示例#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;
 }