示例#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 RightShift(Token tok, Type type) : base(tok, type)
 {
     Parser.Match('#');
     Parser.Match('>');
     Name = Identitifer.Match();
     Parser.Match('>');
     value = Parser.current.ToString();
     Parser.Match(Tag.INT);
 }
示例#3
0
        public static Call Match(Identitifer name = null)
        {
            var call = new Call {
                funcName = name ?? Identitifer.Match()
            };

            Parser.Match('[');
            call.returnType = Identitifer.Match();
            Parser.Match(']');
            Parser.Match('(');
            call.value = BoolTree.Match();
            Parser.Match(')');
            Parser.Match(';');
            return(call);
        }
示例#4
0
        public static Field Match()
        {
            var v = new Field();

            Parser.Match(Tag.VAR);
            v.name = Parser.current.ToString();
            Parser.Match(Tag.ID);
            Parser.Match(Tag.AS);
            v.type = Parser.current.ToString();
            Parser.Match(Tag.ID);
            Parser.Match('(');
            v.value = Identitifer.Match().ILValue;
            Parser.Match(')');
            if (Parser.current.tag_value == '<')
            {
                Parser.Match('<');
                if (Parser.current.tag_value == Tag.PRIVATE)
                {
                    Parser.Match(Tag.PRIVATE);
                }
                else if (Parser.current.tag_value == Tag.PUBLIC)
                {
                    Parser.Match(Tag.PUBLIC);
                    v.isPublic = true;
                }

                if (Parser.current.tag_value == '|')
                {
                    Parser.Match('|');
                    if (Parser.current.tag_value == Tag.STATIC)
                    {
                        Parser.Match(Tag.STATIC);
                        v.isStatic = true;
                    }
                }
                Parser.Match('>');
            }
            Parser.Match(';');
            return(v);
        }
示例#5
0
 public Hex(Token tok, Type type) : base(tok, type)
 {
     Parser.Match('(');
     value = Identitifer.Match().ILValue;
     Parser.Match(')');
 }
示例#6
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);
        }
示例#7
0
 public variable(Identitifer name, Token tok, Type type) : base(tok, type)
 {
     Name = name;
 }