Add parser rules
This commit is contained in:
parent
f2d0c4af96
commit
02add4264a
@ -46,31 +46,80 @@ x.x
|
||||
Operators
|
||||
==================
|
||||
|
||||
+ - = / & |
|
||||
x = y
|
||||
x + y
|
||||
x | y
|
||||
x - y
|
||||
x / y
|
||||
x ; y
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(expression
|
||||
(identifier)
|
||||
(operator)
|
||||
(operator)
|
||||
(operator)
|
||||
(operator)
|
||||
(operator)
|
||||
(operator)))
|
||||
|
||||
==================
|
||||
Expressions
|
||||
==================
|
||||
|
||||
x_x = 1;
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)
|
||||
(operator)
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)
|
||||
(operator)
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)
|
||||
(operator)
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)
|
||||
(operator)
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)
|
||||
(operator)
|
||||
(identifier)))
|
||||
|
||||
==================
|
||||
String
|
||||
==================
|
||||
|
||||
"string"
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(expression
|
||||
(string)))
|
||||
|
||||
==================
|
||||
Integer
|
||||
==================
|
||||
|
||||
1
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(expression
|
||||
(integer)))
|
||||
|
||||
==================
|
||||
List
|
||||
==================
|
||||
|
||||
(1, 2)
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(expression
|
||||
(list
|
||||
(expression
|
||||
(integer))
|
||||
(expression
|
||||
(integer)))))
|
||||
|
||||
|
||||
|
||||
|
18
grammar.js
18
grammar.js
@ -4,15 +4,17 @@ module.exports = grammar({
|
||||
rules: {
|
||||
source_file: $ => repeat(choice($.comment, $.expression)),
|
||||
|
||||
identifier: $ => /[a-zA-Z|_|.]+(_[a-zA-Z]+)*/,
|
||||
|
||||
comment: $ => /(#)(.+?)([\n\r])/,
|
||||
|
||||
expression: $ => choice(
|
||||
$.identifier,
|
||||
$.integer,
|
||||
$.string,
|
||||
$.list,
|
||||
seq($.identifier, $.operator, $.identifier)
|
||||
|
||||
),
|
||||
|
||||
identifier: $ => /[a-zA-Z|_|.]+(_[a-zA-Z]+)*/,
|
||||
|
||||
operator: $ => choice(
|
||||
'=',
|
||||
@ -25,5 +27,15 @@ module.exports = grammar({
|
||||
),
|
||||
|
||||
integer: $ => /\d/,
|
||||
|
||||
string: $ => /"(.*?)\"/,
|
||||
|
||||
function: $ => /'(.*?)\'/,
|
||||
|
||||
list: $ => seq(
|
||||
'(',
|
||||
repeat1(seq($.expression, optional(','))),
|
||||
')'
|
||||
),
|
||||
}
|
||||
});
|
||||
|
@ -8,6 +8,15 @@
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"tree-sitter": [
|
||||
{
|
||||
"scope": "source.dust",
|
||||
"file-types": [
|
||||
"ds",
|
||||
"dust",
|
||||
]
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"nan": "^2.17.0"
|
||||
},
|
||||
|
@ -17,10 +17,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"identifier": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z|_|.]+(_[a-zA-Z]+)*"
|
||||
},
|
||||
"comment": {
|
||||
"type": "PATTERN",
|
||||
"value": "(#)(.+?)([\\n\\r])"
|
||||
@ -32,6 +28,18 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "integer"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "string"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "list"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@ -51,6 +59,10 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"identifier": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z|_|.]+(_[a-zA-Z]+)*"
|
||||
},
|
||||
"operator": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
@ -87,6 +99,51 @@
|
||||
"integer": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\d"
|
||||
},
|
||||
"string": {
|
||||
"type": "PATTERN",
|
||||
"value": "\"(.*?)\\\""
|
||||
},
|
||||
"function": {
|
||||
"type": "PATTERN",
|
||||
"value": "'(.*?)\\'"
|
||||
},
|
||||
"list": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
|
@ -11,9 +11,36 @@
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "operator",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -46,10 +73,22 @@
|
||||
"type": "&",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "(",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ")",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "+",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ",",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "-",
|
||||
"named": false
|
||||
@ -74,6 +113,14 @@
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "|",
|
||||
"named": false
|
||||
|
492
src/parser.c
492
src/parser.c
@ -6,19 +6,19 @@
|
||||
#endif
|
||||
|
||||
#define LANGUAGE_VERSION 14
|
||||
#define STATE_COUNT 9
|
||||
#define STATE_COUNT 16
|
||||
#define LARGE_STATE_COUNT 3
|
||||
#define SYMBOL_COUNT 15
|
||||
#define SYMBOL_COUNT 22
|
||||
#define ALIAS_COUNT 0
|
||||
#define TOKEN_COUNT 11
|
||||
#define TOKEN_COUNT 16
|
||||
#define EXTERNAL_TOKEN_COUNT 0
|
||||
#define FIELD_COUNT 0
|
||||
#define MAX_ALIAS_SEQUENCE_LENGTH 3
|
||||
#define PRODUCTION_ID_COUNT 1
|
||||
|
||||
enum {
|
||||
sym_identifier = 1,
|
||||
sym_comment = 2,
|
||||
sym_comment = 1,
|
||||
sym_identifier = 2,
|
||||
anon_sym_EQ = 3,
|
||||
anon_sym_DASH = 4,
|
||||
anon_sym_PLUS = 5,
|
||||
@ -27,16 +27,23 @@ enum {
|
||||
anon_sym_PIPE = 8,
|
||||
anon_sym_AMP = 9,
|
||||
sym_integer = 10,
|
||||
sym_source_file = 11,
|
||||
sym_expression = 12,
|
||||
sym_operator = 13,
|
||||
aux_sym_source_file_repeat1 = 14,
|
||||
sym_string = 11,
|
||||
sym_function = 12,
|
||||
anon_sym_LPAREN = 13,
|
||||
anon_sym_COMMA = 14,
|
||||
anon_sym_RPAREN = 15,
|
||||
sym_source_file = 16,
|
||||
sym_expression = 17,
|
||||
sym_operator = 18,
|
||||
sym_list = 19,
|
||||
aux_sym_source_file_repeat1 = 20,
|
||||
aux_sym_list_repeat1 = 21,
|
||||
};
|
||||
|
||||
static const char * const ts_symbol_names[] = {
|
||||
[ts_builtin_sym_end] = "end",
|
||||
[sym_identifier] = "identifier",
|
||||
[sym_comment] = "comment",
|
||||
[sym_identifier] = "identifier",
|
||||
[anon_sym_EQ] = "=",
|
||||
[anon_sym_DASH] = "-",
|
||||
[anon_sym_PLUS] = "+",
|
||||
@ -45,16 +52,23 @@ static const char * const ts_symbol_names[] = {
|
||||
[anon_sym_PIPE] = "|",
|
||||
[anon_sym_AMP] = "&",
|
||||
[sym_integer] = "integer",
|
||||
[sym_string] = "string",
|
||||
[sym_function] = "function",
|
||||
[anon_sym_LPAREN] = "(",
|
||||
[anon_sym_COMMA] = ",",
|
||||
[anon_sym_RPAREN] = ")",
|
||||
[sym_source_file] = "source_file",
|
||||
[sym_expression] = "expression",
|
||||
[sym_operator] = "operator",
|
||||
[sym_list] = "list",
|
||||
[aux_sym_source_file_repeat1] = "source_file_repeat1",
|
||||
[aux_sym_list_repeat1] = "list_repeat1",
|
||||
};
|
||||
|
||||
static const TSSymbol ts_symbol_map[] = {
|
||||
[ts_builtin_sym_end] = ts_builtin_sym_end,
|
||||
[sym_identifier] = sym_identifier,
|
||||
[sym_comment] = sym_comment,
|
||||
[sym_identifier] = sym_identifier,
|
||||
[anon_sym_EQ] = anon_sym_EQ,
|
||||
[anon_sym_DASH] = anon_sym_DASH,
|
||||
[anon_sym_PLUS] = anon_sym_PLUS,
|
||||
@ -63,10 +77,17 @@ static const TSSymbol ts_symbol_map[] = {
|
||||
[anon_sym_PIPE] = anon_sym_PIPE,
|
||||
[anon_sym_AMP] = anon_sym_AMP,
|
||||
[sym_integer] = sym_integer,
|
||||
[sym_string] = sym_string,
|
||||
[sym_function] = sym_function,
|
||||
[anon_sym_LPAREN] = anon_sym_LPAREN,
|
||||
[anon_sym_COMMA] = anon_sym_COMMA,
|
||||
[anon_sym_RPAREN] = anon_sym_RPAREN,
|
||||
[sym_source_file] = sym_source_file,
|
||||
[sym_expression] = sym_expression,
|
||||
[sym_operator] = sym_operator,
|
||||
[sym_list] = sym_list,
|
||||
[aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1,
|
||||
[aux_sym_list_repeat1] = aux_sym_list_repeat1,
|
||||
};
|
||||
|
||||
static const TSSymbolMetadata ts_symbol_metadata[] = {
|
||||
@ -74,11 +95,11 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[sym_identifier] = {
|
||||
[sym_comment] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_comment] = {
|
||||
[sym_identifier] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
@ -114,6 +135,26 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_string] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_function] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[anon_sym_LPAREN] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_COMMA] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_RPAREN] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[sym_source_file] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
@ -126,10 +167,18 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_list] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[aux_sym_source_file_repeat1] = {
|
||||
.visible = false,
|
||||
.named = false,
|
||||
},
|
||||
[aux_sym_list_repeat1] = {
|
||||
.visible = false,
|
||||
.named = false,
|
||||
},
|
||||
};
|
||||
|
||||
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
|
||||
@ -150,6 +199,13 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
|
||||
[6] = 6,
|
||||
[7] = 7,
|
||||
[8] = 8,
|
||||
[9] = 9,
|
||||
[10] = 10,
|
||||
[11] = 11,
|
||||
[12] = 12,
|
||||
[13] = 13,
|
||||
[14] = 14,
|
||||
[15] = 15,
|
||||
};
|
||||
|
||||
static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
@ -157,24 +213,29 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
eof = lexer->eof(lexer);
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (eof) ADVANCE(4);
|
||||
if (lookahead == '#') ADVANCE(2);
|
||||
if (lookahead == '&') ADVANCE(15);
|
||||
if (lookahead == '+') ADVANCE(11);
|
||||
if (lookahead == '-') ADVANCE(10);
|
||||
if (lookahead == '/') ADVANCE(13);
|
||||
if (lookahead == ';') ADVANCE(12);
|
||||
if (lookahead == '=') ADVANCE(9);
|
||||
if (lookahead == '|') ADVANCE(14);
|
||||
if (eof) ADVANCE(6);
|
||||
if (lookahead == '"') ADVANCE(2);
|
||||
if (lookahead == '#') ADVANCE(4);
|
||||
if (lookahead == '&') ADVANCE(17);
|
||||
if (lookahead == '\'') ADVANCE(3);
|
||||
if (lookahead == '(') ADVANCE(21);
|
||||
if (lookahead == ')') ADVANCE(23);
|
||||
if (lookahead == '+') ADVANCE(13);
|
||||
if (lookahead == ',') ADVANCE(22);
|
||||
if (lookahead == '-') ADVANCE(12);
|
||||
if (lookahead == '/') ADVANCE(15);
|
||||
if (lookahead == ';') ADVANCE(14);
|
||||
if (lookahead == '=') ADVANCE(11);
|
||||
if (lookahead == '|') ADVANCE(16);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(0)
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(16);
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(18);
|
||||
if (lookahead == '.' ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
lookahead == '_' ||
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(6);
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(10);
|
||||
END_STATE();
|
||||
case 1:
|
||||
if (lookahead == '\n') ADVANCE(7);
|
||||
@ -182,40 +243,39 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
if (lookahead != 0) ADVANCE(1);
|
||||
END_STATE();
|
||||
case 2:
|
||||
if (lookahead == '"') ADVANCE(19);
|
||||
if (lookahead != 0 &&
|
||||
lookahead != '\n') ADVANCE(2);
|
||||
END_STATE();
|
||||
case 3:
|
||||
if (lookahead == '\'') ADVANCE(20);
|
||||
if (lookahead != 0 &&
|
||||
lookahead != '\n') ADVANCE(3);
|
||||
END_STATE();
|
||||
case 4:
|
||||
if (lookahead != 0 &&
|
||||
lookahead != '\n') ADVANCE(1);
|
||||
END_STATE();
|
||||
case 3:
|
||||
if (eof) ADVANCE(4);
|
||||
if (lookahead == '#') ADVANCE(2);
|
||||
case 5:
|
||||
if (eof) ADVANCE(6);
|
||||
if (lookahead == '"') ADVANCE(2);
|
||||
if (lookahead == '#') ADVANCE(4);
|
||||
if (lookahead == '(') ADVANCE(21);
|
||||
if (lookahead == ')') ADVANCE(23);
|
||||
if (lookahead == ',') ADVANCE(22);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(3)
|
||||
lookahead == ' ') SKIP(5)
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(18);
|
||||
if (lookahead == '.' ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
lookahead == '_' ||
|
||||
('a' <= lookahead && lookahead <= 'z') ||
|
||||
lookahead == '|') ADVANCE(6);
|
||||
END_STATE();
|
||||
case 4:
|
||||
ACCEPT_TOKEN(ts_builtin_sym_end);
|
||||
END_STATE();
|
||||
case 5:
|
||||
ACCEPT_TOKEN(sym_identifier);
|
||||
if (lookahead == '_') ADVANCE(5);
|
||||
if (lookahead == '.' ||
|
||||
lookahead == '|') ADVANCE(6);
|
||||
if (('A' <= lookahead && lookahead <= 'Z') ||
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(5);
|
||||
lookahead == '|') ADVANCE(10);
|
||||
END_STATE();
|
||||
case 6:
|
||||
ACCEPT_TOKEN(sym_identifier);
|
||||
if (lookahead == '_') ADVANCE(5);
|
||||
if (lookahead == '.' ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
('a' <= lookahead && lookahead <= 'z') ||
|
||||
lookahead == '|') ADVANCE(6);
|
||||
ACCEPT_TOKEN(ts_builtin_sym_end);
|
||||
END_STATE();
|
||||
case 7:
|
||||
ACCEPT_TOKEN(sym_comment);
|
||||
@ -227,34 +287,71 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
if (lookahead != 0) ADVANCE(1);
|
||||
END_STATE();
|
||||
case 9:
|
||||
ACCEPT_TOKEN(anon_sym_EQ);
|
||||
ACCEPT_TOKEN(sym_identifier);
|
||||
if (lookahead == '_') ADVANCE(9);
|
||||
if (lookahead == '.' ||
|
||||
lookahead == '|') ADVANCE(10);
|
||||
if (('A' <= lookahead && lookahead <= 'Z') ||
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(9);
|
||||
END_STATE();
|
||||
case 10:
|
||||
ACCEPT_TOKEN(anon_sym_DASH);
|
||||
END_STATE();
|
||||
case 11:
|
||||
ACCEPT_TOKEN(anon_sym_PLUS);
|
||||
END_STATE();
|
||||
case 12:
|
||||
ACCEPT_TOKEN(anon_sym_SEMI);
|
||||
END_STATE();
|
||||
case 13:
|
||||
ACCEPT_TOKEN(anon_sym_SLASH);
|
||||
END_STATE();
|
||||
case 14:
|
||||
ACCEPT_TOKEN(anon_sym_PIPE);
|
||||
if (lookahead == '_') ADVANCE(5);
|
||||
ACCEPT_TOKEN(sym_identifier);
|
||||
if (lookahead == '_') ADVANCE(9);
|
||||
if (lookahead == '.' ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
('a' <= lookahead && lookahead <= 'z') ||
|
||||
lookahead == '|') ADVANCE(6);
|
||||
lookahead == '|') ADVANCE(10);
|
||||
END_STATE();
|
||||
case 11:
|
||||
ACCEPT_TOKEN(anon_sym_EQ);
|
||||
END_STATE();
|
||||
case 12:
|
||||
ACCEPT_TOKEN(anon_sym_DASH);
|
||||
END_STATE();
|
||||
case 13:
|
||||
ACCEPT_TOKEN(anon_sym_PLUS);
|
||||
END_STATE();
|
||||
case 14:
|
||||
ACCEPT_TOKEN(anon_sym_SEMI);
|
||||
END_STATE();
|
||||
case 15:
|
||||
ACCEPT_TOKEN(anon_sym_AMP);
|
||||
ACCEPT_TOKEN(anon_sym_SLASH);
|
||||
END_STATE();
|
||||
case 16:
|
||||
ACCEPT_TOKEN(anon_sym_PIPE);
|
||||
if (lookahead == '_') ADVANCE(9);
|
||||
if (lookahead == '.' ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
('a' <= lookahead && lookahead <= 'z') ||
|
||||
lookahead == '|') ADVANCE(10);
|
||||
END_STATE();
|
||||
case 17:
|
||||
ACCEPT_TOKEN(anon_sym_AMP);
|
||||
END_STATE();
|
||||
case 18:
|
||||
ACCEPT_TOKEN(sym_integer);
|
||||
END_STATE();
|
||||
case 19:
|
||||
ACCEPT_TOKEN(sym_string);
|
||||
if (lookahead == '"') ADVANCE(19);
|
||||
if (lookahead != 0 &&
|
||||
lookahead != '\n') ADVANCE(2);
|
||||
END_STATE();
|
||||
case 20:
|
||||
ACCEPT_TOKEN(sym_function);
|
||||
if (lookahead == '\'') ADVANCE(20);
|
||||
if (lookahead != 0 &&
|
||||
lookahead != '\n') ADVANCE(3);
|
||||
END_STATE();
|
||||
case 21:
|
||||
ACCEPT_TOKEN(anon_sym_LPAREN);
|
||||
END_STATE();
|
||||
case 22:
|
||||
ACCEPT_TOKEN(anon_sym_COMMA);
|
||||
END_STATE();
|
||||
case 23:
|
||||
ACCEPT_TOKEN(anon_sym_RPAREN);
|
||||
END_STATE();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -262,21 +359,28 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
|
||||
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
|
||||
[0] = {.lex_state = 0},
|
||||
[1] = {.lex_state = 3},
|
||||
[1] = {.lex_state = 5},
|
||||
[2] = {.lex_state = 0},
|
||||
[3] = {.lex_state = 3},
|
||||
[4] = {.lex_state = 3},
|
||||
[5] = {.lex_state = 3},
|
||||
[6] = {.lex_state = 0},
|
||||
[7] = {.lex_state = 3},
|
||||
[8] = {.lex_state = 3},
|
||||
[3] = {.lex_state = 5},
|
||||
[4] = {.lex_state = 5},
|
||||
[5] = {.lex_state = 5},
|
||||
[6] = {.lex_state = 5},
|
||||
[7] = {.lex_state = 5},
|
||||
[8] = {.lex_state = 5},
|
||||
[9] = {.lex_state = 5},
|
||||
[10] = {.lex_state = 5},
|
||||
[11] = {.lex_state = 5},
|
||||
[12] = {.lex_state = 5},
|
||||
[13] = {.lex_state = 0},
|
||||
[14] = {.lex_state = 5},
|
||||
[15] = {.lex_state = 5},
|
||||
};
|
||||
|
||||
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||
[0] = {
|
||||
[ts_builtin_sym_end] = ACTIONS(1),
|
||||
[sym_identifier] = ACTIONS(1),
|
||||
[sym_comment] = ACTIONS(1),
|
||||
[sym_identifier] = ACTIONS(1),
|
||||
[anon_sym_EQ] = ACTIONS(1),
|
||||
[anon_sym_DASH] = ACTIONS(1),
|
||||
[anon_sym_PLUS] = ACTIONS(1),
|
||||
@ -285,95 +389,229 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||
[anon_sym_PIPE] = ACTIONS(1),
|
||||
[anon_sym_AMP] = ACTIONS(1),
|
||||
[sym_integer] = ACTIONS(1),
|
||||
[sym_string] = ACTIONS(1),
|
||||
[sym_function] = ACTIONS(1),
|
||||
[anon_sym_LPAREN] = ACTIONS(1),
|
||||
[anon_sym_COMMA] = ACTIONS(1),
|
||||
[anon_sym_RPAREN] = ACTIONS(1),
|
||||
},
|
||||
[1] = {
|
||||
[sym_source_file] = STATE(6),
|
||||
[sym_source_file] = STATE(13),
|
||||
[sym_expression] = STATE(3),
|
||||
[sym_list] = STATE(5),
|
||||
[aux_sym_source_file_repeat1] = STATE(3),
|
||||
[ts_builtin_sym_end] = ACTIONS(3),
|
||||
[sym_identifier] = ACTIONS(5),
|
||||
[sym_comment] = ACTIONS(7),
|
||||
[sym_comment] = ACTIONS(5),
|
||||
[sym_identifier] = ACTIONS(7),
|
||||
[sym_integer] = ACTIONS(9),
|
||||
[sym_string] = ACTIONS(9),
|
||||
[anon_sym_LPAREN] = ACTIONS(11),
|
||||
},
|
||||
[2] = {
|
||||
[sym_operator] = STATE(8),
|
||||
[ts_builtin_sym_end] = ACTIONS(9),
|
||||
[sym_identifier] = ACTIONS(11),
|
||||
[sym_comment] = ACTIONS(9),
|
||||
[anon_sym_EQ] = ACTIONS(13),
|
||||
[anon_sym_DASH] = ACTIONS(13),
|
||||
[anon_sym_PLUS] = ACTIONS(13),
|
||||
[anon_sym_SEMI] = ACTIONS(13),
|
||||
[anon_sym_SLASH] = ACTIONS(13),
|
||||
[anon_sym_PIPE] = ACTIONS(15),
|
||||
[anon_sym_AMP] = ACTIONS(13),
|
||||
[sym_operator] = STATE(15),
|
||||
[ts_builtin_sym_end] = ACTIONS(13),
|
||||
[sym_comment] = ACTIONS(13),
|
||||
[sym_identifier] = ACTIONS(15),
|
||||
[anon_sym_EQ] = ACTIONS(17),
|
||||
[anon_sym_DASH] = ACTIONS(17),
|
||||
[anon_sym_PLUS] = ACTIONS(17),
|
||||
[anon_sym_SEMI] = ACTIONS(17),
|
||||
[anon_sym_SLASH] = ACTIONS(17),
|
||||
[anon_sym_PIPE] = ACTIONS(19),
|
||||
[anon_sym_AMP] = ACTIONS(17),
|
||||
[sym_integer] = ACTIONS(13),
|
||||
[sym_string] = ACTIONS(13),
|
||||
[anon_sym_LPAREN] = ACTIONS(13),
|
||||
[anon_sym_COMMA] = ACTIONS(13),
|
||||
[anon_sym_RPAREN] = ACTIONS(13),
|
||||
},
|
||||
};
|
||||
|
||||
static const uint16_t ts_small_parse_table[] = {
|
||||
[0] = 4,
|
||||
ACTIONS(5), 1,
|
||||
[0] = 7,
|
||||
ACTIONS(7), 1,
|
||||
sym_identifier,
|
||||
ACTIONS(17), 1,
|
||||
ts_builtin_sym_end,
|
||||
ACTIONS(19), 1,
|
||||
sym_comment,
|
||||
STATE(4), 2,
|
||||
sym_expression,
|
||||
aux_sym_source_file_repeat1,
|
||||
[14] = 4,
|
||||
ACTIONS(11), 1,
|
||||
anon_sym_LPAREN,
|
||||
ACTIONS(21), 1,
|
||||
ts_builtin_sym_end,
|
||||
ACTIONS(23), 1,
|
||||
sym_identifier,
|
||||
ACTIONS(26), 1,
|
||||
sym_comment,
|
||||
STATE(5), 1,
|
||||
sym_list,
|
||||
ACTIONS(9), 2,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
STATE(4), 2,
|
||||
sym_expression,
|
||||
aux_sym_source_file_repeat1,
|
||||
[28] = 1,
|
||||
ACTIONS(29), 3,
|
||||
[24] = 7,
|
||||
ACTIONS(25), 1,
|
||||
ts_builtin_sym_end,
|
||||
sym_identifier,
|
||||
ACTIONS(27), 1,
|
||||
sym_comment,
|
||||
[34] = 1,
|
||||
ACTIONS(31), 1,
|
||||
ts_builtin_sym_end,
|
||||
[38] = 1,
|
||||
ACTIONS(33), 1,
|
||||
ACTIONS(30), 1,
|
||||
sym_identifier,
|
||||
[42] = 1,
|
||||
ACTIONS(35), 1,
|
||||
ACTIONS(36), 1,
|
||||
anon_sym_LPAREN,
|
||||
STATE(5), 1,
|
||||
sym_list,
|
||||
ACTIONS(33), 2,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
STATE(4), 2,
|
||||
sym_expression,
|
||||
aux_sym_source_file_repeat1,
|
||||
[48] = 1,
|
||||
ACTIONS(13), 8,
|
||||
ts_builtin_sym_end,
|
||||
sym_comment,
|
||||
sym_identifier,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
anon_sym_LPAREN,
|
||||
anon_sym_COMMA,
|
||||
anon_sym_RPAREN,
|
||||
[59] = 7,
|
||||
ACTIONS(7), 1,
|
||||
sym_identifier,
|
||||
ACTIONS(11), 1,
|
||||
anon_sym_LPAREN,
|
||||
ACTIONS(39), 1,
|
||||
anon_sym_RPAREN,
|
||||
STATE(5), 1,
|
||||
sym_list,
|
||||
STATE(9), 1,
|
||||
aux_sym_list_repeat1,
|
||||
STATE(11), 1,
|
||||
sym_expression,
|
||||
ACTIONS(9), 2,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
[82] = 1,
|
||||
ACTIONS(41), 8,
|
||||
ts_builtin_sym_end,
|
||||
sym_comment,
|
||||
sym_identifier,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
anon_sym_LPAREN,
|
||||
anon_sym_COMMA,
|
||||
anon_sym_RPAREN,
|
||||
[93] = 1,
|
||||
ACTIONS(43), 8,
|
||||
ts_builtin_sym_end,
|
||||
sym_comment,
|
||||
sym_identifier,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
anon_sym_LPAREN,
|
||||
anon_sym_COMMA,
|
||||
anon_sym_RPAREN,
|
||||
[104] = 7,
|
||||
ACTIONS(45), 1,
|
||||
sym_identifier,
|
||||
ACTIONS(51), 1,
|
||||
anon_sym_LPAREN,
|
||||
ACTIONS(54), 1,
|
||||
anon_sym_RPAREN,
|
||||
STATE(5), 1,
|
||||
sym_list,
|
||||
STATE(9), 1,
|
||||
aux_sym_list_repeat1,
|
||||
STATE(11), 1,
|
||||
sym_expression,
|
||||
ACTIONS(48), 2,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
[127] = 6,
|
||||
ACTIONS(7), 1,
|
||||
sym_identifier,
|
||||
ACTIONS(11), 1,
|
||||
anon_sym_LPAREN,
|
||||
STATE(5), 1,
|
||||
sym_list,
|
||||
STATE(6), 1,
|
||||
aux_sym_list_repeat1,
|
||||
STATE(11), 1,
|
||||
sym_expression,
|
||||
ACTIONS(9), 2,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
[147] = 2,
|
||||
ACTIONS(58), 1,
|
||||
anon_sym_COMMA,
|
||||
ACTIONS(56), 5,
|
||||
sym_identifier,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
anon_sym_LPAREN,
|
||||
anon_sym_RPAREN,
|
||||
[158] = 1,
|
||||
ACTIONS(54), 5,
|
||||
sym_identifier,
|
||||
sym_integer,
|
||||
sym_string,
|
||||
anon_sym_LPAREN,
|
||||
anon_sym_RPAREN,
|
||||
[166] = 1,
|
||||
ACTIONS(60), 1,
|
||||
ts_builtin_sym_end,
|
||||
[170] = 1,
|
||||
ACTIONS(62), 1,
|
||||
sym_identifier,
|
||||
[174] = 1,
|
||||
ACTIONS(64), 1,
|
||||
sym_identifier,
|
||||
};
|
||||
|
||||
static const uint32_t ts_small_parse_table_map[] = {
|
||||
[SMALL_STATE(3)] = 0,
|
||||
[SMALL_STATE(4)] = 14,
|
||||
[SMALL_STATE(5)] = 28,
|
||||
[SMALL_STATE(6)] = 34,
|
||||
[SMALL_STATE(7)] = 38,
|
||||
[SMALL_STATE(8)] = 42,
|
||||
[SMALL_STATE(4)] = 24,
|
||||
[SMALL_STATE(5)] = 48,
|
||||
[SMALL_STATE(6)] = 59,
|
||||
[SMALL_STATE(7)] = 82,
|
||||
[SMALL_STATE(8)] = 93,
|
||||
[SMALL_STATE(9)] = 104,
|
||||
[SMALL_STATE(10)] = 127,
|
||||
[SMALL_STATE(11)] = 147,
|
||||
[SMALL_STATE(12)] = 158,
|
||||
[SMALL_STATE(13)] = 166,
|
||||
[SMALL_STATE(14)] = 170,
|
||||
[SMALL_STATE(15)] = 174,
|
||||
};
|
||||
|
||||
static const TSParseActionEntry ts_parse_actions[] = {
|
||||
[0] = {.entry = {.count = 0, .reusable = false}},
|
||||
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
|
||||
[3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0),
|
||||
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
|
||||
[7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),
|
||||
[9] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 1),
|
||||
[11] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression, 1),
|
||||
[13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),
|
||||
[15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(7),
|
||||
[17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1),
|
||||
[19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
|
||||
[21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2),
|
||||
[23] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(2),
|
||||
[26] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(4),
|
||||
[29] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 3),
|
||||
[31] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
|
||||
[33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_operator, 1),
|
||||
[35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),
|
||||
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),
|
||||
[7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
|
||||
[9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),
|
||||
[11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10),
|
||||
[13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 1),
|
||||
[15] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression, 1),
|
||||
[17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14),
|
||||
[19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14),
|
||||
[21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1),
|
||||
[23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
|
||||
[25] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2),
|
||||
[27] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(4),
|
||||
[30] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(2),
|
||||
[33] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(5),
|
||||
[36] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(10),
|
||||
[39] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8),
|
||||
[41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 3),
|
||||
[43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list, 3),
|
||||
[45] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_list_repeat1, 2), SHIFT_REPEAT(2),
|
||||
[48] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_list_repeat1, 2), SHIFT_REPEAT(5),
|
||||
[51] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_list_repeat1, 2), SHIFT_REPEAT(10),
|
||||
[54] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_list_repeat1, 2),
|
||||
[56] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_list_repeat1, 1),
|
||||
[58] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12),
|
||||
[60] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
|
||||
[62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_operator, 1),
|
||||
[64] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user