/src/lib/parse/eiffel/eiffel_node.e
Specman e | 132 lines | 80 code | 15 blank | 37 comment | 2 complexity | ad597fae909745808dd940e4a69bee07 MD5 | raw file
1-- This file is part of a Liberty Eiffel library. 2-- See the full copyright at the end. 3-- 4deferred class EIFFEL_NODE 5 -- 6 -- Provides two basic operations: `display' for debug purposes, and `generate' for more generic node 7 -- handling. 8 -- 9 -- Any other operation should be provided by an external VISITOR. 10 -- 11 -- See also: EIFFEL_NON_TERMINAL_NODE, EIFFEL_LIST_NODE, EIFFEL_TERMINAL_NODE, EIFFEL_IMAGE 12 -- 13 14inherit 15 VISITABLE 16 17insert 18 EIFFEL_NODE_HANDLER 19 20feature {ANY} 21 parent: EIFFEL_NODE 22 -- the parent node 23 24 forgotten: FAST_ARRAY[EIFFEL_NODE] 25 -- used when this node is in a EIFFEL_LIST_NODE and nodes are between this node and the next one 26 27 name: FIXED_STRING is 28 -- the name of the node in the grammar 29 deferred 30 ensure 31 name /= Void 32 end 33 34 source_line: INTEGER is 35 deferred 36 end 37 38 source_column: INTEGER is 39 deferred 40 end 41 42 source_index: INTEGER is 43 deferred 44 end 45 46feature {EIFFEL_GRAMMAR} 47 set_forgotten (a_forgotten: like forgotten) is 48 do 49 forgotten := a_forgotten 50 ensure 51 forgotten = a_forgotten 52 end 53 54feature {EIFFEL_NODE_HANDLER} -- Basic operations 55 display (output: OUTPUT_STREAM; indent: INTEGER; p: STRING) is 56 -- Display the node in a tree fashion in the provided `output' stream 57 deferred 58 end 59 60 generate (o: OUTPUT_STREAM) is 61 -- Generate the node exactly as it was written, including blanks and `forgotten' nodes, onto the 62 -- provided `output' stream 63 deferred 64 end 65 66feature {} 67 generate_forgotten (o: OUTPUT_STREAM) is 68 local 69 i: INTEGER 70 do 71 if forgotten /= Void then 72 from 73 i := forgotten.lower 74 until 75 i > forgotten.upper 76 loop 77 forgotten.item(i).generate(o) 78 i := i + 1 79 end 80 end 81 end 82 83feature {EIFFEL_NON_TERMINAL_NODE, EIFFEL_LIST_NODE} 84 set_parent (a_parent: like parent) is 85 require 86 a_parent /= Void 87 parent = Void 88 do 89 parent := a_parent 90 ensure 91 parent = a_parent 92 end 93 94feature {} 95 do_indent (output: OUTPUT_STREAM; indent: INTEGER; p: STRING) is 96 local 97 i: INTEGER 98 do 99 from 100 i := 1 101 until 102 i > indent 103 loop 104 output.put_string(once " ") 105 i := i + 1 106 end 107 if p /= Void then 108 output.put_string(p) 109 end 110 end 111 112end -- class EIFFEL_NODE 113-- 114-- Copyright (c) 2009 by all the people cited in the AUTHORS file. 115-- 116-- Permission is hereby granted, free of charge, to any person obtaining a copy 117-- of this software and associated documentation files (the "Software"), to deal 118-- in the Software without restriction, including without limitation the rights 119-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 120-- copies of the Software, and to permit persons to whom the Software is 121-- furnished to do so, subject to the following conditions: 122-- 123-- The above copyright notice and this permission notice shall be included in 124-- all copies or substantial portions of the Software. 125-- 126-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 127-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 128-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 129-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 130-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 131-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 132-- THE SOFTWARE.