Пример #1
0
 public void setLexer(List<LexerCharacterSet> thecharacterDefinitions, List<LexerKeyword> thekeywordDefinitions,
     List<LexerToken> thetokenDefinitions, LexerCharacterSet thewhitespaceDefinitions)
 {
     characterDefinitions = thecharacterDefinitions;
     keywordDefinitions = thekeywordDefinitions;
     tokenDefinitions = thetokenDefinitions;
     whitespaceDefinitions = thewhitespaceDefinitions;
 }
Пример #2
0
 bool WhiteSpaceDecl()
 {
     HashSet<char> whiteSet = new HashSet<char>();
     bool result = term(TokenType.IGNORE, true) && Set(out whiteSet); ;
     whitespaceDefinitions = new LexerCharacterSet("whitespace", LexerGenerationHelper.getSetRegExp(whiteSet), whiteSet);
     return result;
 }
Пример #3
0
        bool SetDecl(out LexerCharacterSet tmpToken)
        {
            bool result = true;
            string tempId;
            HashSet<char> tmp = new HashSet<char>();
            if (term(TokenType.Ident, false))
            {
                tempId = tokenEnumerator.Current.getValue();
                result = result && term(TokenType.Ident, true);
            }
            else tempId = "";
            result = result && term(TokenType.EQUALS, true);

            result = result && Set(out tmp);
            result = result && term(TokenType.DOT, true);

            tmpToken = new LexerCharacterSet(tempId, LexerGenerationHelper.getSetRegExp(tmp), tmp);

            return result;
        }
Пример #4
0
        bool ScannerSpecification()
        {
            bool result = true;
            if (term(TokenType.CHARACTERS, false))
            {
                result = result && term(TokenType.CHARACTERS, true);
                while (term(TokenType.Ident, false))
                {
                    LexerCharacterSet tmpSet = new LexerCharacterSet();
                    result = result && SetDecl(out tmpSet);
                    characterDefinitions.Add(tmpSet);
                }
                form.appendText("parsed CHARACTERSE\n");
            }

            if (term(TokenType.KEYWORDS, false))
            {
                result = result && term(TokenType.KEYWORDS, true);
                while (term(TokenType.Ident, false))
                {
                    result = result && KeywordDecl();
                }
                form.appendText("parsed KEYWORDS\n");
            }

            if (term(TokenType.TOKENS, false))
            {
                result = result && term(TokenType.TOKENS, true);
                while (term(TokenType.Ident, false))
                {
                    LexerToken tmpToken = new LexerToken();
                    result = result && TokenDecl(out tmpToken);
                    tokenDefinitions.Add(tmpToken);
                }

                form.appendText("parsed TOKENS\n");
            }

            while (term(TokenType.IGNORE, false))
            {
                result = result && WhiteSpaceDecl();
            }
            if (result)
            {
                form.appendText("Parsed scannerspec \n");
            }

            return result;
        }