New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tree-sitter-cairo

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-sitter-cairo - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

38

grammar.js

@@ -17,2 +17,3 @@ module.exports = grammar({

[$.return_statement, $.expression_statement],
[$._generic_arguments, $.binary_expression]
],

@@ -49,3 +50,3 @@

_generic_arguments: $ => prec(10, seq('<', commaSep1($._expression), '>')),
_generic_arguments: $ => prec.right(10, seq('<', commaSep1($._expression), '>')),

@@ -64,3 +65,3 @@ // Boolean expressions

// Unary expressions
unary_expression: $ => prec.left(1, seq($._unary_operator, $._expression)),
unary_expression: $ => prec.left(seq($._unary_operator, $._expression)),
_unary_operator: $ => choice(

@@ -72,3 +73,3 @@ '!',

// Binary expressions
binary_expression: $ => prec.right(1, seq($._expression, $._binary_operator, $._expression)),
binary_expression: $ => prec.left(seq($._expression, $._binary_operator, $._expression)),

@@ -95,6 +96,7 @@ _binary_operator: $ => choice(

// Tuple expressions
tuple_expression: $ => seq('(', commaSep1($._expression), ')'),
tuple_expression: $ => seq('(', commaSep($._expression), ')'),
// Function call expressions
function_call_expression: $ => seq($.path_expression, '(', commaSep($._expression), ')'),
_arguments: $ => seq($._expression, repeat(seq(',', $._expression)), optional(',')),
function_call_expression: $ => seq($.path_expression, '(', optional($._arguments), ')'),

@@ -123,3 +125,9 @@ // Struct ctor call expressions

// If expressions
if_expression: $ => seq('if', $._expression, $.block_expression, optional(seq('else', $.block_expression))),
if_expression: $ => seq(
'if',
$._expression,
$.block_expression,
optional(seq('else', 'if', $._expression, $.block_expression,)),
optional(seq('else', $.block_expression))
),

@@ -171,3 +179,3 @@ // TODO: block or if

// == Type Clauses ==
type_clause: $ => seq(':', $._expression),
type_clause: $ => prec(1, seq(':', $._expression)),

@@ -185,8 +193,8 @@ return_type_clause: $ => seq('->', $._expression),

let_statement: $ => seq('let', $._pattern, optional($.type_clause), "=", optional($._expression), ';'),
let_statement: $ => seq('let', $._pattern, optional($.type_clause), optional(seq('=', $._expression)), ';'),
expression_statement: $ => choice($.match_expression, seq($._expression, ';')),
return_statement: $ => choice(
return_statement: $ => prec(-1, choice(
seq('return', optional($._expression), ';'),
$._expression,
),
)),

@@ -197,3 +205,3 @@ // == Functions ==

implicits_clause: $ => seq('implicits', '(', commaSep($.path_expression), ')'),
implicits_clause: $ => seq('implicits', '(', commaSep(seq($.identifier, $.type_clause)), ')'),

@@ -318,3 +326,4 @@ function_signature: $ => seq(

'{',
repeat($.struct_member),
commaSep1($.struct_member),
optional(','),
'}',

@@ -329,3 +338,4 @@ ),

'{',
repeat($.struct_member), // todo: make special node for enum members
commaSep1($.struct_member), // todo: make special node for enum members
optional(','),
'}',

@@ -341,3 +351,3 @@ ),

_generic_param: $ => $.identifier,
_generic_param: $ => choice($.parenthesized_expression, $.identifier),
_wrapped_generic_parameters: $ => seq('<', commaSep($._generic_param), '>'),

@@ -344,0 +354,0 @@

{
"name": "tree-sitter-cairo",
"version": "0.0.1",
"version": "0.0.2",
"description": "A tree-sitter grammar for cairo 1.0",
"main": "bindings/node",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "tree-sitter test && tree-sitter parse ./test/examples/* -q -s"
},

@@ -9,0 +9,0 @@ "repository": {

## 🌴 tree-sitter-cairo
[![Node.js CI](https://github.com/JoranHonig/tree-sitter-cairo/actions/workflows/grammar_tests.yml/badge.svg)](https://github.com/JoranHonig/tree-sitter-cairo/actions/workflows/grammar_tests.yml)
[![npm version](https://badge.fury.io/js/tree-sitter-cairo.svg)](https://badge.fury.io/js/tree-sitter-cairo)

@@ -3,0 +5,0 @@ > 💡 this grammar is still in development, the structure of the generated AST is not stable

@@ -128,3 +128,3 @@ {

"_generic_arguments": {
"type": "PREC",
"type": "PREC_RIGHT",
"value": 10,

@@ -211,3 +211,3 @@ "content": {

"type": "PREC_LEFT",
"value": 1,
"value": 0,
"content": {

@@ -241,4 +241,4 @@ "type": "SEQ",

"binary_expression": {
"type": "PREC_RIGHT",
"value": 1,
"type": "PREC_LEFT",
"value": 0,
"content": {

@@ -339,23 +339,31 @@ "type": "SEQ",

{
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
"type": "BLANK"
}

@@ -370,2 +378,39 @@ ]

},
"_arguments": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
},
"function_call_expression": {

@@ -386,25 +431,4 @@ "type": "SEQ",

{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
}
]
"type": "SYMBOL",
"name": "_arguments"
},

@@ -649,3 +673,11 @@ {

{
"type": "STRING",
"value": "if"
},
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "SYMBOL",
"name": "block_expression"

@@ -659,2 +691,23 @@ }

]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "else"
},
{
"type": "SYMBOL",
"name": "block_expression"
}
]
},
{
"type": "BLANK"
}
]
}

@@ -973,13 +1026,17 @@ ]

"type_clause": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
},

@@ -1047,11 +1104,16 @@ "return_type_clause": {

{
"type": "STRING",
"value": "="
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
},

@@ -1092,34 +1154,38 @@ {

"return_statement": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "return"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
"type": "PREC",
"value": -1,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "return"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
},

@@ -1182,4 +1248,13 @@ "_param_name": {

{
"type": "SYMBOL",
"name": "path_expression"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "type_clause"
}
]
},

@@ -1196,4 +1271,13 @@ {

{
"type": "SYMBOL",
"name": "path_expression"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "type_clause"
}
]
}

