コード例 #1
0
 def __sdecl(self, stmt_list_node):
     self.__eat(token.STRUCTTYPE, 'expecting struct')
     struct_node = ast.StructDeclStmt()
     struct_node.struct_id = self.current_token
     self.__eat(token.ID, 'expecting ID')
     self.__vdecls(struct_node)
     stmt_list_node.stmts.append(struct_node)
     self.__eat(token.END, 'expecting end')
コード例 #2
0
 def __sdecl(self, stmt_list_node):
     structNode = ast.StructDeclStmt()
     self.__eat(token.STRUCTTYPE, 'expecting struct type')
     structNode.struct_id = self.current_token
     self.__eat(token.ID, 'expecting identifier')
     self.__vdecls(structNode.var_decls)
     self.__eat(token.END, 'expecting end')
     stmt_list_node.stmts.append(structNode)
コード例 #3
0
 def __sdecl(self):
     """<sdecl> ::= STRUCT ID <vdecls> END """
     structNode = ast.StructDeclStmt()
     self.__eat(token.STRUCTTYPE, "expecting struct")
     structNode.struct_id = self.current_token
     self.__eat(token.ID, "expecting an id")
     self.__vdecls(structNode)
     self.__eat(token.END, "expecting an end")
     return structNode
コード例 #4
0
ファイル: mypl_parser.py プロジェクト: michael-newell/CPSC326
 def __sdecl(self):
     """<sdecl> ::= STRUCT ID <vdecls> END"""
     struct_node = ast.StructDeclStmt()
     self.__eat(token.STRUCTTYPE, 'expecting "struct"')
     struct_node.struct_id = self.current_token
     self.__eat(token.ID, 'expecting "ID"')
     struct_node.var_decls = self.__vdecls([])
     self.__eat(token.END, 'expecting "end"')
     return struct_node
コード例 #5
0
 def __sdecl(self):
     """<sdecl> ::= STRUCT ID <vdecls> END"""
     struct_decl_node = ast.StructDeclStmt()
     self.__eat(token.STRUCTTYPE, "expected 'struct'")
     struct_decl_node.struct_id = self.current_token
     self.__eat(token.ID, "expected struct ID")
     self.__vdecls(struct_decl_node)
     self.__eat(token.END, "expected 'end'")
     return struct_decl_node
コード例 #6
0
 def __sdecl(self, stmt_list_node):
     # 〈sdecl〉::= STRUCTTYPE ID〈vdecls〉END
     var_list = []
     struct_node = ast.StructDeclStmt()
     struct_node.struct_id = self.current_token
     self.__eat(token.ID, "expecting an ID")
     self.__vdecls(var_list)
     struct_node.var_decls = var_list
     stmt_list_node.stmts.append(struct_node)
     self.__eat(token.END, "expecting end")
コード例 #7
0
ファイル: mypl_parser.py プロジェクト: ericav99/CPSC326
 def __sdecl(self):
     # print("sdecl: " + str(self.current_token))
     self.__advance() # eat STRUCT (we already know from stmt)
     struct_decl_stmt_node = ast.StructDeclStmt()
     struct_decl_stmt_node.struct_id = self.current_token # StructDeclStmt ID
     self.__eat(token.ID, 'expected ID')
     # passing in an empty list because __vdecls() recurses with a list parameter
     struct_decl_stmt_node.var_decls = self.__vdecls([]) # StructDeclStmt [VarDeclStmt]
     self.__eat(token.END, 'expected "end"')
     return struct_decl_stmt_node
コード例 #8
0
 def __sdecl(self):
     """<sdecl> ::= STRUCT ID <vdecls> END"""
     struct_decl_node = ast.StructDeclStmt()
     self.__eat(token.STRUCTTYPE, "expecting a struct")
     struct_decl_node.struct_id = self.current_token
     self.__eat(token.ID, "expecting an identifyer")
     vDeclsList = []
     self.__vdecls(vDeclsList)
     struct_decl_node.var_decls = vDeclsList
     self.__eat(token.END, "expecting end")
     return struct_decl_node