Example #1
0
        /// <exception cref="ArgumentNullException"><paramref name="eventHandlers" /> is <c>null</c>.</exception>
        internal LSLStateScopeNode(LSLParser.DefaultStateContext context, IEnumerable <LSLEventHandlerNode> eventHandlers)
            : this(context)

        {
            if (eventHandlers == null)
            {
                throw new ArgumentNullException("eventHandlers");
            }

            foreach (var lslEventHandlerNode in eventHandlers)
            {
                Add(lslEventHandlerNode);
            }

            StateName      = "default";
            IsDefaultState = true;

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangeOpenBrace    = new LSLSourceCodeRange(context.open_brace);
            SourceRangeCloseBrace   = new LSLSourceCodeRange(context.close_brace);
            SourceRangeStateName    = new LSLSourceCodeRange(context.state_name);
            SourceRangeStateKeyword = new LSLSourceCodeRange(context.state_name);

            SourceRangesAvailable = true;
        }
Example #2
0
        public override bool VisitDefaultState(LSLParser.DefaultStateContext context)
        {
            if (context == null || context.children == null)
            {
                throw LSLCodeValidatorInternalException.VisitContextInvalidState("VisitDefaultState", true);
            }


            _scopingManager.PreDefineState("default");


            if (!context.eventHandler().Any())
            {
                GenSyntaxError().StateHasNoEventHandlers(new LSLSourceCodeRange(context.state_name), "default");
                return(false);
            }


            var eventHandlerNames = new HashSet <string>();

            foreach (var ctx in context.eventHandler())
            {
                if (ctx.handler_name == null)
                {
                    throw LSLCodeValidatorInternalException
                          .VisitContextInInvalidState("VisitDefaultState", typeof(LSLParser.EventHandlerContext), true);
                }

                if (eventHandlerNames.Contains(ctx.handler_name.Text))
                {
                    GenSyntaxError().RedefinedEventHandler(
                        new LSLSourceCodeRange(ctx.handler_name),
                        ctx.handler_name.Text,
                        context.state_name.Text);

                    return(false);
                }
                eventHandlerNames.Add(ctx.handler_name.Text);
            }


            return(true);
        }
Example #3
0
        /// <exception cref="ArgumentNullException"><paramref name="context" /> is <c>null</c>.</exception>
        internal LSLStateScopeNode(LSLParser.DefaultStateContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            StateName      = "default";
            IsDefaultState = true;

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangeOpenBrace    = new LSLSourceCodeRange(context.open_brace);
            SourceRangeCloseBrace   = new LSLSourceCodeRange(context.close_brace);
            SourceRangeStateName    = new LSLSourceCodeRange(context.state_name);
            SourceRangeStateKeyword = new LSLSourceCodeRange(context.state_name);

            SourceRangesAvailable = true;
        }
Example #4
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="LSLParser.defaultState"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitDefaultState([NotNull] LSLParser.DefaultStateContext context)
 {
 }
Example #5
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="LSLParser.defaultState"/>.
 /// <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 VisitDefaultState([NotNull] LSLParser.DefaultStateContext context)
 {
     return(VisitChildren(context));
 }