polyglot.parse
Class BaseParser

java.lang.Object
  extended by java_cup.runtime.lr_parser
      extended by polyglot.parse.BaseParser
Direct Known Subclasses:
Grm

public abstract class BaseParser
extends java_cup.runtime.lr_parser


Field Summary
 ErrorQueue eq
           
 Lexer lexer
           
 NodeFactory nf
           
protected  Position position
           
protected  Position prev_pos
           
 TypeSystem ts
           
 
Fields inherited from class java_cup.runtime.lr_parser
_done_parsing, _error_sync_size, action_tab, cur_token, lookahead, lookahead_pos, production_tab, reduce_tab, stack, tos
 
Constructor Summary
BaseParser(Lexer l, TypeSystem t, NodeFactory n, ErrorQueue q)
           
 
Method Summary
 TypeNode array(TypeNode n, int dims)
          Return a TypeNode representing a dims-dimensional array of n.
 void die()
          Report a fatal error then abort parsing.
 void die(Position pos)
          Report a fatal error then abort parsing.
 void die(java.lang.String msg, Position pos)
          Report a fatal error then abort parsing.
protected  QualifierNode exprToQualifier(Expr e)
          Helper for exprToType.
 TypeNode exprToType(Expr e)
          Convert e into a type, yielding a TypeNode.
 java_cup.runtime.Symbol nextSymbol()
          The standard scanning routine for use in the CUP "scan with" declaration.
 Position pos(java.util.List l)
          Return the source position of the first element in the list to the last element in the list.
 Position pos(Node n)
          Return the source position of the Node.
 Position pos(java.lang.Object first, java.lang.Object last)
           
 Position pos(java.lang.Object first, java.lang.Object last, java.lang.Object noEndDefault)
           
 Position pos(Token t)
          Return the position of the Token.
 Position pos(Type n)
          Return the source position of the Type.
 Position pos(VarDeclarator n)
          Return the source position of the declaration.
protected  Position posForObject(java.lang.Object o)
           
 Position position()
           
protected  QualifierNode prefixToQualifier(Prefix p)
          Helper for exprToType.
 void report_fatal_error(java.lang.String message, java.lang.Object info)
          Override the default CUP routine.
protected  QualifierNode typeToQualifier(TypeNode t)
          Helper for exprToType.
 
Methods inherited from class java_cup.runtime.lr_parser
action_table, advance_lookahead, cur_err_token, debug_message, debug_parse, debug_reduce, debug_shift, debug_stack, do_action, done_parsing, dump_stack, EOF_sym, error_recovery, error_sym, error_sync_size, find_recovery_config, get_action, get_reduce, getScanner, init_actions, parse_lookahead, parse, production_table, read_lookahead, reduce_table, report_error, restart_lookahead, scan, setScanner, shift_under_error, start_production, start_state, syntax_error, try_parse_ahead, unpackFromStrings, unrecovered_syntax_error, user_init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lexer

public final Lexer lexer

eq

public final ErrorQueue eq

ts

public final TypeSystem ts

nf

public final NodeFactory nf

prev_pos

protected Position prev_pos

position

protected Position position
Constructor Detail

BaseParser

public BaseParser(Lexer l,
                  TypeSystem t,
                  NodeFactory n,
                  ErrorQueue q)
Method Detail

nextSymbol

public java_cup.runtime.Symbol nextSymbol()
                                   throws java.io.IOException
The standard scanning routine for use in the CUP "scan with" declaration. Should read: scan with {: return nextSymbol(); :}

Throws:
java.io.IOException

position

public Position position()

report_fatal_error

public void report_fatal_error(java.lang.String message,
                               java.lang.Object info)
                        throws java.lang.Exception
Override the default CUP routine.

Overrides:
report_fatal_error in class java_cup.runtime.lr_parser
Parameters:
message - an error message.
info - an extra object reserved for use by specialized subclasses.
Throws:
java.lang.Exception

die

public void die(java.lang.String msg,
                Position pos)
         throws java.lang.Exception
Report a fatal error then abort parsing.

Throws:
java.lang.Exception

die

public void die(Position pos)
         throws java.lang.Exception
Report a fatal error then abort parsing.

Throws:
java.lang.Exception

die

public void die()
         throws java.lang.Exception
Report a fatal error then abort parsing.

Throws:
java.lang.Exception

posForObject

protected Position posForObject(java.lang.Object o)

pos

public Position pos(java.lang.Object first,
                    java.lang.Object last)

pos

public Position pos(java.lang.Object first,
                    java.lang.Object last,
                    java.lang.Object noEndDefault)

pos

public Position pos(Token t)
Return the position of the Token.


pos

public Position pos(Type n)
Return the source position of the Type.


pos

public Position pos(java.util.List l)
Return the source position of the first element in the list to the last element in the list.


pos

public Position pos(VarDeclarator n)
Return the source position of the declaration.


pos

public Position pos(Node n)
Return the source position of the Node.


array

public TypeNode array(TypeNode n,
                      int dims)
               throws java.lang.Exception
Return a TypeNode representing a dims-dimensional array of n.

Throws:
java.lang.Exception

prefixToQualifier

protected QualifierNode prefixToQualifier(Prefix p)
                                   throws java.lang.Exception
Helper for exprToType.

Throws:
java.lang.Exception

typeToQualifier

protected QualifierNode typeToQualifier(TypeNode t)
                                 throws java.lang.Exception
Helper for exprToType.

Throws:
java.lang.Exception

exprToQualifier

protected QualifierNode exprToQualifier(Expr e)
                                 throws java.lang.Exception
Helper for exprToType.

Throws:
java.lang.Exception

exprToType

public TypeNode exprToType(Expr e)
                    throws java.lang.Exception
Convert e into a type, yielding a TypeNode. This is used by the cast_expression production.

Throws:
java.lang.Exception