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)); }
/// <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); } }
/// <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)); }
protected Factory(Type operation, Operator.Tag Tag) { this.Tag = Tag; this.Arg0Types = PriorityManager.Instance.GetLeftArgs(operation); this.Arg1Types = PriorityManager.Instance.GetRightArgs(operation); }
public ParseException(Operator.Tag Tag, TextRegion region) { this.EntityTypes = new Type[] { typeof(Operator) }; this.Tag = Tag; this.region = region; }
protected PostfixFactory(Type operation, Operator.Tag Tag) : base(operation, Tag) { this.ArgTypes = PriorityManager.Instance.GetLeftArgs(operation); }