//---------------------
        // Парсер бинарных выражений
        //---------------------

        private static ASTNode MemberBinOperation()
        {
            ASTNode node = null;

            switch (curTok.token)
            {
            case Tokens.Token.ID:
                string nameID = curTok.subString;
                Point  point  = new Point(curTok.y, curTok.x);
                node = new IdentificatorAST(nameID, point);
                GetNextToken();
                if (curTok.token == Tokens.Token.BRACKET_L)
                {
                    return(new IdentificatorAST(nameID, point, new BracketsAST(ParseBrackets(true)), true));
                }
                //return new BracketsAST(node, ParseBrackets(true));
                return(node);

            case Tokens.Token.STRING:
                node = new StringAST(curTok.subString);
                break;

            case Tokens.Token.CHAR:
                node = new CharAST(curTok.subString, new Point(curTok.y, curTok.x));
                break;

            case Tokens.Token.PARENTHESIS_L:
                node = ParseParenthesis();
                break;

            case Tokens.Token.BOOL:
                node = new BoolAST(curTok.subString, null, new Point(curTok.y, curTok.x));
                break;

            case Tokens.Token.INT_VALUE:
            case Tokens.Token.DOUBLE_VALUE:
            case Tokens.Token.X16_VALUE:
            case Tokens.Token.X8_VALUE:
            case Tokens.Token.X2_VALUE:
                node = new NumAST(curTok.token, curTok.subString);
                break;

            default:
                ConsoleHelper.WriteErrorAST("Impossible token in this area", curTok.y, curTok.x);
                break;
            }
            GetNextToken();
            return(node);
        }
Beispiel #2
0
        private KeyValuePairAST Parameter()
        {
            StringToken keyToken = Eat(TokenType.ID) as StringToken;
            WordAST     keyAST   = new WordAST(keyToken);

            Eat(TokenType.COLON);
            if (currentToken.Type == TokenType.STRING)
            {
                StringToken valueToken = Eat(TokenType.STRING) as StringToken;
                StringAST   valueAST   = new StringAST(valueToken);
                return(new KeyValuePairAST(keyAST, valueAST));
            }
            else
            {
                AST valueAST = ValueExpr();
                return(new KeyValuePairAST(keyAST, valueAST));
            }
        }
Beispiel #3
0
        private ConfAST ProgramConfig(bool nested = false)
        {
            if (!nested)
            {
                Eat(TokenType.CONF);
            }
            StringToken idToken = Eat(TokenType.ID) as StringToken;
            WordAST     wordAST = new WordAST(idToken);
            AST         valueAST;

            if (currentToken.Type == TokenType.FROM)
            {
                Eat(TokenType.FROM);
                if (currentToken.Type == TokenType.TRUE || currentToken.Type == TokenType.FALSE)
                {
                    BoolToken valueToken = Eat(currentToken.Type) as BoolToken;
                    valueAST = new BoolAST(valueToken);
                }
                else if (currentToken.Type == TokenType.STRING)
                {
                    StringToken valueToken = Eat(TokenType.STRING) as StringToken;
                    valueAST = new StringAST(valueToken);
                }
                else
                {
                    valueAST = ValueExpr();
                }
                Eat(TokenType.SEMIC);
            }
            else if (currentToken.Type == TokenType.DOT)
            {
                Eat(TokenType.DOT);
                valueAST = ProgramConfig(true);
            }
            else
            {
                Eat(TokenType.COLON);
                valueAST = ConfList();
                Eat(TokenType.END);
            }
            return(new ConfAST(wordAST, valueAST, nested));
        }
Beispiel #4
0
 private string Visit(StringAST stringAST)
 {
     return(stringAST.String);
 }
Beispiel #5
0
 public void VisitStringAST(StringAST node)
 {
 }
 //TODO: Implement Strings +feature +important id:0 gh:2
 public StringAST StringVisit(StringAST node)
 {
     throw new NotImplementedException();
 }