Update of /cvsroot/cpptool/rfta/src/pyrfta/test/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv16704/src/pyrfta/test/rfta
Modified Files:
parser.py
Log Message:
* added action to remove symbol
Index: parser.py
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/pyrfta/test/rfta/parser.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** parser.py 1 Aug 2003 08:25:05 -0000 1.3
--- parser.py 1 Aug 2003 18:53:44 -0000 1.4
***************
*** 512,516 ****
return self.matched( scanner, result.getValue() )
scanner.popState()
! return self.matched( scanner, None )
def __str__( self ):
--- 512,516 ----
return self.matched( scanner, result.getValue() )
scanner.popState()
! return self.matched( scanner, Node('missing') )
def __str__( self ):
***************
*** 622,625 ****
--- 622,636 ----
return self.subparser.parse( local_scanner )
+ class RemoveSymbolAction(Action):
+ def __call__( self, node ):
+ children = node.getChildren()
+ new_children = []
+ for child_node in children:
+ if child_node.isLeaf() and child_node.getToken().getType() == SYMBOL:
+ continue
+ new_children.append( child_node )
+ new_node = Node(node.getType(), new_children)
+ return self.matched( new_node )
+
def inline_child_at_a( node_index ):
return InlineChildAction( node_index )
***************
*** 648,651 ****
--- 659,665 ----
return SubParseAction( make_p( parser ) )
+ def remove_symbol_a():
+ return RemoveSymbolAction()
+
end_p = TerminalParser( END_STREAM )
***************
*** 678,683 ****
eos_p = symbol_p( ';' )
!
! nested_id_p = (maybe_p( "::" ) >> list_p( id_p, symbol_p('::') ))[inline_child_at_a(1)]['nested_id']
# use separate parser for inheritance => allow other alternative matching
--- 692,697 ----
eos_p = symbol_p( ';' )
! nested_id_p = (maybe_p( "::" ) >> \
! list_p( id_p, symbol_p('::') )[remove_symbol_a()])[inline_child_at_a(1)]['nested_id']
# use separate parser for inheritance => allow other alternative matching
|