Example #1
0
        //Compiles a primitive literal value
        private ExprData CompilePrimitive(ElaPrimitive p, LabelMap map, Hints hints)
        {
            AddLinePragma(p);
            PushPrimitive(p.Value);

            if ((hints & Hints.Left) == Hints.Left)
                AddValueNotUsed(p);

            if (p.Parens && p.Value.IsNegative())
            {
                AddWarning(ElaCompilerWarning.SectionAmbiguity, p, p.Value.ToString());
                AddHint(ElaCompilerHint.AddSpaceSection, p, p.Value.ToString().TrimStart('-'));
            }

            return new ExprData(DataKind.VarType, (Int32)p.Value.LiteralType);
        }
Example #2
0
 void Primitive(out ElaExpression exp)
 {
     exp = null;
     switch (la.kind) {
     case 3: {
     Get();
     exp = new ElaPrimitive(t) { Value = ParseInt(t.val) };
     break;
     }
     case 4: {
     Get();
     exp = new ElaPrimitive(t) { Value = ParseReal(t.val) };
     break;
     }
     case 5: {
     Get();
     exp = new ElaPrimitive(t) { Value = ParseString(t.val) };
     break;
     }
     case 6: {
     Get();
     exp = new ElaPrimitive(t) { Value = ParseChar(t.val) };
     break;
     }
     case 40: {
     Get();
     exp = new ElaPrimitive(t) { Value = new ElaLiteralValue(true) };
     break;
     }
     case 41: {
     Get();
     exp = new ElaPrimitive(t) { Value = new ElaLiteralValue(false) };
     break;
     }
     default: SynErr(69); break;
     }
 }