Skip to content

Commit

Permalink
self.signer and array type added
Browse files Browse the repository at this point in the history
  • Loading branch information
r001 committed Dec 9, 2023
1 parent 23a9534 commit e04bcd6
Show file tree
Hide file tree
Showing 5 changed files with 26,759 additions and 19,980 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ nvim.appimage
nvim-linux64*
nvim-macos*
nvim-win64*
build/
node_modules/
44 changes: 43 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ module.exports = grammar({
/[a-z0-9]{58}/
),

signature_literal: $ => seq(
'sign',
/[a-z0-9]{212}/
),

annotation: $ => seq(
'@', $.identifier
),
Expand Down Expand Up @@ -396,6 +401,8 @@ module.exports = grammar({

address_type: $ => 'address',

signature_type: $ => 'signature',

unit_type: $ => seq(
"(",
")"
Expand Down Expand Up @@ -430,6 +437,7 @@ module.exports = grammar({
$.group_type,
$.scalar_type,
$.address_type,
$.signature_type,
$.record_type,
),

Expand All @@ -448,6 +456,14 @@ module.exports = grammar({
')'
),

array_type: $ => seq(
'[',
$.type,
';',
$._numeral,
']'
),

type: $ => choice(
$.unsigned_type,
$.signed_type,
Expand All @@ -456,9 +472,11 @@ module.exports = grammar({
$.scalar_type,
$.boolean_type,
$.address_type,
$.signature_type,
$.record_type,
$.unit_type,
$.tuple_type
$.tuple_type,
$.array_type
),

group_coordinate: $ => choice(
Expand Down Expand Up @@ -554,6 +572,18 @@ module.exports = grammar({
')'
),

array_expression: $ => seq(
'[',
$._expression,
repeat1(
seq(
',',
$._expression,
)
),
']'
),

struct_expression: $ => seq(
$.identifier,
'{',
Expand Down Expand Up @@ -585,6 +615,14 @@ module.exports = grammar({
)
),

self_signer: $ => prec(PREC.OBJ_ACCESS,
seq(
'self',
'.',
'signer'
)
),

block_height: $ => prec(PREC.OBJ_ACCESS,
seq(
'block',
Expand All @@ -601,6 +639,7 @@ module.exports = grammar({
$.scalar_literal,
$.boolean_literal,
$.address_literal,
$.signature_literal,
$.affine_group_literal,
$.variable,
$.associated_constant,
Expand All @@ -609,6 +648,7 @@ module.exports = grammar({
$.associated_function_call,
$.unit_expression,
$.tuple_expression,
$.array_expression,
$.struct_expression,
$.self_caller,
$.block_height,
Expand Down Expand Up @@ -650,6 +690,7 @@ module.exports = grammar({
$.scalar_literal,
$.boolean_literal,
$.address_literal,
$.signature_literal,
$.affine_group_literal,
$.variable,
$.associated_constant,
Expand All @@ -658,6 +699,7 @@ module.exports = grammar({
$.associated_function_call,
$.unit_expression,
$.tuple_expression,
$.array_expression,
$.struct_expression,
$.self_caller,
$.block_height,
Expand Down
124 changes: 124 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,19 @@
}
]
},
"signature_literal": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "sign"
},
{
"type": "PATTERN",
"value": "[a-z0-9]{212}"
}
]
},
"annotation": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -1188,6 +1201,10 @@
"type": "STRING",
"value": "address"
},
"signature_type": {
"type": "STRING",
"value": "signature"
},
"unit_type": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -1293,6 +1310,10 @@
"type": "SYMBOL",
"name": "address_type"
},
{
"type": "SYMBOL",
"name": "signature_type"
},
{
"type": "SYMBOL",
"name": "record_type"
Expand Down Expand Up @@ -1344,6 +1365,31 @@
}
]
},
"array_type": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "SYMBOL",
"name": "type"
},
{
"type": "STRING",
"value": ";"
},
{
"type": "SYMBOL",
"name": "_numeral"
},
{
"type": "STRING",
"value": "]"
}
]
},
"type": {
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -1375,6 +1421,10 @@
"type": "SYMBOL",
"name": "address_type"
},
{
"type": "SYMBOL",
"name": "signature_type"
},
{
"type": "SYMBOL",
"name": "record_type"
Expand All @@ -1386,6 +1436,10 @@
{
"type": "SYMBOL",
"name": "tuple_type"
},
{
"type": "SYMBOL",
"name": "array_type"
}
]
},
Expand Down Expand Up @@ -1679,6 +1733,39 @@
}
]
},
"array_expression": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
},
{
"type": "STRING",
"value": "]"
}
]
},
"struct_expression": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -1775,6 +1862,27 @@
]
}
},
"self_signer": {
"type": "PREC",
"value": 17,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "self"
},
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "signer"
}
]
}
},
"block_height": {
"type": "PREC",
"value": 17,
Expand Down Expand Up @@ -1827,6 +1935,10 @@
"type": "SYMBOL",
"name": "address_literal"
},
{
"type": "SYMBOL",
"name": "signature_literal"
},
{
"type": "SYMBOL",
"name": "affine_group_literal"
Expand Down Expand Up @@ -1872,6 +1984,10 @@
"type": "SYMBOL",
"name": "tuple_expression"
},
{
"type": "SYMBOL",
"name": "array_expression"
},
{
"type": "SYMBOL",
"name": "struct_expression"
Expand Down Expand Up @@ -1996,6 +2112,10 @@
"type": "SYMBOL",
"name": "address_literal"
},
{
"type": "SYMBOL",
"name": "signature_literal"
},
{
"type": "SYMBOL",
"name": "affine_group_literal"
Expand Down Expand Up @@ -2045,6 +2165,10 @@
"type": "SYMBOL",
"name": "tuple_expression"
},
{
"type": "SYMBOL",
"name": "array_expression"
},
{
"type": "SYMBOL",
"name": "struct_expression"
Expand Down
Loading

0 comments on commit e04bcd6

Please sign in to comment.