Package jminusminus
Class Parser
java.lang.Object
jminusminus.Parser
A recursive descent parser that, given a lexical analyzer (a LookaheadScanner), parses a j--
compilation unit (program file), taking tokens from the LookaheadScanner, and produces an
abstract syntax tree (AST) for it.
-
Constructor Summary
ConstructorDescriptionParser
(LookaheadScanner scanner) Constructs a parser from the given lexical analyzer. -
Method Summary
Modifier and TypeMethodDescriptionParses a compilation unit (a program file) and returns an AST for it.boolean
Returns true if a parser error has occurred up to now, and false otherwise.
-
Constructor Details
-
Parser
Constructs a parser from the given lexical analyzer.- Parameters:
scanner
- the lexical analyzer with which tokens are scanned.
-
-
Method Details
-
errorHasOccurred
public boolean errorHasOccurred()Returns true if a parser error has occurred up to now, and false otherwise.- Returns:
- true if a parser error has occurred up to now, and false otherwise.
-
compilationUnit
Parses a compilation unit (a program file) and returns an AST for it.compilationUnit ::= [ PACKAGE qualifiedIdentifier SEMI ] { IMPORT qualifiedIdentifier SEMI } { typeDeclaration } EOF
- Returns:
- an AST for a compilation unit.
-