Skip to content

Commit 3c07f4d

Browse files
author
F Saad
committed
Fixes plus small test for analyze grammar.
1 parent 9e7b533 commit 3c07f4d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/metamodels/cgpm_analyze/analyze_grammar.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
anlaysis(start) ::= phrases(ps).
2626

27-
phrases(none) ::= .
2827
phrases(one) ::= phrase(p).
2928
phrases(many) ::= phrases(ps) T_SEMI phrase(p).
3029

3130
phrase(variables) ::= K_VARIABLES column_list(cols).
3231
phrase(skip) ::= K_SKIP column_list(cols).
32+
phrase(none) ::= .
3333

3434
column_list(one) ::= column_name(col).
3535
column_list(many) ::= column_list(cols) T_COMMA column_name(col).

src/metamodels/cgpm_analyze/analyze_parse.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
}
3636

3737
PUNCTUATION = {
38-
'(': analyze_grammar.T_LROUND,
39-
')': analyze_grammar.T_RROUND,
4038
',': analyze_grammar.T_COMMA,
4139
';': analyze_grammar.T_SEMI,
4240
}
@@ -91,7 +89,6 @@ def syntax_error(self, (token, text)):
9189

9290
def p_anlaysis_start(self, ps): self.phrases = ps
9391

94-
def p_phrases_none(self): return []
9592
def p_phrases_one(self, p): return [p]
9693
def p_phrases_many(self, ps, p):
9794
if p: ps.append(p)
@@ -107,3 +104,11 @@ def p_column_name_n(self, name): return name
107104

108105
Variables = namedtuple('Variables', ['vars',])
109106
Skip = namedtuple('Skip', ['vars',])
107+
108+
if __name__ == '__main__':
109+
# VARIABLES a, b,c, d;
110+
tokens = [
111+
'SKIP', 'a', ',', 'b', ';',
112+
'VARIABLES', 'a', ',', 'b', ';',
113+
'SKIP', 'a', ';']
114+
print parse(tokens)

0 commit comments

Comments
 (0)