1 NoEcho(' 2 /****************************************************************************** 3 * 4 * Module Name: aslcstyle.y - Production rules for symbolic operators 5 * 6 *****************************************************************************/ 7 8 /* 9 * Copyright (C) 2000 - 2016, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions, and the following disclaimer, 17 * without modification. 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 * substantially similar to the "NO WARRANTY" disclaimer below 20 * ("Disclaimer") and any redistribution must be conditioned upon 21 * including a substantially similar Disclaimer requirement for further 22 * binary redistribution. 23 * 3. Neither the names of the above-listed copyright holders nor the names 24 * of any contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * Alternatively, this software may be distributed under the terms of the 28 * GNU General Public License ("GPL") version 2 as published by the Free 29 * Software Foundation. 30 * 31 * NO WARRANTY 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 * POSSIBILITY OF SUCH DAMAGES. 43 */ 44 45 ') 46 47 /******************************************************************************* 48 * 49 * Production rules for the symbolic (c-style) operators 50 * 51 ******************************************************************************/ 52 53 /* 54 * ASL Extensions: C-style math/logical operators and expressions. 55 * The implementation transforms these operators into the standard 56 * AML opcodes and syntax. 57 * 58 * Supported operators and precedence rules (high-to-low) 59 * 60 * NOTE: The operator precedence and associativity rules are 61 * implemented by the tokens in asltokens.y 62 * 63 * (left-to-right): 64 * 1) ( ) expr++ expr-- 65 * 66 * (right-to-left): 67 * 2) ! ~ 68 * 69 * (left-to-right): 70 * 3) * / % 71 * 4) + - 72 * 5) >> << 73 * 6) < > <= >= 74 * 7) == != 75 * 8) & 76 * 9) ^ 77 * 10) | 78 * 11) && 79 * 12) || 80 * 81 * (right-to-left): 82 * 13) = += -= *= /= %= <<= >>= &= ^= |= 83 */ 84 85 Expression 86 87 /* Unary operators */ 88 89 : PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);} 90 TermArg {$$ = TrLinkChildren ($<n>2,1,$3);} 91 | PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);} 92 TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateNullTarget ());} 93 94 | SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);} 95 {$$ = TrLinkChildren ($<n>3,1,$1);} 96 | SuperName PARSEOP_EXP_DECREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);} 97 {$$ = TrLinkChildren ($<n>3,1,$1);} 98 99 /* Binary operators: math and logical */ 100 101 | TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} 102 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 103 | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} 104 TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), 105 TrCreateNullTarget ());} 106 | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} 107 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 108 | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} 109 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 110 | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} 111 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 112 | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} 113 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 114 | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} 115 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 116 117 | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} 118 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 119 | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} 120 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 121 | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} 122 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());} 123 124 | TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);} 125 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 126 | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATEREQUAL);} 127 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 128 | TermArg PARSEOP_EXP_LESS {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);} 129 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 130 | TermArg PARSEOP_EXP_LESS_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LLESSEQUAL);} 131 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 132 133 | TermArg PARSEOP_EXP_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);} 134 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 135 | TermArg PARSEOP_EXP_NOT_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LNOTEQUAL);} 136 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 137 138 | TermArg PARSEOP_EXP_LOGICAL_AND {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);} 139 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 140 | TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);} 141 TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);} 142 143 /* Parentheses */ 144 145 | '(' TermArg ')' { $$ = $2;} 146 147 /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */ 148 149 | SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT 150 {$$ = TrCreateLeafNode (PARSEOP_INDEX); 151 TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} 152 ; 153 154 /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */ 155 156 IndexExpTerm 157 158 : SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT 159 {$$ = TrCreateLeafNode (PARSEOP_INDEX); 160 TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} 161 ; 162 163 EqualsTerm 164 165 /* All assignment-type operations */ 166 167 : SuperName PARSEOP_EXP_EQUALS 168 TermArg {$$ = TrCreateAssignmentNode ($1, $3);} 169 170 | TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} 171 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 172 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 173 174 | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} 175 TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), 176 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 177 178 | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} 179 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 180 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 181 182 | TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} 183 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 184 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 185 186 | TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} 187 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 188 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 189 190 | TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} 191 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 192 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 193 194 | TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} 195 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 196 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 197 198 | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} 199 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 200 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 201 202 | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} 203 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 204 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 205 206 | TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} 207 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 208 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 209 ; 210