Exemple #1
0
            public override Node Make(Parser parser)
            {
                Keyword keyword = parser.AssertToken <Keyword>();

                Operator.Tag tag = keyword.tag;
                string       name;

                switch (tag)
                {
                case Operator.Tag._int:
                    name = "int";
                    break;

                case Operator.Tag._string:
                    name = "string";
                    break;

                case Operator.Tag._double:
                    name = "double";
                    break;

                case Operator.Tag._void:
                    name = "void";
                    break;

                case Operator.Tag._object:
                    name = "object";
                    break;

                default:
                    throw new ParseException(typeof(TypeNode), keyword.Region);
                }

                return(new TypeNode(name, keyword.Region));
            }
Exemple #2
0
 /// <summary>
 /// Tries the get operator.
 /// </summary>
 /// <remarks>If no token with this tag exist in this position then return null.</remarks>
 /// <param name="TokenTag">The token tag.</param>
 /// <returns>The operator</returns>
 public Operator TryGetOperator(Operator.Tag TokenTag)
 {
     try
     {
         return(AssertOperator(TokenTag));
     }
     catch (ParseException)
     {
         return(null);
     }
 }
Exemple #3
0
        /// <summary>
        /// Asserts the operator with the specific tag
        /// </summary>
        /// <param name="TokenTag">The token tag.</param>
        /// <returns>The operator</returns>
        /// <exception cref="T:jcc.ParserScope.ParseException">No token with this tag exist at this position</exception>
        public Operator AssertOperator(Operator.Tag TokenTag)
        {
            Operator token = GetToken() as Operator;

            if (token != null && token.tag == TokenTag)
            {
                return(token);
            }
            UngetToken();
            throw new ParseException(TokenTag, new TextRegion(position));
        }
Exemple #4
0
 protected Factory(Type operation, Operator.Tag Tag)
 {
     this.Tag       = Tag;
     this.Arg0Types = PriorityManager.Instance.GetLeftArgs(operation);
     this.Arg1Types = PriorityManager.Instance.GetRightArgs(operation);
 }
Exemple #5
0
 public ParseException(Operator.Tag Tag, TextRegion region)
 {
     this.EntityTypes = new Type[] { typeof(Operator) };
     this.Tag         = Tag;
     this.region      = region;
 }
Exemple #6
0
 protected PostfixFactory(Type operation, Operator.Tag Tag)
     : base(operation, Tag)
 {
     this.ArgTypes = PriorityManager.Instance.GetLeftArgs(operation);
 }