parser.py (7567:238f99c9f441) parser.py (7839:9e556fb25900)
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

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

160 'stall_and_wait' : 'STALL_AND_WAIT',
161 'wake_up_dependents' : 'WAKE_UP_DEPENDENTS',
162 'enqueue' : 'ENQUEUE',
163 'copy_head' : 'COPY_HEAD',
164 'check_allocate' : 'CHECK_ALLOCATE',
165 'check_stop_slots' : 'CHECK_STOP_SLOTS',
166 'static_cast' : 'STATIC_CAST',
167 'if' : 'IF',
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

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

160 'stall_and_wait' : 'STALL_AND_WAIT',
161 'wake_up_dependents' : 'WAKE_UP_DEPENDENTS',
162 'enqueue' : 'ENQUEUE',
163 'copy_head' : 'COPY_HEAD',
164 'check_allocate' : 'CHECK_ALLOCATE',
165 'check_stop_slots' : 'CHECK_STOP_SLOTS',
166 'static_cast' : 'STATIC_CAST',
167 'if' : 'IF',
168 'is_valid' : 'IS_VALID',
169 'is_invalid' : 'IS_INVALID',
168 'else' : 'ELSE',
169 'return' : 'RETURN',
170 'THIS' : 'THIS',
171 'CHIP' : 'CHIP',
172 'void' : 'VOID',
173 'new' : 'NEW',
170 'else' : 'ELSE',
171 'return' : 'RETURN',
172 'THIS' : 'THIS',
173 'CHIP' : 'CHIP',
174 'void' : 'VOID',
175 'new' : 'NEW',
176 'OOD' : 'OOD',
174 }
175
176 literals = ':[]{}(),='
177
178 tokens = [ 'EQ', 'NE', 'LT', 'GT', 'LE', 'GE',
179 'LEFTSHIFT', 'RIGHTSHIFT',
180 'NOT', 'AND', 'OR',
181 'PLUS', 'DASH', 'STAR', 'SLASH',

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

571 p[0] = ast.CheckAllocateStatementAST(self, p[3])
572
573 def p_statement__check_stop(self, p):
574 "statement : CHECK_STOP_SLOTS '(' var ',' STRING ',' STRING ')' SEMI"
575 p[0] = ast.CheckStopStatementAST(self, p[3], p[5], p[7])
576
577 def p_statement__static_cast(self, p):
578 "aexpr : STATIC_CAST '(' type ',' expr ')'"
177 }
178
179 literals = ':[]{}(),='
180
181 tokens = [ 'EQ', 'NE', 'LT', 'GT', 'LE', 'GE',
182 'LEFTSHIFT', 'RIGHTSHIFT',
183 'NOT', 'AND', 'OR',
184 'PLUS', 'DASH', 'STAR', 'SLASH',

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

574 p[0] = ast.CheckAllocateStatementAST(self, p[3])
575
576 def p_statement__check_stop(self, p):
577 "statement : CHECK_STOP_SLOTS '(' var ',' STRING ',' STRING ')' SEMI"
578 p[0] = ast.CheckStopStatementAST(self, p[3], p[5], p[7])
579
580 def p_statement__static_cast(self, p):
581 "aexpr : STATIC_CAST '(' type ',' expr ')'"
579 p[0] = ast.StaticCastAST(self, p[3], p[5])
582 p[0] = ast.StaticCastAST(self, p[3], "ref", p[5])
580
583
584 def p_statement__static_cast_ptr(self, p):
585 "aexpr : STATIC_CAST '(' type ',' STRING ',' expr ')'"
586 p[0] = ast.StaticCastAST(self, p[3], p[5], p[7])
587
581 def p_statement__return(self, p):
582 "statement : RETURN expr SEMI"
583 p[0] = ast.ReturnStatementAST(self, p[2])
584
585 def p_statement__if(self, p):
586 "statement : if_statement"
587 p[0] = p[1]
588

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

598 "if_statement : IF '(' expr ')' statements ELSE if_statement"
599 p[0] = ast.IfStatementAST(self, p[3], p[5],
600 ast.StatementListAST(self, p[7]))
601
602 def p_expr__var(self, p):
603 "aexpr : var"
604 p[0] = p[1]
605
588 def p_statement__return(self, p):
589 "statement : RETURN expr SEMI"
590 p[0] = ast.ReturnStatementAST(self, p[2])
591
592 def p_statement__if(self, p):
593 "statement : if_statement"
594 p[0] = p[1]
595

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

605 "if_statement : IF '(' expr ')' statements ELSE if_statement"
606 p[0] = ast.IfStatementAST(self, p[3], p[5],
607 ast.StatementListAST(self, p[7]))
608
609 def p_expr__var(self, p):
610 "aexpr : var"
611 p[0] = p[1]
612
613 def p_expr__localvar(self, p):
614 "aexpr : type ident"
615 p[0] = ast.LocalVariableAST(self, p[1], p[2])
616
606 def p_expr__literal(self, p):
607 "aexpr : literal"
608 p[0] = p[1]
609
610 def p_expr__enumeration(self, p):
611 "aexpr : enumeration"
612 p[0] = p[1]
613
614 def p_expr__func_call(self, p):
615 "aexpr : ident '(' exprs ')'"
616 p[0] = ast.FuncCallExprAST(self, p[1], p[3])
617
618 def p_expr__new(self, p):
619 "aexpr : NEW type"
620 p[0] = ast.NewExprAST(self, p[2])
621
617 def p_expr__literal(self, p):
618 "aexpr : literal"
619 p[0] = p[1]
620
621 def p_expr__enumeration(self, p):
622 "aexpr : enumeration"
623 p[0] = p[1]
624
625 def p_expr__func_call(self, p):
626 "aexpr : ident '(' exprs ')'"
627 p[0] = ast.FuncCallExprAST(self, p[1], p[3])
628
629 def p_expr__new(self, p):
630 "aexpr : NEW type"
631 p[0] = ast.NewExprAST(self, p[2])
632
633 def p_expr__null(self, p):
634 "aexpr : OOD"
635 p[0] = ast.OodAST(self)
636
622 # globally access a local chip component and call a method
623 def p_expr__local_chip_method(self, p):
624 "aexpr : THIS DOT var '[' expr ']' DOT var DOT ident '(' exprs ')'"
625 p[0] = ast.LocalChipMethodAST(self, p[3], p[5], p[8], p[10], p[12])
626
627 # globally access a local chip component and access a data member
628 def p_expr__local_chip_member(self, p):
629 "aexpr : THIS DOT var '[' expr ']' DOT var DOT field"

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

682 """expr : NOT expr
683 | DASH expr %prec UMINUS"""
684 p[0] = PrefixOperatorExpr(p[1], p[2])
685
686 def p_expr__parens(self, p):
687 "aexpr : '(' expr ')'"
688 p[0] = p[2]
689
637 # globally access a local chip component and call a method
638 def p_expr__local_chip_method(self, p):
639 "aexpr : THIS DOT var '[' expr ']' DOT var DOT ident '(' exprs ')'"
640 p[0] = ast.LocalChipMethodAST(self, p[3], p[5], p[8], p[10], p[12])
641
642 # globally access a local chip component and access a data member
643 def p_expr__local_chip_member(self, p):
644 "aexpr : THIS DOT var '[' expr ']' DOT var DOT field"

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

697 """expr : NOT expr
698 | DASH expr %prec UMINUS"""
699 p[0] = PrefixOperatorExpr(p[1], p[2])
700
701 def p_expr__parens(self, p):
702 "aexpr : '(' expr ')'"
703 p[0] = p[2]
704
705 def p_expr__is_valid_ptr(self, p):
706 "aexpr : IS_VALID '(' var ')'"
707 p[0] = ast.IsValidPtrExprAST(self, p[3], True)
708
709 def p_expr__is_invalid_ptr(self, p):
710 "aexpr : IS_INVALID '(' var ')'"
711 p[0] = ast.IsValidPtrExprAST(self, p[3], False)
712
690 def p_literal__string(self, p):
691 "literal : STRING"
692 p[0] = ast.LiteralExprAST(self, p[1], "std::string")
693
694 def p_literal__number(self, p):
695 "literal : NUMBER"
696 p[0] = ast.LiteralExprAST(self, p[1], "int")
697

--- 19 unchanged lines hidden ---
713 def p_literal__string(self, p):
714 "literal : STRING"
715 p[0] = ast.LiteralExprAST(self, p[1], "std::string")
716
717 def p_literal__number(self, p):
718 "literal : NUMBER"
719 p[0] = ast.LiteralExprAST(self, p[1], "int")
720

--- 19 unchanged lines hidden ---