Example #1
0
        public override object VisitMemberDefn(ChessVCParser.MemberDefnContext context)
        {
            string typename     = context.predefinedType().GetText();
            string variableName = context.identifier().GetText();
            Type   variableType = null;

            switch (typename)
            {
            case "Choice":
                variableType = typeof(ChoiceVariable);
                break;

            case "IntRange":
                variableType = typeof(IntRangeVariable);
                break;

            case "String":
                variableType = typeof(string);
                break;

            case "Bool":
                variableType = typeof(Boolean);
                break;

            case "PieceType":
                variableType = typeof(PieceType);
                break;
            }
            if (variableType == null)
            {
                throw new Exception("Game variable declared of unsupported type: " + typename);
            }
            partial.AddMemberVariableDeclaration(variableName, variableType);
            return(base.VisitMemberDefn(context));
        }
Example #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="ChessVCParser.memberDefn"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitMemberDefn([NotNull] ChessVCParser.MemberDefnContext context)
 {
     return(VisitChildren(context));
 }
Example #3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="ChessVCParser.memberDefn"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitMemberDefn([NotNull] ChessVCParser.MemberDefnContext context)
 {
 }