Beispiel #1
0
 public virtual Type getType(Identifier id)
 {
     Type type = (Type) this.get_Renamed(id, "type");
     if (type == null)
     {
         throw new Exception("No type found for "+id);
     }
     return type;
 }
Beispiel #2
0
 public virtual void setType(Identifier id, Type type)
 {
     this.set_Renamed(id, "type", type);
 }
Beispiel #3
0
 private Node parseProcedureCall(Identifier id, Scanner tokens)
 {
     ArrayList children = ArrayList.Synchronized(new ArrayList(10));
     children.Add(new Node(id));
     if (tokens.peek() == PascalTokens.TOPENPAREN)
     {
         tokens.next();
         children.Add(parseExpression(tokens));
         while (tokens.peek() == PascalTokens.TCOMMA)
         {
             tokens.next();
             children.Add(parseExpression(tokens));
         }
         consume(PascalTokens.TCLOSEPAREN, tokens);
     }
     return new Node(PascalNonterminals.PROCEDURE_CALL, children);
 }
Beispiel #4
0
        private Node parseVariable(Identifier id, Scanner tokens)
        {
            Node base_Renamed = new Node(PascalNonterminals.VARIABLE_NAME, new Node(id));
            bool done = false;
            while (!done)
            {
                Token tok = tokens.peek();
                if (tok == PascalTokens.TDOT)
                {
                    //CHECKING IF THIS BLOCK GET EVER ACCESSED
                    //OTHER WISE REMOVE FIELD_SELECT FROM PASCALNONTERMINALS

                    tokens.next();
                    ArrayList children = ArrayList.Synchronized(new ArrayList(10));
                    children.Add(base_Renamed);
                    children.Add(getID(tokens));
                    base_Renamed = new Node(PascalNonterminals.FIELD_SELECT, children);
                }
                else if (tok == PascalTokens.TOPENBRACKET)
                {
                    tokens.next();
                    ArrayList children = ArrayList.Synchronized(new ArrayList(10));
                    children.Add(base_Renamed);
                    children.Add(parseExpression(tokens));
                    while (tokens.peek() == PascalTokens.TCOMMA)
                    {
                        tokens.next();
                        children.Add(parseExpression(tokens));
                    }
                    consume(PascalTokens.TCLOSEBRACKET, tokens);
                    base_Renamed = new Node(PascalNonterminals.ARRAY_SELECT, children);
                }

                else
                {
                    done = true;
                }
            }
            return base_Renamed;
        }
Beispiel #5
0
 private Node parseAssignment(Identifier id, Scanner tokens)
 {
     ArrayList children = ArrayList.Synchronized(new ArrayList(10));
     children.Add(parseVariable(id, tokens));
     if (tokens.peek() != PascalTokens.TBECOMES)
         return wrongToken(PascalNonterminals.ASS_STAT, tokens.peek());
     tokens.next();
     children.Add(parseExpression(tokens));
     return new Node(PascalNonterminals.ASS_STAT, children);
 }