public StringExpression(CodePragma loc, string str, Scope s, Errors e) : base(loc) { List <VariableRef> refs = new List <VariableRef>(); this.str = UnescapeString(str, s, e, location, refs); vars = new LValue[refs.Count]; for (int i = 0; i < vars.Length; i++) { vars[i] = new VariableLValue(location, refs[i]); } }
public VariableDeclarationStatement(CodePragma loc) : base(loc) { }
public AssignmentStatement(CodePragma loc) : base(loc) { }
public InputStatement(CodePragma loc) : base(loc) { }
public Expression(CodePragma loc) : base(loc) { }
public ConditionalStatement(CodePragma loc) : base(loc) { }
public PrimitiveExpression(CodePragma loc) : base(loc) { }
public void SetLoopVariable(CodePragma loc, VariableRef vr) { (operation as AssignmentStatement).lval = new VariableLValue(loc, vr); ((operation as AssignmentStatement).rval as FunctionExpression).arguments.Add(new VariableLValue(loc, vr)); }
public TypecastExpression(CodePragma loc) : base(loc) { }
public static string UnescapeString(string str, Scope s, Errors e, CodePragma location, List <VariableRef> refs) { int lastIdx = 1; int idx; StringBuilder ret = new StringBuilder(); try { while ((idx = str.IndexOf(':', lastIdx)) != -1) { //Append the string between the last escape and this one ret.Append(str, lastIdx, idx - lastIdx); //Decipher the escape int endIdx, refnum; VariableRef vr; switch (str[idx + 1]) { case ')': ret.Append('\n'); lastIdx = idx + 2; break; case '>': ret.Append('\t'); lastIdx = idx + 2; break; case 'o': ret.Append('\a'); lastIdx = idx + 2; break; case '"': ret.Append('"'); lastIdx = idx + 2; break; case ':': ret.Append(':'); lastIdx = idx + 2; break; case '(': endIdx = str.IndexOf(')', idx + 2); ret.Append(char.ConvertFromUtf32(int.Parse(str.Substring(idx + 2, endIdx - idx - 2), System.Globalization.NumberStyles.AllowHexSpecifier))); lastIdx = endIdx + 1; break; case '{': endIdx = str.IndexOf('}', idx + 2); vr = s[str.Substring(idx + 2, endIdx - idx - 2)] as VariableRef; if (vr == null) { e.SemErr(location.filename, location.startLine, location.startColumn, string.Format("Undefined variable: \"{0}\"", str.Substring(idx + 2, endIdx - idx - 2))); } refnum = refs.IndexOf(vr); if (refnum == -1) { refnum = refs.Count; refs.Add(vr); } ret.Append("{" + refnum.ToString() + "}"); lastIdx = endIdx + 1; break; case '[': endIdx = str.IndexOf(']', idx + 2); string uc = UnicodeNameLookup.GetUnicodeCharacter(str.Substring(idx + 2, endIdx - idx - 2)); if (uc == null) { e.SemErr(location.filename, location.startLine, location.startColumn, string.Format("Unknown unicode normative name: \"{0}\".", str.Substring(idx + 2, endIdx - idx - 2))); } else { ret.Append(uc); } lastIdx = endIdx + 1; break; } } //Append the end of the string ret.Append(str, lastIdx, str.Length - lastIdx - 1); } catch (Exception ex) { e.SemErr(string.Format("Invalid escape sequence in string constant: {0}", ex.Message)); } return(ret.ToString()); }
public LValue(CodePragma loc) : base(loc) { }
public FunctionExpression(CodePragma loc, FunctionRef fr) : base(loc) { func = fr; }
public FunctionExpression(CodePragma loc) : base(loc) { }
public ContinueStatement(CodePragma loc) : base(loc) { }
public CodeObject(CodePragma loc) { this.location = loc; }
public TypecastExpression(CodePragma loc, Type t, Expression exp) : base(loc) { this.destType = t; this.exp = exp; }
public void StartOperation(CodePragma loc) { operation = new AssignmentStatement(loc); }
public ReturnStatement(CodePragma loc) : base(loc) { }
public LoopStatement(CodePragma loc) : base(loc) { }
public BlockStatement(CodePragma loc) : base(loc) { }
public PrimitiveExpression(CodePragma loc, object val) : base(loc) { value = val; }
public VariableLValue(CodePragma loc) : base(loc) { }
public BreakableStatement(CodePragma loc) : base(loc) { }
public VariableLValue(CodePragma loc, VariableRef vr) : base(loc) { this.var = vr; }
public SwitchStatement(CodePragma loc) : base(loc) { }
public PrintStatement(CodePragma loc) : base(loc) { }