public object VisitTypeDefinition(KpLinguaParser.TypeDefinitionContext context) { var identifierContext = context.Identifier(); var ruleSetContext = context.ruleSet(); _currentTypeName = GetIdentifier(identifierContext); if (_kPsystem.TryGetType(_currentTypeName) != null) { throw new KpLinguaSemanticException(string.Format("A membrane type with name '{0}' has already been defined", _currentTypeName), identifierContext.Symbol.Line, identifierContext.Symbol.Column); } var type = new MType(_currentTypeName); _kPsystem.AddType(type); if (ruleSetContext != null) { type.ExecutionStrategy = ruleSetContext.Accept(this) as ExecutionStrategy; } return(type); }
/// <summary> /// Visit a parse tree produced by <see cref="KpLinguaParser.typeDefinition"/>. /// <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 VisitTypeDefinition([NotNull] KpLinguaParser.TypeDefinitionContext context) { return(VisitChildren(context)); }