示例#1
0
        protected override void OnDefineLexer(Lexicon lexicon, ICollection <Token> triviaTokens)
        {
            var lexer = lexicon.Lexer;

            PLUS              = lexer.DefineToken(RE.Symbol('+'));
            ASTERISK          = lexer.DefineToken(RE.Symbol('*'));
            LEFT_PARENTHESIS  = lexer.DefineToken(RE.Symbol('('));
            RIGHT_PARENTHESIS = lexer.DefineToken(RE.Symbol(')'));
            NUMBER            = lexer.DefineToken(RE.Range('0', '9').Many1(), "number");
            SPACE             = lexer.DefineToken(RE.Symbol(' ').Many1());

            triviaTokens.Add(SPACE);
        }
示例#2
0
        private void SetUpScanner()
        {
            var lexcion = new Lexicon();

            var lexer = lexcion.Lexer;

            PLUS              = lexer.DefineToken(RE.Symbol('+'));
            ASTERISK          = lexer.DefineToken(RE.Symbol('*'));
            LEFT_PARENTHESIS  = lexer.DefineToken(RE.Symbol('('));
            RIGHT_PARENTHESIS = lexer.DefineToken(RE.Symbol(')'));
            NUMBER            = lexer.DefineToken(RE.Range('0', '9').Many1(), "number");
            SPACE             = lexer.DefineToken(RE.Symbol(' ').Many1());

            m_scannerInfo = lexcion.CreateScannerInfo();
        }