private bool step() { if (currentToken == null) { int pos = 0; if (previousToken != null) { pos = previousToken.getPosition() + previousToken.getLexeme().Length; } currentToken = new Token(DOLLAR, "$", pos); } int x = ((int)stack.Pop()); int a = currentToken.getId(); if (x == EPSILON) { return(false); } else if (isTerminal(x)) { if (x == a) { if (stack.Count == 0) { return(true); } else { previousToken = currentToken; currentToken = scanner.nextToken(); return(false); } } else { throw new SyntaticError(PARSER_ERROR[x], currentToken.getLinha()); } } else if (isNonTerminal(x)) { if (pushProduction(x, a)) { return(false); } else { //Console.WriteLine(currentToken.getLexeme()); throw new SyntaticError(PARSER_ERROR[x], currentToken.getLinha()); } } else // isSemanticAction(x) { semanticAnalyser.executeAction(x - FIRST_SEMANTIC_ACTION, previousToken); return(false); } }
public void parse(Lexico scanner, Semantico semanticAnalyser) { this.scanner = scanner; this.semanticAnalyser = semanticAnalyser; stack.Clear(); stack.Push(DOLLAR); stack.Push(START_SYMBOL); currentToken = scanner.nextToken(); while (!step()); }
public void parse(Lexico scanner, Semantico semanticAnalyser) { this.scanner = scanner; this.semanticAnalyser = semanticAnalyser; stack.Clear(); stack.Push(DOLLAR); stack.Push(START_SYMBOL); currentToken = scanner.nextToken(); while (!step()) { ; } }