def __idrval(self):
        """<idrvalue> ::= ID ( DOT ID )* | ID LPAREN <exprlist> RPAREN """

        idrval = ast.IDRvalue()
        idrval.path.append(self.current_token)
        call_rval = ast.CallRValue()
        call_rval.fun = self.current_token

        self.__eat(token.ID, "expected an ID")

        is_id_not_call = None
        if self.__tokenIs(token.LPAREN):
            is_id_not_call = False
            self.__advance()
            self.__exprlist(call_rval.args)
            self.__eat(token.RPAREN, "expected ')'")

        else:
            is_id_not_call = True

            while self.__tokenIs(token.DOT):
                self.__advance()
                idrval.path.append(self.current_token)

                self.__eat(token.ID, "expected an ID")

        if (is_id_not_call):
            return idrval
        else:
            return call_rval
Beispiel #2
0
    def __idrval(self, exprNode):
        temp = self.current_token
        self.__eat(token.ID, 'expecting id')
        if self.current_token.tokentype == token.LPAREN:
            exprNode.term = ast.CallRValue()
            exprNode.term.fun = temp
            self.__eat(token.LPAREN, 'expecting (')
            self.__exprlist(exprNode.term)
            self.__eat(token.RPAREN, 'expecting )')

        else:
            exprNode.term = ast.IDRvalue()
            exprNode.term.path.append(temp)
            while self.current_token.tokentype == token.DOT:
                self.__advance()
                exprNode.term.path.append(self.current_token)
                self.__eat(token.ID, 'expecting id')
Beispiel #3
0
 def __idrval(self):
     """<idrval> ::= ID (DOT ID)* | ID LPAREN <exprlist> RPAREN"""
     idr_value_node = ast.IDRvalue()
     idr_value_node.path.append(self.current_token)
     self.__eat(token.ID, "expecting an identifier")
     if self.current_token.tokentype == token.LPAREN:
         call_rvalue_node = ast.CallRValue()
         call_rvalue_node.fun = idr_value_node.path[0]
         self.__advance()
         call_rvalue_node.args = self.__exprlist()
         self.__eat(token.RPAREN, 'expecting a ")"')
         return call_rvalue_node
     else:
         while self.current_token.tokentype == token.DOT:
             self.__advance()
             idr_value_node.path.append(self.current_token)
             self.__eat(token.ID, "expecting an identifier")
     return idr_value_node
Beispiel #4
0
    def __idrval(self):
        id_rval_node = ast.IDRvalue()
        call_rval_node = ast.CallRValue()

        id_rval_node.path.append(self.current_token)
        call_rval_node.fun = self.current_token

        self.__eat(token.ID, 'expecting ID')
        if self.current_token.tokentype == token.LPAREN:
            self.__advance()
            self.__exprlist(call_rval_node)
            self.__eat(token.RPAREN, 'expecting rparren')
            return call_rval_node
        else:
            while self.current_token.tokentype == token.DOT:
                self.__advance()
                id_rval_node.path.append(self.current_token)
                self.__eat(token.ID, 'expecting ID')
            return id_rval_node
Beispiel #5
0
    def idrval(self):
        id_node = ast.IDRvalue()
        call_rvalue_node = ast.CallRValue()
        id_node.path.append(self.current_token)
        self.__eat(token.ID, "expecting an ID")
        if self.current_token.tokentype == token.DOT:

            while self.current_token.tokentype == token.DOT:
                self.__advance()
                id_node.path.append(self.current_token)
                self.__eat(token.ID, "expecting an ID")
            return id_node
        elif self.current_token.tokentype == token.LPAREN:
            call_rvalue_node.fun = id_node.path[0]
            self.__advance()
            if self.current_token.tokentype != token.RPAREN:
                self.__expr_list(call_rvalue_node)
            self.__eat(token.RPAREN, "expecting ')'")
            return call_rvalue_node
        return id_node
Beispiel #6
0
 def __idrval(self):
     """<idrval> ::= ID ( DOT ID )* | ID LPAREN <exprlist> RPAREN"""
     rStmt = ast.SimpleRValue()
     rStmt.val = self.current_token
     self.__eat(token.ID, "expecting ID")
     if self.current_token.tokentype == token.LPAREN:
         temp = rStmt.val
         rStmt = ast.CallRValue()
         rStmt.fun = temp
         self.__advance()
         self.__exprlist(rStmt)
         self.__eat(token.RPAREN, "expecting a ')'")
         return rStmt
     else:
         if self.current_token.tokentype == token.DOT:
             temp = rStmt.val
             rStmt = ast.IDRvalue()
             rStmt.path.append(temp)
             while self.current_token.tokentype == token.DOT:
                 self.__advance()
                 temp = self.current_token
                 rStmt.path.append(temp)
                 self.__eat(token.ID, "expecting an ID")
     return rStmt