/src/tools/syntax/tree/liberty_ast_expression_binary.e
Specman e | 88 lines | 62 code | 12 blank | 14 comment | 0 complexity | 9f52c8d20786483bb3ae711f34d38d22 MD5 | raw file
1-- This file is part of Liberty Eiffel. 2-- 3-- Liberty Eiffel is free software: you can redistribute it and/or modify 4-- it under the terms of the GNU General Public License as published by 5-- the Free Software Foundation, version 3 of the License. 6-- 7-- Liberty Eiffel is distributed in the hope that it will be useful, 8-- but WITHOUT ANY WARRANTY; without even the implied warranty of 9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10-- GNU General Public License for more details. 11-- 12-- You should have received a copy of the GNU General Public License 13-- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>. 14-- 15deferred class LIBERTY_AST_EXPRESSION_BINARY[E_ -> LIBERTY_AST_NON_TERMINAL_NODE] 16 17inherit 18 LIBERTY_AST_NON_TERMINAL_NODE 19 20feature {LIBERTY_AST_HANDLER} 21 left_expression: E_ is 22 require 23 not is_empty 24 not is_binary 25 do 26 Result ::= nodes.first 27 end 28 29 left_binary: like Current is 30 require 31 not is_empty 32 is_binary 33 do 34 Result ::= nodes.first 35 end 36 37 right_expression: E_ is 38 require 39 not is_empty 40 do 41 Result ::= nodes.last 42 end 43 44 is_binary: BOOLEAN is 45 require 46 not is_empty 47 do 48 Result := nodes.first.name = eiffel_name 49 end 50 51 is_double_operator: BOOLEAN is 52 do 53 Result := count = 4 54 end 55 56 operator1: EIFFEL_IMAGE is 57 local 58 op1: LIBERTY_AST_TERMINAL_NODE 59 do 60 op1 ::= nodes.item(1) 61 Result := op1.image 62 end 63 64 operator2: EIFFEL_IMAGE is 65 require 66 is_double_operator 67 local 68 op2: LIBERTY_AST_TERMINAL_NODE 69 do 70 op2 ::= nodes.item(2) 71 Result := op2.image 72 end 73 74feature {ANY} 75 count: INTEGER is 76 do 77 Result := nodes.count 78 end 79 80feature {} 81 possible_counts: SET[INTEGER] is 82 once 83 Result := {AVL_SET[INTEGER] << 3, 4 >> } -- depends on the operator 84 end 85 86 errors: LIBERTY_ERRORS 87 88end