@@ -1790,9 +1874,39 @@ ]

{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "struct_member"
}
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "struct_member"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "struct_member"
}
]
}
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",

@@ -1838,9 +1952,39 @@ "value": "}"

{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "struct_member"
}
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "struct_member"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "struct_member"
}
]
}
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",

@@ -1876,4 +2020,13 @@ "value": "}"

"_generic_param": {
"type": "SYMBOL",
"name": "identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "parenthesized_expression"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
},

@@ -1964,2 +2117,6 @@ "_wrapped_generic_parameters": {

"expression_statement"
],
[
"_generic_arguments",
"binary_expression"
]

@@ -1966,0 +2123,0 @@ ],

@@ -192,2 +192,6 @@ [

{
"type": "parenthesized_expression",
"named": true
},
{
"type": "struct_member",

@@ -348,2 +352,6 @@ "named": true

"named": true
},
{
"type": "parenthesized_expression",
"named": true
}

@@ -364,2 +372,6 @@ ]

"named": true
},
{
"type": "parenthesized_expression",
"named": true
}

@@ -392,2 +404,6 @@ ]

"named": true
},
{
"type": "parenthesized_expression",
"named": true
}

@@ -571,2 +587,6 @@ ]

{
"type": "parenthesized_expression",
"named": true
},
{
"type": "path_expression",

@@ -634,4 +654,8 @@ "named": true

{
"type": "path_expression",
"type": "identifier",
"named": true
},
{
"type": "type_clause",
"named": true
}

@@ -1190,2 +1214,6 @@ ]

{
"type": "parenthesized_expression",
"named": true
},
{
"type": "struct_member",

@@ -1300,2 +1328,6 @@ "named": true

{
"type": "parenthesized_expression",
"named": true
},
{
"type": "trait_body",

@@ -1326,2 +1358,6 @@ "named": true

"named": true
},
{
"type": "parenthesized_expression",
"named": true
}

@@ -1337,3 +1373,3 @@ ]

"multiple": true,
"required": true,
"required": false,
"types": [

@@ -1340,0 +1376,0 @@ {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc