/// <summary> /// Creates a new LALR parser. /// </summary> /// <param name="tokenizer">A tokenizer.</param> /// <param name="states">The LALR states.</param> /// <param name="startState">The starting state.</param> /// <param name="symbols"></param> public LALRParser(IStringTokenizer tokenizer, StateCollection states, State startState, SymbolCollection symbols) { this.tokenizer = tokenizer; this.states = states; this.startState = startState; this.symbols = symbols; storeTokens = StoreTokensMode.NoUserObject; }
private void Reset() { stream = null; structure = null; content = null; dfaStates = null; parserStates = null; symbols = null; rules = null; }
/// <summary> /// Creates a new LALR parser. /// </summary> /// <param name="tokenizer">A tokenizer.</param> /// <param name="states">The LALR states.</param> /// <param name="startState">The starting state.</param> public LALRParser(IStringTokenizer tokenizer, StateCollection states, State startState, SymbolCollection symbols) { this.tokenizer = tokenizer; this.states = states; this.startState = startState; this.symbols = symbols; storeTokens = StoreTokensMode.NoUserObject; }
private SymbolCollection CreateSymbols(CGTContent content) { SymbolCollection symbols = new SymbolCollection(); foreach (SymbolRecord symbolRecord in content.SymbolTable) { Symbol symbol = SymbolFactory.CreateSymbol(symbolRecord); symbols.Add(symbol); } return(symbols); }
private SymbolCollection FindExpectedTokens() { SymbolCollection symbols = new SymbolCollection(); State state = stateStack.Peek(); foreach (Action action in state.Actions) { if ((action is ShiftAction) || (action is ReduceAction) || (action is AcceptAction)) { symbols.Add(action.symbol); } } return(symbols); }
private SymbolCollection FindExpectedTokens() { SymbolCollection symbols = new SymbolCollection(); State state = stateStack.Peek(); foreach(Action action in state.Actions) { if ((action is ShiftAction) || (action is ReduceAction) || (action is AcceptAction)) { symbols.Add(action.symbol); } } return symbols; }
public ParseErrorEventArgs(TerminalToken unexpectedToken, SymbolCollection expectedTokens) { this.unexpectedToken = unexpectedToken; this.expectedTokens = expectedTokens; contin = ContinueMode.Stop; nextToken = null; }
private SymbolCollection CreateSymbols(CGTContent content) { SymbolCollection symbols = new SymbolCollection(); foreach (SymbolRecord symbolRecord in content.SymbolTable) { Symbol symbol = SymbolFactory.CreateSymbol(symbolRecord); symbols.Add(symbol); } return symbols; }
private DFA.StateCollection CreateDFAStates(CGTContent content) { symbols = CreateSymbols(content); DFA.StateCollection states = new DFA.StateCollection(); foreach (DFAStateRecord stateRecord in content.DFAStateTable) { DFA.State state; if (stateRecord.AcceptState) { Symbol symbol = symbols[stateRecord.AcceptIndex]; state = new DFA.EndState(stateRecord.Index,(SymbolTerminal)symbol); //todo: type checking (exception?) } else { state = new DFA.State(stateRecord.Index); } states.Add(state); } foreach (DFAStateRecord stateRecord in content.DFAStateTable) { foreach (EdgeSubRecord edgeRecord in stateRecord.EdgeSubRecords) { DFA.State source = states[stateRecord.Index]; DFA.State target = states[edgeRecord.TargetIndex]; CharacterSetRecord charsetRec = content.CharacterSetTable[edgeRecord.CharacterSetIndex]; DFA.Transition transition = new DFA.Transition(target,charsetRec.Characters); source.Transitions.Add(transition); } } return states; }
public ParseErrorEventArgs(TerminalToken unexpectedToken, SymbolCollection expectedTokens) { this.unexpectedToken = unexpectedToken; this.expectedTokens = expectedTokens; this.contin = false; this.nextToken = null; }