first commit
This commit is contained in:
commit
b21727a3fe
20 changed files with 18126 additions and 0 deletions
1922
parsers/filters/lexer.js
Normal file
1922
parsers/filters/lexer.js
Normal file
File diff suppressed because it is too large
Load diff
1152
parsers/filters/parser.js
Normal file
1152
parsers/filters/parser.js
Normal file
File diff suppressed because it is too large
Load diff
155
parsers/filters/parser.out
Normal file
155
parsers/filters/parser.out
Normal file
|
@ -0,0 +1,155 @@
|
|||
State 0:
|
||||
main ::= * expr
|
||||
string ::= * STRING_LITERAL
|
||||
id ::= * string
|
||||
id ::= * ID
|
||||
eq ::= * id EQ literal
|
||||
and ::= * expr AND expr
|
||||
expr ::= * eq
|
||||
expr ::= * and
|
||||
expr ::= * LCB expr RCB
|
||||
|
||||
STRING_LITERAL shift-reduce 3 string ::= STRING_LITERAL
|
||||
ID shift-reduce 5 id ::= ID
|
||||
LCB shift 1
|
||||
main accept
|
||||
expr shift 6
|
||||
string shift-reduce 4 id ::= string
|
||||
id shift 11
|
||||
eq shift-reduce 8 expr ::= eq
|
||||
and shift-reduce 9 expr ::= and
|
||||
|
||||
State 1:
|
||||
string ::= * STRING_LITERAL
|
||||
id ::= * string
|
||||
id ::= * ID
|
||||
eq ::= * id EQ literal
|
||||
and ::= * expr AND expr
|
||||
expr ::= * eq
|
||||
expr ::= * and
|
||||
expr ::= * LCB expr RCB
|
||||
expr ::= LCB * expr RCB
|
||||
|
||||
STRING_LITERAL shift-reduce 3 string ::= STRING_LITERAL
|
||||
ID shift-reduce 5 id ::= ID
|
||||
LCB shift 1
|
||||
expr shift 5
|
||||
string shift-reduce 4 id ::= string
|
||||
id shift 11
|
||||
eq shift-reduce 8 expr ::= eq
|
||||
and shift-reduce 9 expr ::= and
|
||||
|
||||
State 2:
|
||||
string ::= * STRING_LITERAL
|
||||
id ::= * string
|
||||
id ::= * ID
|
||||
eq ::= * id EQ literal
|
||||
and ::= * expr AND expr
|
||||
and ::= expr AND * expr
|
||||
expr ::= * eq
|
||||
expr ::= * and
|
||||
expr ::= * LCB expr RCB
|
||||
|
||||
STRING_LITERAL shift-reduce 3 string ::= STRING_LITERAL
|
||||
ID shift-reduce 5 id ::= ID
|
||||
LCB shift 1
|
||||
expr shift-reduce 7 and ::= expr AND expr
|
||||
string shift-reduce 4 id ::= string
|
||||
id shift 11
|
||||
eq shift-reduce 8 expr ::= eq
|
||||
and shift-reduce 9 expr ::= and
|
||||
|
||||
State 3:
|
||||
integer ::= * INTEGER_LITERAL
|
||||
literal ::= * integer
|
||||
eq ::= id EQ * literal
|
||||
address_literal ::= * ADDRESS LSB address_literal_content_or_empty RSB
|
||||
literal ::= * address_literal
|
||||
|
||||
INTEGER_LITERAL shift-reduce 1 integer ::= INTEGER_LITERAL
|
||||
ADDRESS shift 10
|
||||
integer shift-reduce 2 literal ::= integer
|
||||
literal shift-reduce 6 eq ::= id EQ literal
|
||||
address_literal shift-reduce 16 literal ::= address_literal
|
||||
|
||||
State 4:
|
||||
address_literal_content ::= * STRING_LITERAL
|
||||
address_literal_content ::= * address_literal_content COMMA STRING_LITERAL
|
||||
address_literal_content_or_empty ::= * address_literal_content
|
||||
(14) address_literal_content_or_empty ::= *
|
||||
address_literal ::= ADDRESS LSB * address_literal_content_or_empty RSB
|
||||
|
||||
STRING_LITERAL shift-reduce 11 address_literal_content ::= STRING_LITERAL
|
||||
address_literal_content shift 9
|
||||
address_literal_content_or_empty shift 7
|
||||
{default} reduce 14 address_literal_content_or_empty ::=
|
||||
|
||||
State 5:
|
||||
and ::= expr * AND expr
|
||||
expr ::= LCB expr * RCB
|
||||
|
||||
AND shift 2
|
||||
RCB shift-reduce 10 expr ::= LCB expr RCB
|
||||
|
||||
State 6:
|
||||
(0) main ::= expr *
|
||||
and ::= expr * AND expr
|
||||
|
||||
$ reduce 0 main ::= expr
|
||||
AND shift 2
|
||||
|
||||
State 7:
|
||||
address_literal ::= ADDRESS LSB address_literal_content_or_empty * RSB
|
||||
|
||||
RSB shift-reduce 15 address_literal ::= ADDRESS LSB address_literal_content_or_empty RSB
|
||||
|
||||
State 8:
|
||||
address_literal_content ::= address_literal_content COMMA * STRING_LITERAL
|
||||
|
||||
STRING_LITERAL shift-reduce 12 address_literal_content ::= address_literal_content COMMA STRING_LITERAL
|
||||
|
||||
State 9:
|
||||
address_literal_content ::= address_literal_content * COMMA STRING_LITERAL
|
||||
(13) address_literal_content_or_empty ::= address_literal_content *
|
||||
|
||||
COMMA shift 8
|
||||
{default} reduce 13 address_literal_content_or_empty ::= address_literal_content
|
||||
|
||||
State 10:
|
||||
address_literal ::= ADDRESS * LSB address_literal_content_or_empty RSB
|
||||
|
||||
LSB shift 4
|
||||
|
||||
State 11:
|
||||
eq ::= id * EQ literal
|
||||
|
||||
EQ shift 3
|
||||
|
||||
----------------------------------------------------
|
||||
Symbols:
|
||||
0: $:
|
||||
1: OR
|
||||
2: AND
|
||||
3: NOT
|
||||
4: INTEGER_LITERAL
|
||||
5: STRING_LITERAL
|
||||
6: ID
|
||||
7: EQ
|
||||
8: LCB
|
||||
9: RCB
|
||||
10: COMMA
|
||||
11: ADDRESS
|
||||
12: LSB
|
||||
13: RSB
|
||||
14: error:
|
||||
15: main: STRING_LITERAL ID LCB
|
||||
16: expr: STRING_LITERAL ID LCB
|
||||
17: integer: INTEGER_LITERAL
|
||||
18: literal: INTEGER_LITERAL ADDRESS
|
||||
19: string: STRING_LITERAL
|
||||
20: id: STRING_LITERAL ID
|
||||
21: eq: STRING_LITERAL ID
|
||||
22: and: STRING_LITERAL ID LCB
|
||||
23: address_literal_content: STRING_LITERAL
|
||||
24: address_literal_content_or_empty: <lambda> STRING_LITERAL
|
||||
25: address_literal: ADDRESS
|
152
parsers/filters/parser.y
Normal file
152
parsers/filters/parser.y
Normal file
|
@ -0,0 +1,152 @@
|
|||
%name Parser
|
||||
|
||||
%token_prefix TOKEN_
|
||||
|
||||
%left OR.
|
||||
%left AND.
|
||||
%right NOT.
|
||||
|
||||
%include {
|
||||
// include something
|
||||
}
|
||||
|
||||
%code {
|
||||
&&REPLACER{process.js}&&
|
||||
}
|
||||
|
||||
%syntax_error {
|
||||
console.log("Syntax error");
|
||||
}
|
||||
|
||||
main ::= expr(A) . {
|
||||
_result.root_node = A
|
||||
}
|
||||
|
||||
integer(A) ::= INTEGER_LITERAL(B) . {
|
||||
A = new Node({
|
||||
type: "INTEGER_LITERAL",
|
||||
lexeme: B.lexeme,
|
||||
start: B.start,
|
||||
end: B.end
|
||||
})
|
||||
}
|
||||
|
||||
literal(A) ::= integer(B) . {
|
||||
A = new Node({
|
||||
type: "literal",
|
||||
children: [B]
|
||||
})
|
||||
}
|
||||
|
||||
string(A) ::= STRING_LITERAL(B) . {
|
||||
A = new Node({
|
||||
type: "STRING_LITERAL",
|
||||
lexeme: B.lexeme,
|
||||
start: B.start,
|
||||
end: B.end
|
||||
})
|
||||
}
|
||||
|
||||
id(A) ::= string(B) . {
|
||||
A = new Node({
|
||||
type: "id",
|
||||
children: [B]
|
||||
});
|
||||
}
|
||||
|
||||
id(A) ::= ID(B) . {
|
||||
A = new Node({
|
||||
type: "ID",
|
||||
lexeme: B.lexeme,
|
||||
start: B.start,
|
||||
end: B.end
|
||||
})
|
||||
}
|
||||
|
||||
eq(A) ::= id(B) EQ(C) literal(D) . {
|
||||
A = new Node({
|
||||
type: "eq",
|
||||
children: [
|
||||
B,
|
||||
new Node({
|
||||
type: "EQ",
|
||||
lexeme: C.lexeme,
|
||||
start: C.start,
|
||||
end: C.end
|
||||
}),
|
||||
D
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
and(A) ::= expr(B) AND expr(D) . {
|
||||
A = new Node({
|
||||
type: "and",
|
||||
children: [
|
||||
B,
|
||||
D
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
expr(A) ::= eq(B) . {
|
||||
A = new Node({
|
||||
type: "expr",
|
||||
children: [B]
|
||||
})
|
||||
}
|
||||
|
||||
expr(A) ::= and(B) . {
|
||||
A = B;
|
||||
}
|
||||
|
||||
expr(A) ::= LCB expr(C) RCB . {
|
||||
A = C;
|
||||
}
|
||||
|
||||
address_literal_content(A) ::= STRING_LITERAL(B) . {
|
||||
A = new Node({
|
||||
children: [
|
||||
new Node({
|
||||
type: "STRING_LITERAL",
|
||||
lexeme: B.lexeme,
|
||||
start: B.start,
|
||||
end: B.end
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
address_literal_content(A) ::= address_literal_content(B) COMMA STRING_LITERAL(C) . {
|
||||
B.add(new Node({
|
||||
type: "STRING_LITERAL",
|
||||
lexeme: C.lexeme,
|
||||
start: C.start,
|
||||
end: C.end
|
||||
}));
|
||||
A = B;
|
||||
}
|
||||
|
||||
address_literal_content_or_empty(A) ::= address_literal_content(B) . {
|
||||
A = B;
|
||||
}
|
||||
|
||||
address_literal_content_or_empty(A) ::= . {
|
||||
A = new Node({
|
||||
type: "address_literal_content"
|
||||
});
|
||||
}
|
||||
|
||||
address_literal(A) ::= ADDRESS LSB address_literal_content_or_empty(C) RSB . {
|
||||
A = new Node({
|
||||
type: "address_literal",
|
||||
children: C.children
|
||||
});
|
||||
}
|
||||
|
||||
literal(A) ::= address_literal(B) . {
|
||||
A = new Node({
|
||||
type: "literal",
|
||||
children: [B]
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue