public ILexeme Create(ILexerRule lexerRule) { if (lexerRule.LexerRuleType != LexerRuleType) throw new Exception( string.Format( "Unable to create TerminalLexeme from type {0}. Expected TerminalLexerRule", lexerRule.GetType().FullName)); var terminalLexerRule = lexerRule as ITerminalLexerRule; return new TerminalLexeme(terminalLexerRule); }
public ILexeme Create(ILexerRule lexerRule) { if (lexerRule.LexerRuleType != LexerRuleType) throw new Exception( string.Format( "Unable to create DfaLexeme from type {0}. Expected DfaLexerRule", lexerRule.GetType().FullName)); var dfaLexerRule = lexerRule as IDfaLexerRule; return new DfaLexeme(dfaLexerRule.Start, dfaLexerRule.TokenType); }
public ILexeme Create(ILexerRule lexerRule) { if (lexerRule.LexerRuleType != LexerRuleType) throw new Exception( string.Format( "Unable to create ParseEngineLexeme from type {0}. Expected TerminalLexerRule", lexerRule.GetType().FullName)); var grammarLexerRule = lexerRule as IGrammarLexerRule; var parseEngine = new ParseEngine(grammarLexerRule.Grammar); return new ParseEngineLexeme(parseEngine, grammarLexerRule.TokenType); }
public ILexeme Create(ILexerRule lexerRule) { if (lexerRule.LexerRuleType != LexerRuleType) throw new Exception( $"Unable to create TerminalLexeme from type {lexerRule.GetType().FullName}. Expected TerminalLexerRule"); var terminalLexerRule = lexerRule as ITerminalLexerRule; if (_queue.Count == 0) return new TerminalLexeme(terminalLexerRule); var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(terminalLexerRule); return reusedLexeme; }
public ILexeme Create(ILexerRule lexerRule) { if (lexerRule.LexerRuleType != LexerRuleType) throw new Exception( $"Unable to create DfaLexeme from type {lexerRule.GetType().FullName}. Expected DfaLexerRule"); var dfaLexerRule = lexerRule as IDfaLexerRule; if (_queue.Count > 0) { var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(dfaLexerRule); return reusedLexeme; } return new DfaLexeme(dfaLexerRule); }
public ILexeme Create(ILexerRule lexerRule, int position) { if (lexerRule.LexerRuleType != LexerRuleType) { throw new Exception( $"Unable to create DfaLexeme from type {lexerRule.GetType().FullName}. Expected DfaLexerRule"); } var dfaLexerRule = lexerRule as IDfaLexerRule; if (_queue.Count > 0) { var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(dfaLexerRule); return(reusedLexeme); } return(new DfaLexeme(dfaLexerRule, position)); }
public ILexeme Create(ILexerRule lexerRule, ICapture <char> segment, int offset) { if (lexerRule.LexerRuleType != LexerRuleType) { throw new Exception( $"Unable to create StringLiteralLexeme from type {lexerRule.GetType().FullName}. Expected StringLiteralLexerRule"); } var stringLiteralLexerRule = lexerRule as IStringLiteralLexerRule; if (_queue.Count == 0) { return(new StringLiteralLexeme(stringLiteralLexerRule, segment, offset)); } var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(stringLiteralLexerRule, offset); return(reusedLexeme); }
public ILexeme Create(ILexerRule lexerRule, ICapture <char> segment, int offset) { if (lexerRule.LexerRuleType != LexerRuleType) { throw new Exception( $"Unable to create DfaLexeme from type {lexerRule.GetType().FullName}. Expected DfaLexerRule"); } var dfaLexerRule = lexerRule as IDfaLexerRule; if (_queue.Count > 0) { var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(dfaLexerRule, offset); return(reusedLexeme); } var dfaLexeme = new DfaLexeme(dfaLexerRule, segment, offset); return(dfaLexeme); }
public ILexeme Create(ILexerRule lexerRule, int position) { if (lexerRule.LexerRuleType != LexerRuleType) { throw new Exception( $"Unable to create ParseEngineLexeme from type {lexerRule.GetType().FullName}. Expected TerminalLexerRule"); } var grammarLexerRule = lexerRule as IGrammarLexerRule; if (_queue.Count == 0) { return(new ParseEngineLexeme(grammarLexerRule)); } var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(grammarLexerRule); return(reusedLexeme); }
public ILexeme Create(ILexerRule lexerRule, ICapture <char> segment, int offset) { if (!LexerRuleType.Equals(lexerRule.LexerRuleType)) { throw new Exception( $"Unable to create TerminalLexeme from type {lexerRule.GetType().FullName}. Expected TerminalLexerRule"); } var terminalLexerRule = lexerRule as ITerminalLexerRule; if (_queue.Count == 0) { return(new TerminalLexeme(terminalLexerRule, segment, offset)); } var reusedLexeme = _queue.Dequeue(); reusedLexeme.Reset(terminalLexerRule, offset); return(reusedLexeme); }