Skip to content

Commit

Permalink
Added raw string grammar and unification stmt test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal <[email protected]>
  • Loading branch information
Vishalk91-4 committed Jun 8, 2024
1 parent ce0f797 commit 32ada31
Show file tree
Hide file tree
Showing 6 changed files with 36,823 additions and 36,676 deletions.
21 changes: 20 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ module.exports = grammar({
),

unification: $ => seq(
field('left', $.identifier),
field('left', $.dotted_name),
':',
field('right', $.schema_expr),
),
Expand Down Expand Up @@ -885,6 +885,25 @@ module.exports = grammar({
$.expression,
)),

raw_string: $ => prec(64, seq(
$.raw_string_start,
repeat($.string_content),
$.string_end,
)),

raw_string_content: $ => prec.right(repeat1(
choice(
$._not_escape_sequence,
$._raw_string_content,
))),

raw_string_start: $ => token(seq(
choice('r', 'R'),
'"'
)),

_raw_string_content: $ => /[^"]/, // matches any character except "

string: $ => seq(
$.string_start,
repeat($.string_content),
Expand Down
129 changes: 101 additions & 28 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
},
{
"type": "SYMBOL",
"name": "augmented_assignment"
"name": "assignment"
},
{
"type": "SYMBOL",
"name": "unification"
"name": "augmented_assignment"
},
{
"type": "SYMBOL",
"name": "assignment"
"name": "unification"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -81,31 +81,6 @@
}
]
},
"unification": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "identifier",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": ":"
},
{
"type": "FIELD",
"name": "schema_expr",
"content": {
"type": "SYMBOL",
"name": "schema_expr"
}
}
]
},
"import_prefix": {
"type": "REPEAT1",
"content": {
Expand Down Expand Up @@ -2669,6 +2644,31 @@
}
]
},
"unification": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL",
"name": "dotted_name"
}
},
{
"type": "STRING",
"value": ":"
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "SYMBOL",
"name": "schema_expr"
}
}
]
},
"attribute": {
"type": "PREC_RIGHT",
"value": 11,
Expand Down Expand Up @@ -3724,6 +3724,79 @@
]
}
},
"raw_string": {
"type": "PREC",
"value": 64,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "raw_string_start"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "string_content"
}
},
{
"type": "SYMBOL",
"name": "string_end"
}
]
}
},
"raw_string_content": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_not_escape_sequence"
},
{
"type": "SYMBOL",
"name": "_raw_string_content"
}
]
}
}
},
"raw_string_start": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "r"
},
{
"type": "STRING",
"value": "R"
}
]
},
{
"type": "STRING",
"value": "\""
}
]
}
},
"_raw_string_content": {
"type": "PATTERN",
"value": "[^\"]"
},
"string": {
"type": "SEQ",
"members": [
Expand Down
10 changes: 7 additions & 3 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2154,17 +2154,17 @@
"type": "unification",
"named": true,
"fields": {
"identifier": {
"left": {
"multiple": false,
"required": true,
"types": [
{
"type": "identifier",
"type": "dotted_name",
"named": true
}
]
},
"schema_expr": {
"right": {
"multiple": false,
"required": true,
"types": [
Expand Down Expand Up @@ -2555,6 +2555,10 @@
"type": "protocol",
"named": false
},
{
"type": "raw_string_start",
"named": true
},
{
"type": "rule",
"named": false
Expand Down
Loading

0 comments on commit 32ada31

Please sign in to comment.