Пример #1
0
        public FunCall(Identitifer name, Token tok, Type type) : base(tok, type)
        {
            funcName = name ?? Identitifer.Match();
            if (Parser.current.tag_value == '^')
            {
                Parser.Match('^');
                isSystemFunction = true;
            }
            Parser.Match('[');
            returnType = Identitifer.Match();
            if (Parser.current.tag_value == '|')
            {
                Parser.Match('|');
                arguments.Add(Identitifer.Match());
                while (Parser.current.tag_value == ',')
                {
                    Parser.Match(',');
                    arguments.Add(Identitifer.Match());
                }
            }
            Parser.Match(']');
            Parser.Match('(');
            if (Parser.current.tag_value == Tag.ID)
            {
                value.Add(BoolTree.Match());
                while (Parser.current.tag_value == ',')
                {
                    Parser.Match(',');
                    value.Add(BoolTree.Match());
                }
            }

            Parser.Match(')');
        }
Пример #2
0
        public static LogicNode Match()
        {
            LogicNode factor;

            switch (Parser.current.tag_value)
            {
            case Tag.INT:
                factor = new Factor(Parser.current, Type.Int);
                break;

            case Tag.FLOAT:
                factor = new Factor(Parser.current, Type.Float);
                break;

            case Tag.TRUE:
                factor = True;
                break;

            case Tag.FALSE:
                factor = False;
                break;

            case Tag.STRING:
                factor = new Factor(Parser.current, Type.String);
                break;

            case '(':
                Parser.Move();
                factor = BoolTree.Match();
                Parser.Match(')');
                return(factor);

            case '#':
                return(new RightShift(Parser.current, Type.Void));

            case Tag.ID:
                var tok  = Parser.current;
                var name = Identitifer.Match();
                if (name.ILValue == "HEX")
                {
                    return(new Hex(tok, Type.Void));
                }

                else if (Parser.current.tag_value == '[' || Parser.current.tag_value == '^')
                {
                    return(new FunCall(name, tok, Type.Void));
                }
                else
                {
                    return(new variable(name, tok, Type.Void));
                }

            //return null;
//                    var tok = Parser.current;
//                    var identitifer = Type.Match();
//                    var variable = Top.Get(Parser.current);
//                    if (variable == null)
//                        Error(Parser.current + " UnknownVariable");
//                    Parser.Move();
//                    return new Factor(tok, identitifer.Check());
            default:
                Error("GrammarError" + " " + Parser.current);
                return(null);
            }

            Parser.Move();
            return(factor);
        }