Пример #1
0
        // have entered the body
        // the header should have finished being parsed and currentNode ready
        // all we do is set up a body visitor and tell it to run through all the statements
        // it handles everything from that point onwards
        public override void EnterBody(YarnSpinnerParser.BodyContext context)
        {
            // if it is a regular node
            if (!rawTextNode)
            {
                BodyVisitor visitor = new BodyVisitor(this);

                foreach (var statement in context.statement())
                {
                    visitor.Visit(statement);
                }
            }
            // we are a rawText node
            // turn the body into text
            // save that into the node
            // perform no compilation
            // TODO: oh glob! there has to be a better way
            else
            {
                // moving in by 4 from the end to cut off the ---/=== delimiters
                // and their associated /n's
                int    start = context.Start.StartIndex + 4;
                int    end   = context.Stop.StopIndex - 4;
                string body  = context.Start.InputStream.GetText(new Interval(start, end));

                currentNode.sourceTextStringID = program.RegisterString(body, currentNode.name, "line:" + currentNode.name, context.Start.Line, true);
            }
        }
Пример #2
0
        // have entered the body
        // the header should have finished being parsed and currentNode ready
        // all we do is set up a body visitor and tell it to run through all the statements
        // it handles everything from that point onwards
        public override void EnterBody(YarnSpinnerParser.BodyContext context)
        {
            // if it is a regular node
            if (!RawTextNode)
            {
                // This is the start of a node that we can jump to. Add a label at this point.
                CurrentNode.Labels.Add(RegisterLabel(), CurrentNode.Instructions.Count);

                BodyVisitor visitor = new BodyVisitor(this);

                foreach (var statement in context.statement())
                {
                    visitor.Visit(statement);
                }
            }
            // we are a rawText node
            // turn the body into text
            // save that into the node
            // perform no compilation
            // TODO: oh glob! there has to be a better way
            else
            {
                CurrentNode.SourceTextStringID = RegisterString(context.GetText(), CurrentNode.Name, "line:" + CurrentNode.Name, context.Start.Line, null);
            }
        }
Пример #3
0
        // have entered the body the header should have finished being
        // parsed and currentNode ready all we do is set up a body visitor
        // and tell it to run through all the statements it handles
        // everything from that point onwards
        public override void EnterBody(YarnSpinnerParser.BodyContext context)
        {
            // if it is a regular node
            if (!RawTextNode)
            {
                // This is the start of a node that we can jump to. Add a
                // label at this point.
                CurrentNode.Labels.Add(RegisterLabel(), CurrentNode.Instructions.Count);

                CodeGenerationVisitor visitor = new CodeGenerationVisitor(this);

                foreach (var statement in context.statement())
                {
                    visitor.Visit(statement);
                }
            }
            // We are a rawText node. Don't compile it; instead, note the string
            else
            {
                CurrentNode.SourceTextStringID = Compiler.GetLineIDForNodeName(CurrentNode.Name);
            }
        }