Exemple #1
0
        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]);
            }
        }
Exemple #2
0
 public VariableDeclarationStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #3
0
 public AssignmentStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #4
0
 public InputStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #5
0
 public Expression(CodePragma loc) : base(loc)
 {
 }
Exemple #6
0
 public ConditionalStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #7
0
 public PrimitiveExpression(CodePragma loc) : base(loc)
 {
 }
Exemple #8
0
 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));
 }
Exemple #9
0
 public TypecastExpression(CodePragma loc) : base(loc)
 {
 }
Exemple #10
0
        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());
        }
Exemple #11
0
 public LValue(CodePragma loc) : base(loc)
 {
 }
Exemple #12
0
 public FunctionExpression(CodePragma loc, FunctionRef fr) : base(loc)
 {
     func = fr;
 }
Exemple #13
0
 public FunctionExpression(CodePragma loc) : base(loc)
 {
 }
Exemple #14
0
 public ContinueStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #15
0
 public CodeObject(CodePragma loc)
 {
     this.location = loc;
 }
Exemple #16
0
 public TypecastExpression(CodePragma loc, Type t, Expression exp) : base(loc)
 {
     this.destType = t;
     this.exp      = exp;
 }
Exemple #17
0
 public void StartOperation(CodePragma loc)
 {
     operation = new AssignmentStatement(loc);
 }
Exemple #18
0
 public ReturnStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #19
0
 public LoopStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #20
0
 public BlockStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #21
0
 public PrimitiveExpression(CodePragma loc, object val) : base(loc)
 {
     value = val;
 }
Exemple #22
0
 public VariableLValue(CodePragma loc) : base(loc)
 {
 }
Exemple #23
0
 public BreakableStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #24
0
 public VariableLValue(CodePragma loc, VariableRef vr) : base(loc)
 {
     this.var = vr;
 }
Exemple #25
0
 public SwitchStatement(CodePragma loc) : base(loc)
 {
 }
Exemple #26
0
 public PrintStatement(CodePragma loc) : base(loc)
 {
 }