new Parser()
Parses a token stream.
- Source:
- Parser.js, line 12
Members
-
<inner> tokenStream
-
The token stream from the Lexer
- Source:
- Parser.js, line 15
Methods
-
getErrors() → {Array}
-
Returns errors found during parsing
- Source:
- Parser.js, line 46
Returns:
Errors- Type
- Array
-
getSymbolTable() → {Object}
-
Returns the Symbol Table build during parsing
- Source:
- Parser.js, line 54
Returns:
Symbol Table- Type
- Object
-
parse(tokens)
-
Traverses the source code input to verify and build a token stream.
Parameters:
Name Type Description tokens
Array Token Stream from Lex - Source:
- Parser.js, line 24
-
<inner> checkToken(type, displayError) → {Boolean}
-
Checks the next token against a series of types
Parameters:
Name Type Description type
String Type of token to match displayError
Boolean Should function display error on fail? Defaults to true - Source:
- Parser.js, line 374
Returns:
true if token type is matched false otherwise- Type
- Boolean
-
<inner> consume() → {Boolean}
-
Consumes a token in the tokenStream
- Source:
- Parser.js, line 433
Returns:
False if the tokenStream is empty otherwise true.- Type
- Boolean
-
<inner> expectedError(expected)
-
Logs an error of the format "Expected x, found y"
Parameters:
Name Type Description expected
String The expected token type - Source:
- Parser.js, line 477
-
<inner> lookAhead(number) → {Token}
-
Returns the token the number of steps ahead requested
Parameters:
Name Type Description number
Integer The number of steps to look ahead - Source:
- Parser.js, line 516
Returns:
The token asked for- Type
- Token
-
<inner> multiCheckToken(types) → {Boolean}
-
Checks the next token against a series of types
Parameters:
Name Type Description types
Array Array of types to match - Source:
- Parser.js, line 412
Returns:
true if token matches any of the types false otherwise- Type
- Boolean
-
<inner> nextLine()
-
Fast forwards to the next line
- Source:
- Parser.js, line 501
-
<inner> parseCharacter()
-
Checks for the Character production | a || b || c ... z
- Source:
- Parser.js, line 334
-
<inner> parseCharExpr()
-
Checks for the CharExpr production | "CharList"
- Source:
- Parser.js, line 238
-
<inner> parseCharList()
-
Checks for the CharList production | Char CharList || Epsilon
- Source:
- Parser.js, line 260
-
<inner> parseDigit()
-
Checks for the Digit production | 1 || 2 || 3 ... 9 || 0
- Source:
- Parser.js, line 345
-
<inner> parseExpr()
-
Checks for the Expr production
- Source:
- Parser.js, line 179
-
<inner> parseId()
-
Checks for the Id production | Char
- Source:
- Parser.js, line 327
-
<inner> parseIntExpr()
-
Checks for the IntExpr production | digit op Expr || digit
- Source:
- Parser.js, line 206
-
<inner> parseOp()
-
Checks for the Op production | + || -
- Source:
- Parser.js, line 356
-
<inner> parseProgram()
-
Checks for the Program production | Statement $
- Source:
- Parser.js, line 64
-
<inner> parseQuote()
-
Checks for the Quote sub-production | "
- Source:
- Parser.js, line 249
-
<inner> parseStatement()
-
Checks for the Statement production
- Source:
- Parser.js, line 83
-
<inner> parseStatementList()
-
Checks for the StatementList production | Statement StatementList || Epsilon
- Source:
- Parser.js, line 153
-
<inner> parseType()
-
Checks for the Type production | int || char
- Source:
- Parser.js, line 316
-
<inner> parseVarDecl()
-
Checks for the VarDecl production | Type Id
- Source:
- Parser.js, line 282
-
<inner> subIntExpr()
-
Checks for the sub-production op Expr
- Source:
- Parser.js, line 227
-
<inner> subStatement1()
-
Checks for the Statement production P(Expr)
- Source:
- Parser.js, line 113
-
<inner> subStatement2()
-
Checks for the Statement production Id = Expr
- Source:
- Parser.js, line 124
-
<inner> subStatement3()
-
Checks for the Statement production VarDecl
- Source:
- Parser.js, line 135
-
<inner> subStatement4()
-
Checks for the Statement production {StatementList}
- Source:
- Parser.js, line 142
-
<inner> tokenLine() → {Integer}
-
Get the line number of the current token
- Source:
- Parser.js, line 463
Returns:
line number- Type
- Integer
-
<inner> tokenType() → {String}
-
Get the type of the current token
- Source:
- Parser.js, line 449
Returns:
token constant- Type
- String