Deleted Added
sdiff udiff text old ( 10165:7e9edf4297a9 ) new ( 10307:6df951dcd7d9 )
full compact
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

--- 304 unchanged lines hidden (view full) ---

313 p[0] = ast.EnumDeclAST(self, p[3], p[4], p[7])
314
315 def p_decl__state_decl(self, p):
316 "decl : STATE_DECL '(' type pairs ')' '{' type_states '}'"
317 p[4]["enumeration"] = "yes"
318 p[4]["state_decl"] = "yes"
319 p[0] = ast.StateDeclAST(self, p[3], p[4], p[7])
320
321 def p_decl__object(self, p):
322 "decl : type ident pairs SEMI"
323 p[0] = ast.ObjDeclAST(self, p[1], p[2], p[3])
324
325 # Function definition and declaration
326 def p_decl__func_decl(self, p):
327 "decl : func_decl"
328 p[0] = p[1]
329
330 def p_func_decl__0(self, p):
331 """func_decl : void ident '(' params ')' pairs SEMI
332 | type ident '(' params ')' pairs SEMI"""
333 p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], None)
334
335 def p_decl__func_def(self, p):
336 "decl : func_def"
337 p[0] = p[1]
338
339 def p_func_def__0(self, p):
340 """func_def : void ident '(' params ')' pairs statements
341 | type ident '(' params ')' pairs statements"""
342 p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], p[7])
343
344 # Type fields
345 def p_type_members__list(self, p):
346 "type_members : type_member type_members"
347 p[0] = [ p[1] ] + p[2]
348
349 def p_type_members__empty(self, p):
350 "type_members : empty"
351 p[0] = []
352
353 def p_type_method__0(self, p):
354 "type_member : type_or_void ident '(' types ')' pairs SEMI"
355 p[0] = ast.TypeFieldMethodAST(self, p[1], p[2], p[4], p[6])
356
357 def p_type_method__1(self, p):
358 "type_member : type_or_void ident '(' params ')' pairs statements"
359 p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], p[7])
360
361 def p_type_member__1(self, p):
362 "type_member : type_or_void ident pairs SEMI"
363 p[0] = ast.TypeFieldMemberAST(self, p[1], p[2], p[3], None)
364
365 def p_type_member__2(self, p):
366 "type_member : type_or_void ident ASSIGN expr SEMI"
367 p[0] = ast.TypeFieldMemberAST(self, p[1], p[2],
368 ast.PairListAST(self), p[4])
369
370 # Enum fields
371 def p_type_enums__list(self, p):
372 "type_enums : type_enum type_enums"
373 p[0] = [ p[1] ] + p[2]
374
375 def p_type_enums__empty(self, p):
376 "type_enums : empty"
377 p[0] = []

--- 10 unchanged lines hidden (view full) ---

388 def p_type_states__empty(self, p):
389 "type_states : empty"
390 p[0] = []
391
392 def p_type_state(self, p):
393 "type_state : ident ',' enumeration pairs SEMI"
394 p[0] = ast.TypeFieldStateAST(self, p[1], p[3], p[4])
395
396 # Type
397 def p_types__multiple(self, p):
398 "types : type ',' types"
399 p[0] = [ p[1] ] + p[3]
400
401 def p_types__one(self, p):
402 "types : type"
403 p[0] = [ p[1] ]
404
405 def p_types__empty(self, p):
406 "types : empty"
407 p[0] = []
408
409 def p_typestr__multi(self, p):
410 "typestr : typestr DOUBLE_COLON ident"
411 p[0] = '%s::%s' % (p[1], p[3])
412
413 def p_typestr__single(self, p):
414 "typestr : ident"
415 p[0] = p[1]
416
417 def p_type__one(self, p):
418 "type : typestr"
419 p[0] = ast.TypeAST(self, p[1])
420
421 def p_void(self, p):
422 "void : VOID"
423 p[0] = ast.TypeAST(self, p[1])
424
425 def p_type_or_void(self, p):
426 """type_or_void : type
427 | void"""
428 p[0] = p[1]
429
430 # Formal Param
431 def p_params__many(self, p):
432 "params : param ',' params"
433 p[0] = [ p[1] ] + p[3]
434
435 def p_params__one(self, p):
436 "params : param"
437 p[0] = [ p[1] ]

--- 21 unchanged lines hidden (view full) ---

459 def p_param__default_bool(self, p):
460 "param : type ident '=' LIT_BOOL"
461 p[0] = ast.FormalParamAST(self, p[1], p[2], p[4])
462
463 def p_param__default_string(self, p):
464 "param : type ident '=' STRING"
465 p[0] = ast.FormalParamAST(self, p[1], p[2], p[4])
466
467 # Idents and lists
468 def p_idents__braced(self, p):
469 "idents : '{' identx '}'"
470 p[0] = p[2]
471
472 def p_idents__bare(self, p):
473 "idents : ident"
474 p[0] = [ p[1] ]

--- 245 unchanged lines hidden ---