예제 #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
        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));
            }
        }
예제 #3
0
 internal SymtabElt AddElt(ident i, SymtabElt e)
 {
     this.names.Peek()[i.name] = e;
     this.symtab[i] = e;
     return e;
 }
예제 #4
0
 internal bool TryGetElt(string name, out SymtabElt e)
 {
     return this.names.Peek().TryGetValue(name, out e);
 }
예제 #5
0
 internal SymtabElt AddElt(ident i, SymtabElt e)
 {
     this.names.Peek()[i.name] = e;
     this.symtab[i]            = e;
     return(e);
 }
예제 #6
0
 internal bool TryGetElt(string name, out SymtabElt e)
 {
     return(this.names.Peek().TryGetValue(name, out e));
 }