1# Copyright (c) 2009 The Hewlett-Packard Development Company 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 301 unchanged lines hidden (view full) --- 310 p[4]["enumeration"] = "yes" 311 p[4]["state_decl"] = "yes" 312 p[0] = ast.StateDeclAST(self, p[3], p[4], p[7]) 313 314 def p_decl__object(self, p): 315 "decl : type ident pairs SEMI" 316 p[0] = ast.ObjDeclAST(self, p[1], p[2], p[3]) 317 |
318 # Function definition and declaration |
319 def p_decl__func_decl(self, p): |
320 "decl : func_decl" 321 p[0] = p[1] 322 323 def p_func_decl__0(self, p): 324 """func_decl : void ident '(' params ')' pairs SEMI |
325 | type ident '(' params ')' pairs SEMI""" 326 p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], None) 327 328 def p_decl__func_def(self, p): |
329 "decl : func_def" 330 p[0] = p[1] 331 332 def p_func_def__0(self, p): 333 """func_def : void ident '(' params ')' pairs statements 334 | type ident '(' params ')' pairs statements""" |
335 p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], p[7]) 336 337 # Type fields 338 def p_type_members__list(self, p): 339 "type_members : type_member type_members" 340 p[0] = [ p[1] ] + p[2] 341 342 def p_type_members__empty(self, p): 343 "type_members : empty" 344 p[0] = [] 345 346 def p_type_method__0(self, p): 347 "type_member : type_or_void ident '(' types ')' pairs SEMI" 348 p[0] = ast.TypeFieldMethodAST(self, p[1], p[2], p[4], p[6]) 349 |
350 def p_type_method__1(self, p): 351 "type_member : type_or_void ident '(' params ')' pairs statements" 352 p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], p[7]) 353 |
354 def p_type_member__1(self, p): 355 "type_member : type_or_void ident pairs SEMI" 356 p[0] = ast.TypeFieldMemberAST(self, p[1], p[2], p[3], None) 357 358 def p_type_member__2(self, p): 359 "type_member : type_or_void ident ASSIGN expr SEMI" 360 p[0] = ast.TypeFieldMemberAST(self, p[1], p[2], 361 ast.PairListAST(self), p[4]) --- 349 unchanged lines hidden --- |