public ObjectPropertyToken CreateToken()
        {
            var identifierToken = new IdentifierToken(null).CreateToken();

            SyntaxParser.Parse(":", LexType.DELIMETER);
            var value = new ValueToken().CreateToken();

            return(new ObjectPropertyToken(identifierToken, value));
        }
Exemplo n.º 2
0
        public DeclarationToken CreateToken()
        {
            SyntaxParser.Parse(KEYWORD, LexType.KEYWORD);
            var id = new IdentifierToken("null").CreateToken();

            SyntaxParser.Parse("=", LexType.DELIMETER);
            VarType     varType;
            ObjectToken obj = null;

            if (SyntaxParser.GetCurrentLex().Value == "new")
            {
                obj = new ObjectToken(null).CreateToken();
            }

            return(new DeclarationToken(id, obj));
        }
Exemplo n.º 3
0
        public ValueToken CreateToken()
        {
            Lex lex = SyntaxParser.GetCurrentLex();

            switch (lex.LexType)
            {
            case  LexType.NUMBER: return(new NumberToken().CreateToken());

            case LexType.STRING: return(new StringToken().CreateToken());
            }

            if (lex.Value == "{")
            {
                return(new ObjectToken().CreateToken());
            }

            return(null);
        }
Exemplo n.º 4
0
        public StatementToken CreateToken()
        {
            var currToken = SyntaxParser.GetCurrentLex();
            DeclarationToken declarationToken = null;
            MethodToken      methodToken      = null;

            if (currToken.Value == "val")
            {
                declarationToken = new DeclarationToken().CreateToken();
                SyntaxParser.Parse(";", LexType.DELIMETER);
                return(new StatementToken(declarationToken));
            }
            else if (SyntaxParser.GetCurrentLex().LexType == LexType.IDENTIFIER)
            {
                methodToken = new MethodToken().CreateToken();
                SyntaxParser.Parse(";", LexType.DELIMETER);
                return(new StatementToken(methodToken));
            }

            return(null);
        }
Exemplo n.º 5
0
        public ObjectToken CreateToken()
        {
            List <ObjectPropertyToken> objectPropertyTokens = new List <ObjectPropertyToken>();

            SyntaxParser.Parse("new", LexType.KEYWORD);
            Lex objectType = SyntaxParser.Parse(null, LexType.TYPE);

            SyntaxParser.Parse("{", LexType.DELIMETER);
            while (SyntaxParser.GetCurrentLex().Value != "}")
            {
                objectPropertyTokens.Add(new ObjectPropertyToken().CreateToken());
                if (SyntaxParser.GetCurrentLex().Value != "}")
                {
                    SyntaxParser.Parse(",", LexType.DELIMETER);
                }
            }

            SyntaxParser.Parse("}", LexType.DELIMETER);
            VarType varType = (VarType)Enum.Parse(typeof(VarType), objectType.Value);

            return(new ObjectToken(varType, objectPropertyTokens));
        }
Exemplo n.º 6
0
        public MethodToken CreateToken()
        {
            string        methodName = SyntaxParser.Parse(null, LexType.IDENTIFIER).Value;
            List <string> parameters = new List <string>();

            SyntaxParser.Parse("(", LexType.DELIMETER);
            while (true)
            {
                Lex identifier = SyntaxParser.Parse(null, LexType.IDENTIFIER);
                parameters.Add(identifier.Value);
                if (identifier.LexType == LexType.IDENTIFIER && SyntaxParser.GetCurrentLex().Value == ")")
                {
                    SyntaxParser.Parse(")", LexType.DELIMETER);
                    break;
                }
                else if (SyntaxParser.Parse(",", LexType.DELIMETER).Value == ",")
                {
                    continue;
                }
            }

            return(new MethodToken(methodName, parameters));
        }
Exemplo n.º 7
0
        public NumberToken CreateToken()
        {
            var token = SyntaxParser.Parse(null, LexType.NUMBER);

            return(new NumberToken(Int32.Parse(token.Value)));
        }
Exemplo n.º 8
0
        public IdentifierToken CreateToken()
        {
            var token = SyntaxParser.Parse(null, LexType.IDENTIFIER);

            return(new IdentifierToken(token.Value));
        }
Exemplo n.º 9
0
        public StringToken CreateToken()
        {
            Lex lex = SyntaxParser.Parse(null, LexType.STRING);

            return(new StringToken(lex.Value));
        }