public override string VisitEnumDefinition(GrammarParser.EnumDefinitionContext context) { var name = VisitTerminal(context.type().ID()); var @enum = new Enumeration(name); foreach (var member in context.enumMemberList().enumMember()) { var valueContext = member.enumMemberValue(); var memberValue = int.Parse(VisitTerminal(valueContext.INTEGER())); var memberName = VisitTerminal(member.name().ID()); @enum.Values.Add(new EnumerationValue(memberName, memberValue)); } File.Enums.Add(@enum); return(context.ToString()); }
public override SyntaxNode VisitEnumDefinition([NotNull] GrammarParser.EnumDefinitionContext context) { if (context == null) { return(null); } var name = SyntaxFactory.IdentifierName(context.name().GetText()); var enumDec = SyntaxFactory.EnumDeclaration(name.GetFirstToken()) .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword)) .AddMembers(context.enumDeclaration() .Select(VisitEnumDeclaration) .Select(i => i as EnumMemberDeclarationSyntax) .Where(i => i != null) .ToArray()); return(enumDec); }
/// <summary> /// Exit a parse tree produced by <see cref="GrammarParser.enumDefinition"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitEnumDefinition([NotNull] GrammarParser.EnumDefinitionContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="GrammarParser.enumDefinition"/>. /// <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 VisitEnumDefinition([NotNull] GrammarParser.EnumDefinitionContext context) { return(VisitChildren(context)); }