예제 #1
0
        internal void HandleLhs(ident i, BekTypes t, bool implicitdefine = false)
        {
            SymtabElt e;

            if (TryGetElt(i.name, out e))
            {
                if (implicitdefine)
                {
                    throw new BekParseException(i.line, i.pos, string.Format("'{0}' already defined", i.name));
                }
                if (e.type != t)
                {
                    throw new BekParseException(i.line, i.pos, string.Format("'{0}' inconsistent type", i.name));
                }

                this.symtab[i] = e;
            }
            else if (implicitdefine)
            {
                e = new SymtabElt(i, t);
                this.AddElt(i, e);
            }
            else
            {
                throw new BekParseException(i.line, i.pos, string.Format("'{0}' undefined", i.name));
            }
        }
예제 #2
0
        Expr MkExpr(BekTypes btype, expr e)
        {
            switch (btype)
            {
            case BekTypes.BOOL:
                return(((boolconst)e).val ? stb.Solver.True : stb.Solver.False);

            case BekTypes.CHAR:
                return(stb.Solver.MkNumeral(((charconst)e).val, charsort));

            case BekTypes.STR:
                return(stb.Solver.MkListFromString(((strconst)e).val, charsort));

            default:
                throw new BekException();     //TBD: introduce exception kinds
            }
        }
예제 #3
0
        Sort BekTypeToSort(BekTypes btype)
        {
            switch (btype)
            {
            case BekTypes.BOOL:
                return(stb.Solver.BoolSort);

            case BekTypes.CHAR:
                return(charsort);

            case BekTypes.STR:
                return(stb.Solver.MkListSort(charsort));

            default:
                throw new BekException();     //TBD: introduce exception kinds
            }
        }
예제 #4
0
        internal void HandleLhs(ident i, BekTypes t, bool implicitdefine=false)
        {
            SymtabElt e;
            if (TryGetElt(i.name, out e))
            {
                if (implicitdefine)
                    throw new BekParseException(i.line, i.pos, string.Format("'{0}' already defined", i.name));
                if (e.type != t)
                    throw new BekParseException(i.line, i.pos, string.Format("'{0}' inconsistent type", i.name));

                this.symtab[i] = e;
            }
            else if (implicitdefine)
            {
                e = new SymtabElt(i, t);
                this.AddElt(i, e);
            }
            else
            {
                throw new BekParseException(i.line, i.pos, string.Format("'{0}' undefined", i.name));
            }
        }
예제 #5
0
 public SymtabElt(object def, BekTypes type)
 {
     this.id = nextid++;
     this.def = def;
     this.type = type;
 }
예제 #6
0
 public SymtabElt(object def, BekTypes type)
 {
     this.id   = nextid++;
     this.def  = def;
     this.type = type;
 }