public override object VisitStringExpr(StringExprContext context) { var text = ""; if (context.stringTemplate().Length == 0) { foreach (var v in context.stringContent()) { text += Visit(v); } return((new System.Text.StringBuilder().Append("\"").Append(text).Append("\"")).to_str()); } else { text = "(new System.Text.StringBuilder()"; foreach (var i in range(1, context.ChildCount - 2, 1, true, true)) { var v = context.GetChild(i); var r = (string)(Visit(context.GetChild(i))); if (v.@is <StringContentContext>()) { text += (new System.Text.StringBuilder().Append(".Append(").Append("\"").Append(r).Append("\"").Append(")")).to_str(); } else { text += r; } } text += ").to_str()"; return(text); } }
public override object VisitStringExpr(StringExprContext context) { var text = ""; if (context.stringTemplate().Length == 0) { foreach (var v in context.stringContent()) { text += Visit(v); } return((new System.Text.StringBuilder().Append("\"").Append(text).Append("\"")).To_Str()); } else { text = "(new System.Text.StringBuilder()"; foreach (var i in 1.Up_until(context.ChildCount - 1)) { var v = context.GetChild(i); var r = ((string)Visit(context.GetChild(i))); if ((v is StringContentContext)) { text += (new System.Text.StringBuilder().Append(".Append(").Append("\"").Append(r).Append("\"").Append(")")).To_Str(); } else { text += r; } } text += ").To_Str()"; return(text); } }
public IHolderCil Visit(StringExprContext parserRule, IFunctionCil cilTree, IContextCil contextCil) { var value = new LocalCil($"_value{cilTree.LocalCils.Count}"); cilTree.LocalCils.Add(value); var stringCool = parserRule.STRING().GetText(); var varDataString = new VarCil($"s{CilAst.dataStringCils.Count}"); CilAst.dataStringCils.Add(new DataStringCil(varDataString, new StringCil(stringCool))); cilTree.ThreeDirInses.Add(new LoadCil(value, varDataString)); return(CreateABasicTypeWhitVal(cilTree, CilAst.String, value)); }
public void Visit(StringExprContext parserRule, IObjectContext <IVar, IVar> context) { parserRule.computedType = globalContext.String; }