public ScanningLexer(int tabSize, string source) { source += " "; // No idea why but without this extra space the lexer sometimes throws an exception Func <BooLexer, antlr.TokenStream> makeFilter = lexer => { lexer.WantAllWhitespace = true; return(new WhitespacePreservingTokenStreamFilter(lexer, BooParserBase.EOL, BooParserBase.END, BooParserBase.ID)); }; lexer = BooParser.CreateFilteredBooLexer(tabSize, "Line Scanner", new StringReader(source), makeFilter); var sourcePos = 0; var mappedPos = 0; var positionList = new List <int>(); foreach (var c in source) { if (c == '\t') { while (mappedPos % tabSize < tabSize - 1) { positionList.Add(sourcePos); mappedPos++; } } positionList.Add(sourcePos++); mappedPos++; } positionList.Add(sourcePos); // to map the <EOL> token positionMap = positionList.ToArray(); }
public LexingBaseFixture() : base() { lexer = GetLexer(rawCodeString); tokens = new List<TokenInfo>(); scanner = new Boo.BooLangService.BooScanner(new BooTokenLexer()); }
private static antlr.IToken NextToken(antlr.TokenStream tokens) { while (true) { try { return(tokens.nextToken()); } // ReSharper disable EmptyGeneralCatchClause catch { } } // ReSharper restore EmptyGeneralCatchClause }
public IndentTokenStreamFilter(antlr.TokenStream istream, int wsTokenType, int indentTokenType, int dedentTokenType, int eosTokenType) { if (null == istream) { throw new ArgumentNullException("istream"); } _istream = istream; _wsTokenType = wsTokenType; _indentTokenType = indentTokenType; _dedentTokenType = dedentTokenType; _eosTokenType = eosTokenType; _indentStack = new Stack(); _pendingTokens = new Queue(); _indentStack.Push(0); // current indent level is zero }
public ScanningLexer(int tabSize, string source) { source += " "; // No idea why but without this extra space the lexer sometimes throws an exception lexer = BooParser.CreateBooLexer(tabSize, "Line Scanner", new StringReader(source)); var sourcePos = 0; var mappedPos = 0; var positionList = new List<int>(); foreach (var c in source) { if (c == '\t') while (mappedPos % tabSize < tabSize - 1) { positionList.Add(sourcePos); mappedPos++; } positionList.Add(sourcePos++); mappedPos++; } positionList.Add(sourcePos); // to map the <EOL> token positionMap = positionList.ToArray(); }
public ScanningLexer(int tabSize, string source) { source += " "; // No idea why but without this extra space the lexer sometimes throws an exception lexer = BooParser.CreateBooLexer(tabSize, "Line Scanner", new StringReader(source)); var sourcePos = 0; var mappedPos = 0; var positionList = new List <int>(); foreach (var c in source) { if (c == '\t') { while (mappedPos % tabSize < tabSize - 1) { positionList.Add(sourcePos); mappedPos++; } } positionList.Add(sourcePos++); mappedPos++; } positionList.Add(sourcePos); // to map the <EOL> token positionMap = positionList.ToArray(); }
protected P(TokenStream lexer, int k) : base(lexer,k) { initialize(); }
public BooParserBase(TokenStream lexer) : this(lexer,2) { }
public InterfaceParser(TokenStream lexer) : this(lexer,3) { }
public BoolExprParser(TokenStream lexer) : this(lexer,4) { }
protected TemplateParser(TokenStream lexer, int k) : base(lexer,k) { initialize(); }
protected BoolParser(TokenStream lexer, int k) : base(lexer, k) { initialize(); }
public CalcParser(TokenStream lexer) : this(lexer, 1) { }
public BooScanner() { _currentLine = " "; lexer = null; }
public void SetSource(string source, int offset) { _currentLine = source; if (_currentLine == string.Empty) { lexer = BooParser.CreateBooLexer(1, "", new StringReader(" "), true); } else { lexer = BooParser.CreateBooLexer(1, "", new StringReader(_currentLine), true); } }
protected InterfaceParser(TokenStream lexer, int k) : base(lexer,k) { initialize(); }
public DepParser(TokenStream lexer) : this(lexer,3) { }
protected DepParser(TokenStream lexer, int k) : base(lexer,k) { initialize(); }
public BoolParser(TokenStream lexer) : this(lexer, 2) { }
public ActionParser(TokenStream lexer, StringTemplate self) : this(lexer, 2) { this.self = self; }
public TemplateParser(TokenStream lexer) : this(lexer,1) { }
public ActionParser(TokenStream lexer) : this(lexer,2) { }
public ExpressionParser(TokenStream lexer) : this(lexer, 1) { }
public virtual void SetUp() { lexer = GetLexer(rawCodeString); tokens = new List<TokenInfo>(); scanner = new Boo.BooLangService.BooScanner(); }
public CalcParser(TokenStream lexer) : this(lexer,1) { }
public SQLParser(TokenStream lexer) : this(lexer,2) { }
protected ExpressionParser(TokenStream lexer, int k) : base(lexer, k) { initialize(); }
public AS3Parser(TokenStream lexer) : this(lexer,2) { }
protected BooParserBase(TokenStream lexer, int k) : base(lexer,k) { initialize(); }
public NetParser(TokenStream lexer) : this(lexer,3) { }
public BooParser(antlr.TokenStream lexer) : base(lexer) { }
public P(TokenStream lexer) : this(lexer,1) { }