// a regular ol' line of text public override int VisitLine_statement(YarnSpinnerParser.Line_statementContext context) { // TODO: add support for line conditions: // // Mae: here's a line <<if true>> // // is identical to // // <<if true>> Mae: here's a line <<endif>> // Evaluate the inline expressions and push the results onto the // stack. var expressionCount = this.GenerateCodeForExpressionsInFormattedText(context.line_formatted_text().children); // Get the lineID for this string from the hashtags var lineIDTag = Compiler.GetLineIDTag(context.hashtag()); if (lineIDTag == null) { throw new InvalidOperationException("Internal error: line should have an implicit or explicit line ID tag, but none was found"); } var lineID = lineIDTag.text.Text; this.compiler.Emit(OpCode.RunLine, context.Start, new Operand(lineID), new Operand(expressionCount)); return(0); }
// a regular ol' line of text public override int VisitLine_statement(YarnSpinnerParser.Line_statementContext context) { // TODO: add support for line conditions: // // Mae: here's a line <<if true>> // // is identical to // // <<if true>> // Mae: here's a line // <<endif>> // Convert the formatted string into a string with // placeholders, and evaluate the inline expressions and push // the results onto the stack. GenerateFormattedText(context.line_formatted_text().children, out var composedString, out var expressionCount); // Get the lineID for this string from the hashtags if it has one; otherwise, a new one will be created string lineID = compiler.GetLineID(context.hashtag()); var hashtagText = GetHashtagTexts(context.hashtag()); int lineNumber = context.Start.Line; string stringID = compiler.RegisterString( composedString.ToString(), compiler.CurrentNode.Name, lineID, lineNumber, hashtagText); compiler.Emit(OpCode.RunLine, new Operand(stringID), new Operand(expressionCount)); return(0); }
public override int VisitLine_statement([NotNull] YarnSpinnerParser.Line_statementContext context) { int lineNumber = context.Start.Line; string lineID = Compiler.GetLineID(context.hashtag()); var hashtagText = GetHashtagTexts(context.hashtag()); GenerateFormattedText(context.line_formatted_text().children, out var composedString, out var expressionCount); string stringID = stringTableManager.RegisterString( composedString.ToString(), fileName, currentNodeName, lineID, lineNumber, hashtagText); if (lineID == null) { var hashtag = new YarnSpinnerParser.HashtagContext(context, 0); hashtag.text = new CommonToken(YarnSpinnerLexer.HASHTAG_TEXT, stringID); context.AddChild(hashtag); } return(0); }
// a regular ol' line of text public override int VisitLine_statement(YarnSpinnerParser.Line_statementContext context) { // TODO: add support for line conditions: // // Mae: here's a line <<if true>> // // is identical to // // <<if true>> Mae: here's a line <<endif>> // Evaluate the inline expressions and push the results onto // the stack. var expressionCount = GenerateCodeForExpressionsInFormattedText(context.line_formatted_text().children); // Get the lineID for this string from the hashtags string lineID = Compiler.GetLineID(context.hashtag()); if (lineID == null) { throw new ParseException("No line ID specified"); } compiler.Emit(OpCode.RunLine, new Operand(lineID), new Operand(expressionCount)); return(0); }
public override int VisitLine_statement([NotNull] YarnSpinnerParser.Line_statementContext context) { int lineNumber = context.Start.Line; YarnSpinnerParser.HashtagContext[] hashtags = context.hashtag(); var lineIDTag = Compiler.GetLineIDTag(hashtags); var lineID = lineIDTag?.text.Text ?? null; var hashtagText = GetHashtagTexts(hashtags); GenerateFormattedText(context.line_formatted_text().children, out var composedString, out var expressionCount); // Does this string table already have a string with this ID? if (lineID != null && stringTableManager.ContainsKey(lineID)) { // If so, this is an error. ParserRuleContext diagnosticContext; diagnosticContext = lineIDTag ?? (ParserRuleContext)context; this.diagnostics.Add(new Diagnostic(fileName, diagnosticContext, $"Duplicate line ID {lineID}")); return(0); } string stringID = stringTableManager.RegisterString( composedString.ToString(), fileName, currentNodeName, lineID, lineNumber, hashtagText); if (lineID == null) { var hashtag = new YarnSpinnerParser.HashtagContext(context, 0); hashtag.text = new CommonToken(YarnSpinnerLexer.HASHTAG_TEXT, stringID); context.AddChild(hashtag); } return(0); }