public class Parser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.String> |
callList
List of all the calls.
|
private boolean |
dividing
Usefull for the LLVM generator.
|
private java.lang.String |
input |
private LexicalAnalyzer |
lex |
private int |
lineNum |
private LLVMGenerator |
llvm |
private boolean |
multiplying
Usefull for the LLVM generator.
|
private boolean |
newLine
Tells whether we are on a new line or not.
|
private java.util.List<java.lang.String> |
performList
List of all the labels (ie methods).
|
private java.lang.String |
programId
name of the program.
|
private java.lang.String |
terminal |
private java.lang.String |
token |
private SymbolsTable |
tos |
private java.lang.String[] |
tosEntry
Name, Initialization, Type, Digits, Current Value
|
private VariableInteger |
varLeftAdd |
private VariableInteger |
varLeftEq |
private VariableInteger |
varLeftMult |
private VariableInteger |
varRightAdd |
private VariableInteger |
varRightEq |
private VariableInteger |
varRightMult |
Constructor and Description |
---|
Parser(LexicalAnalyzer l,
SymbolsTable tos,
LLVMGenerator llvm) |
Modifier and Type | Method and Description |
---|---|
private void |
assignation() |
private void |
assignEnd() |
private void |
call() |
private void |
callTail() |
private void |
checkCallList()
Checks if all the procedure are called.
|
private void |
checkProgramId()
Check if the program id the same at the beginning and
the end of the code.
|
private void |
data() |
private void |
endInst() |
private void |
env() |
private static java.lang.String |
escapeChar(java.lang.String input)
Escapes special characters by placing them inside
rackets.
|
private VariableInteger |
expAdd() |
private VariableInteger |
expAddLR() |
private VariableInteger |
expAnd() |
private void |
expAndLR() |
private VariableInteger |
expEqual() |
private VariableInteger |
expEqualLR() |
private VariableInteger |
expMult() |
private VariableInteger |
expMultLR() |
private VariableInteger |
expNot() |
private VariableInteger |
expression() |
private void |
expressionLR() |
private VariableInteger |
expressionParenthesis() |
private VariableInteger |
expTerm() |
private void |
ident() |
private void |
ifEnd() |
private void |
ifRule() |
private void |
instruction() |
private void |
instructionList() |
private void |
label() |
private void |
labels() |
private void |
labelsLR() |
private void |
level() |
private void |
matchNextToken(java.lang.String toMatch) |
private void |
nextToken()
Determine the next token on the input using the lexical analyzer.
|
void |
parse(java.lang.String input)
Launches the parser, then check the call list, the asks
the LLVM generator to finalize the code, then to write
it into a file.
|
private void |
proc() |
private void |
program() |
private void |
read() |
private void |
varDecl() |
private void |
varDeclTail() |
private void |
varList() |
private void |
words() |
private void |
wordsLR() |
private void |
write() |
private void |
writeTail() |
private LexicalAnalyzer lex
private LLVMGenerator llvm
private java.lang.String input
private java.lang.String token
private java.lang.String terminal
private int lineNum
private java.lang.String programId
private boolean newLine
private SymbolsTable tos
private java.lang.String[] tosEntry
private VariableInteger varLeftMult
private VariableInteger varRightMult
private VariableInteger varLeftAdd
private VariableInteger varRightAdd
private VariableInteger varLeftEq
private VariableInteger varRightEq
private java.util.List<java.lang.String> callList
private java.util.List<java.lang.String> performList
private boolean multiplying
private boolean dividing
public Parser(LexicalAnalyzer l, SymbolsTable tos, LLVMGenerator llvm)
private void nextToken()
public void parse(java.lang.String input)
input
- Whole code as one single String.private void checkCallList()
Checks if all the procedure are called.
Checks if all the procedure called exists.
The callList and performList are populated during the parsing.
private void matchNextToken(java.lang.String toMatch)
private void program()
private void ident()
private void endInst()
private void words()
private void wordsLR()
private void env()
private void data()
private void varList()
private void varDecl()
private void level()
private void varDeclTail()
private void proc()
private void labels()
private void labelsLR()
private void label()
private void instructionList()
private void instruction()
private void assignation()
private void assignEnd()
private VariableInteger expression()
private void expressionLR()
private VariableInteger expAnd()
private void expAndLR()
private VariableInteger expEqual()
private VariableInteger expEqualLR()
private VariableInteger expAdd()
private VariableInteger expAddLR()
private VariableInteger expMult()
private VariableInteger expMultLR()
private VariableInteger expNot()
private VariableInteger expressionParenthesis()
private VariableInteger expTerm()
private void ifRule()
private void ifEnd()
private void call()
private void callTail()
private void read()
private void write()
private void writeTail()
private void checkProgramId()
private static java.lang.String escapeChar(java.lang.String input)
Escapes special characters by placing them inside rackets.
This is to avoid confusion the string is used in regular expressions.
input
- String containing the characters to escape.