Example #1
0
        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());
 }
Example #3
0
 private static antlr.IToken NextToken(antlr.TokenStream tokens)
 {
     while (true)
     {
         try { return(tokens.nextToken()); }
         // ReSharper disable EmptyGeneralCatchClause
         catch { }
     }
     // ReSharper restore EmptyGeneralCatchClause
 }
Example #4
0
        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
        }
Example #5
0
 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();
 }
Example #6
0
        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();
 }
Example #8
0
		public BooParserBase(TokenStream lexer) : this(lexer,2)
		{
		}
 public InterfaceParser(TokenStream lexer)
     : this(lexer,3)
 {
 }
Example #10
0
 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();
 }
Example #13
0
 public CalcParser(TokenStream lexer) : this(lexer, 1)
 {
 }
Example #14
0
 public BooScanner()
 {
     _currentLine = " ";
     lexer = null;
 }
Example #15
0
 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();
 }
Example #17
0
 public DepParser(TokenStream lexer)
     : this(lexer,3)
 {
 }
Example #18
0
 protected DepParser(TokenStream lexer, int k)
     : base(lexer,k)
 {
     initialize();
 }
        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 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)
 {
 }
Example #25
0
 public virtual void SetUp()
 {
     lexer = GetLexer(rawCodeString);
     tokens = new List<TokenInfo>();
     scanner = new Boo.BooLangService.BooScanner();
 }
Example #26
0
		public CalcParser(TokenStream lexer) : this(lexer,1)
		{
		}
Example #27
0
		public SQLParser(TokenStream lexer) : this(lexer,2)
		{
		}
 protected ExpressionParser(TokenStream lexer, int k)
     : base(lexer, k)
 {
     initialize();
 }
Example #29
0
 public AS3Parser(TokenStream lexer)
     : this(lexer,2)
 {
 }
Example #30
0
		protected BooParserBase(TokenStream lexer, int k) : base(lexer,k)
		{
			initialize();
		}
Example #31
0
 public NetParser(TokenStream lexer)
     : this(lexer,3)
 {
 }
Example #32
0
 public BooParser(antlr.TokenStream lexer) : base(lexer)
 {
 }
 public P(TokenStream lexer)
     : this(lexer,1)
 {
 }