-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edits #78
base: master
Are you sure you want to change the base?
Edits #78
Changes from 3 commits
13c4d39
1da2915
6343157
84bee76
660cfb9
4172edb
fa7ed97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,14 +377,38 @@ def p_elif_clause(p): | |
def p_case_clause(p): | ||
'''case_clause : pattern_list | ||
| case_clause_sequence pattern_list''' | ||
handleNotImplemented(p, 'case clause') | ||
|
||
if len(p) == 2: | ||
p[0]=p[1] | ||
else: | ||
p[0] = p[2] | ||
p[0].append(p[1]) | ||
|
||
def p_pattern_list(p): | ||
'''pattern_list : newline_list pattern RIGHT_PAREN compound_list | ||
| newline_list pattern RIGHT_PAREN newline_list | ||
| newline_list LEFT_PAREN pattern RIGHT_PAREN compound_list | ||
| newline_list LEFT_PAREN pattern RIGHT_PAREN newline_list''' | ||
handleNotImplemented(p, 'pattern list') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
parserobj = p.context | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems unused There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken care of |
||
parts = [] | ||
action = None | ||
if p.slice[2].type == "pattern": | ||
patterns = p[2] | ||
parts.extend(patterns) | ||
rparen = ast.node(kind='reservedword', word=p[3], pos = p.lexspan(3)) | ||
parts.append(rparen) | ||
else: | ||
lparen = ast.node(kind='reservedword', word=p[2], pos=p.lexspan(2)) | ||
patterns = p[3] | ||
rparen = ast.node(kind='reservedword', word=p[4], pos=p.lexspan(4)) | ||
parts.extend([lparen, patterns, rparen]) | ||
if p.slice[-1].type == "compound_list": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a comment that explains this part |
||
# for some reason, p[-1] does not give the "true" last element, do not know why | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
action = p[len(p)-1] | ||
parts.append(action) | ||
p[0] = ast.node(kind="pattern_list", | ||
parts=parts, pos = _partsspan(parts)) | ||
|
||
def p_case_clause_sequence(p): | ||
'''case_clause_sequence : pattern_list SEMI_SEMI | ||
|
@@ -393,12 +417,22 @@ def p_case_clause_sequence(p): | |
| case_clause_sequence pattern_list SEMI_AND | ||
| pattern_list SEMI_SEMI_AND | ||
| case_clause_sequence pattern_list SEMI_SEMI_AND''' | ||
handleNotImplemented(p, 'case clause') | ||
if len(p) == 3: | ||
p[0]=p[1] | ||
else: | ||
p[0] = p[2] | ||
p[0].parts.append(p[1]) | ||
|
||
def p_pattern(p): | ||
'''pattern : WORD | ||
| pattern BAR WORD''' | ||
handleNotImplemented(p, 'pattern') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newline |
||
parserobj = p.context | ||
if len(p) == 2: | ||
p[0] = [_expandword(parserobj, p.slice[1])] | ||
else: | ||
p[0] = p[1] | ||
p[0].append(_expandword(parserobj, p.slice[3])) | ||
|
||
def p_list(p): | ||
'''list : newline_list list0''' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary new line here