Skip to content

Commit

Permalink
#264-Front-End Parser - implement modifications on statement with
Browse files Browse the repository at this point in the history
Completed...
  • Loading branch information
schmouk committed Sep 27, 2019
1 parent 9efa0ac commit 26d8691
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/FrontEnd/Errors/fe_syntax_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class FESyntaxErrors:
WHILE_COND_END = 'missing ) at end of conditional expression in while clause, leads to unpaired (',
WHILE_OTHERWISE_BODY = 'missing instruction or instructions block after keyword "otherwise" in while instruction',
WITH_AS_IDENT = 'missing or badly formed identifier after keyword "as" in with clause',
WITH_AS_TYPED_IDENT = 'missing or badly formed identifier after type declaration in with-as clause',
WITH_BODY = 'missing instruction or instructions block after with clause in with instruction',
WITH_EXPR = 'missing or badly formed expression after keyword "with"',
WITH_LIST_COMMA = 'missing or badly formed with-as clause in list of with-as clauses' ## notice: we already know that this kind of error will never be detected as such
Expand Down
19 changes: 17 additions & 2 deletions src/FrontEnd/Parser/fe_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4217,16 +4217,31 @@ def _with_item(self) -> bool:
#-------------------------------------------------------------------------
def _with_item1(self) -> bool:
#=======================================================================
# <with item'> ::= 'as' <target>
# <with item'> ::= 'as' <with item">
# | EPS
#=======================================================================
if self._current.is_AS():
self._append_syntaxic_node()
self._next_token_node()
if not self._target():
if not self._with_item2():
self._append_error( FESyntaxErrors.WITH_AS_IDENT )
return True

#-------------------------------------------------------------------------
def _with_item2(self) -> bool:
#=======================================================================
# <with item"> ::= <target>
# | <type'> <target>
#=======================================================================
if self._target():
return True
elif self._type1():
if not self._target():
self._append_error( FESyntaxErrors.WITH_AS_TYPED_IDENT )
return True
else:
return False

#-------------------------------------------------------------------------
def _with_items_list(self) -> bool:
#=======================================================================
Expand Down

0 comments on commit 26d8691

Please sign in to comment.