Home | History | Annotate | Download | only in antlr3

Lines Matching refs:follow

64   a stack that tracks follow sets for error recovery
382 # the symbol doesn't match, attempt to use the follow-set
383 # data provided by +follow+ to recover from the mismatched
385 def match( type, follow )
393 return recover_from_mismatched_token( type, follow )
535 # follow that rule reference on the stack; this amounts to
537 # enclosing rule. This local follow set only includes tokens
546 # can legally follow a call to r *or* any rule that called r.
561 # At each rule invocation, the set of tokens that could follow
563 # follow sets:
565 # FOLLOW( b1_in_a ) = FIRST( ']' ) = ']'
566 # FOLLOW( b2_in_a ) = FIRST( ')' ) = ')'
567 # FOLLOW( c_in_b ) = FIRST( '^' ) = '^'
573 # and, hence, the follow context stack is:
575 # depth local follow set after call to rule
584 # For error recovery, we cannot consider FOLLOW(c)
586 # all context-sensitive FOLLOW sets--the set of all tokens that
587 # could follow any reference in the call chain. We need to
588 # resync to one of those tokens. Note that FOLLOW(c)='^' and if
621 # Like Grosch I implemented local FOLLOW sets that are combined
627 def recover_from_mismatched_token( type, follow )
636 if mismatch_is_missing_token?( follow )
637 inserted = missing_symbol( nil, type, follow )
645 def recover_from_mismatched_set( e, follow )
646 if mismatch_is_missing_token?( follow )
648 return missing_symbol( e, INVALID_TOKEN_TYPE, follow )
653 def recover_from_mismatched_element( e, follow )
654 follow.nil? and return false
655 if follow.include?( EOR_TOKEN_TYPE )
657 follow = ( follow | viable_tokens ) - Set[ EOR_TOKEN_TYPE ]
659 if follow.include?( @input.peek )
684 def missing_symbol( error, expected_token_type, follow )
692 def mismatch_is_missing_token?( follow )
693 follow.nil? and return false
694 if follow.include?( EOR_TOKEN_TYPE )
696 follow = follow | viable_tokens
698 follow.delete( EOR_TOKEN_TYPE ) unless @state.following.empty?
700 if follow.include?( @input.peek ) or follow.include?( EOR_TOKEN_TYPE )
723 # Compute the context-sensitive +FOLLOW+ set for current rule.
724 # This is set of token types that can follow a specific rule
728 # definition of plain FOLLOW for rule r:
730 # FOLLOW(r)={x | S=>*alpha r beta in G and x in FIRST(beta)}
734 # FOLLOW(r) is the set of all tokens that can possibly follow
742 # stat : ID '=' expr ';' // FOLLOW(stat)=={EOF}
745 # expr : atom ('+' atom)* ; // FOLLOW(expr)=={';','.',')'}
746 # atom : INT // FOLLOW(atom)=={'+',')',';','.'}
750 # The FOLLOW sets are all inclusive whereas context-sensitive
751 # FOLLOW sets are precisely what could follow a rule reference.
765 # What can follow that specific nested ref to atom? Exactly ')'
767 # input. Contrast this with the FOLLOW(atom)={'+',')',';','.'}.
1284 def missing_symbol( error, expected_type, follow )