Skip to content

Commit

Permalink
Working on AST tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cadrian committed Sep 13, 2009
1 parent 249f8c8 commit 8f0203b
Show file tree
Hide file tree
Showing 191 changed files with 1,453 additions and 257 deletions.
18 changes: 0 additions & 18 deletions src/lib/loadpath.se
@@ -1,20 +1,2 @@
./
./abilities/
./backtracking/loadpath.se
./design_patterns/
./exec/loadpath.se
./io/loadpath.se
./iterator/loadpath.se
./kernel/loadpath.se
./misc/
./ncurses/loadpath.se
./numeric/loadpath.se
./parse/loadpath.se
./random/
./regular_expression/loadpath.se
./sequencer/loadpath.se
./signal/
./sorting/
./storage/loadpath.se
./string/loadpath.se
./time/loadpath.se
25 changes: 2 additions & 23 deletions src/lib/parse/ese_parser.e → src/lib/parse/descending_parser.e
@@ -1,25 +1,4 @@
-- -----------------------------------------------------------------------------------------------------------
-- This file is part of the ESE library.
-- Copyright(C) 2006-2009: Cyril ADRIAN <cyril.adrian@gmail.com> and others (see AUTHORS)
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
-- associated documentation files (the "Software"), to deal in the Software without restriction, including
-- without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
-- following conditions:
--
-- The above copyright notice and this permission notice shall be included in all copies or substantial
-- portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
-- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
-- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-- USE OR OTHER DEALINGS IN THE SOFTWARE.
--
-- http://ese.sourceforge.net
-- -----------------------------------------------------------------------------------------------------------
class ESE_PARSER
class DESCENDING_PARSER
--
-- The entry point to LL(n) parsing. Currently that top-down parsing is directly implemented in the
-- PARSE_ATOM classes.
Expand Down Expand Up @@ -100,4 +79,4 @@ feature {}
create Result.make(0)
end

end -- class ESE_PARSER
end
52 changes: 0 additions & 52 deletions src/lib/parse/eiffel/eiffel_list_node.e
Expand Up @@ -28,65 +28,13 @@ insert
TRAVERSABLE[EIFFEL_NODE]

feature {ANY}
item (i: INTEGER): EIFFEL_NODE is
require
valid_index(i)
deferred
end

valid_index (index: INTEGER): BOOLEAN is
deferred
ensure
definition: Result = index >= lower and then index <= upper
end

lower: INTEGER is
deferred
ensure
lower >= 0
end

upper: INTEGER is
deferred
ensure
upper >= lower - 1
end

count: INTEGER is
deferred
ensure
definition: Result = upper - lower + 1
end

first: EIFFEL_NODE is
require
not is_empty
deferred
ensure
definition: Result = item(lower)
end

last: EIFFEL_NODE is
require
not is_empty
deferred
ensure
definition: Result = item(upper)
end

frozen get_new_iterator: ITERATOR[EIFFEL_NODE] is
do
check
dont_use_this: False
end
end

is_empty: BOOLEAN is
deferred
ensure
definition: Result = (count = 0)
end

feature {EIFFEL_GRAMMAR}
add (a_child: like item) is
deferred
Expand Down
5 changes: 0 additions & 5 deletions src/lib/parse/eiffel/eiffel_list_node_impl.e
Expand Up @@ -43,11 +43,6 @@ feature {ANY}
Result := children.item(children.upper - i)
end

valid_index (i: INTEGER): BOOLEAN is
do
Result := children.valid_index(i)
end

lower: INTEGER is
do
Result := children.lower
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse/eiffel/eiffel_non_terminal_node.e
Expand Up @@ -40,7 +40,7 @@ feature {ANY}
valid_index (index: INTEGER): BOOLEAN is
deferred
ensure
definition: Result = index >= lower and then index <= upper
definition: Result = (index >= lower and then index <= upper)
end

lower: INTEGER is
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse/parse_atom.e
Expand Up @@ -64,7 +64,7 @@ feature {PARSE_TABLE}
deferred
end

feature {ESE_PARSER, PARSE_NT_NODE}
feature {DESCENDING_PARSER, PARSE_NT_NODE}
parse (buffer: MINI_PARSER_BUFFER; actions: COLLECTION[PARSE_ACTION]): BOOLEAN is
-- The Result is True if the parsing succeeded, False otherwise.
require
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse/parse_non_terminal.e
Expand Up @@ -61,7 +61,7 @@ feature {PARSE_TABLE}
end
end

feature {ESE_PARSER, PARSE_NT_NODE}
feature {DESCENDING_PARSER, PARSE_NT_NODE}
parse (buffer: MINI_PARSER_BUFFER; actions: COLLECTION[PARSE_ACTION]): BOOLEAN is
do
Result := parser_tree.parse(buffer, actions)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse/parse_terminal.e
Expand Up @@ -41,7 +41,7 @@ feature {PARSE_TABLE}
end
end

feature {ESE_PARSER, PARSE_NT_NODE}
feature {DESCENDING_PARSER, PARSE_NT_NODE}
parse (buffer: MINI_PARSER_BUFFER; actions: COLLECTION[PARSE_ACTION]): BOOLEAN is
local
old_index: INTEGER; image: PARSER_IMAGE
Expand Down
53 changes: 37 additions & 16 deletions src/lib/storage/low_level/fixed_array.e
@@ -1,26 +1,43 @@
expanded class FIXED_ARRAY[E_]

insert
SAFE_EQUAL[E_]

creation {ANY}
default_create

feature {ANY}
capacity: INTEGER is
capacity: INTEGER
-- The number of slots this array holds
external "build_in"

feature {}
elements: NATIVE_ARRAY[E_]

feature {FIXED_ARRAY}
set_capacity (c: like capacity) is
require
c >= 0
do
elements := calloc(c)
capacity := c
ensure
capacity = c
end

feature {ANY} -- Basic features:
element_sizeof: INTEGER is
-- The size in number of bytes for type `E_'.
external "built_in"
do
Result := elements.element_sizeof
end

calloc (nb_elements: INTEGER): like Current is
-- Allocate a new array of `nb_elements' of type `E_'.
-- The new array is initialized with default values.
require
nb_elements > 0
external "built_in"
do
Result.set_capacity(nb_elements)
ensure
Result.all_default(nb_elements - 1)
Result.capacity = nb_elements
Expand All @@ -31,7 +48,8 @@ feature {ANY} -- Basic features:
-- Assume that `calloc' is already done and that `index' is the range [0 .. `capacity'-1].
require
index >= 0 and then index < capacity
external "built_in"
do
Result := elements.item(index)
end

put (element: E_; index: INTEGER) is
Expand All @@ -40,7 +58,8 @@ feature {ANY} -- Basic features:
-- is the range [0 .. `capacity'-1].
require
index >= 0 and then index < capacity
external "built_in"
do
elements.put(element, index)
ensure
item(index) = element
end
Expand All @@ -53,7 +72,6 @@ feature {ANY}
-- Old range is copied in the new allocated array.
-- New items are initialized with default values.
require
is_not_null
new_nb_elts > capacity
do
Result := calloc(new_nb_elts)
Expand Down Expand Up @@ -142,13 +160,13 @@ feature {ANY} -- Comparison:
Result := i < 0
end

deep_memcmp (other: like Current; capacity: INTEGER): BOOLEAN is
deep_memcmp (other: like Current; nb_elements: INTEGER): BOOLEAN is
-- Same jobs as `memcmp' but uses `is_deep_equal' instead of `is_equal'.
local
i: INTEGER; e1, e2: like item
do
from
i := capacity - 1
i := nb_elements - 1
Result := True
until
not Result or else i < 0
Expand Down Expand Up @@ -261,7 +279,7 @@ feature {ANY} -- Searching:
do
Result := fast_index_of(element, 0)
ensure
Result.in_range(-1, caoacity - 1)
Result.in_range(-1, capacity - 1)
Result /= -1 implies element = item(Result)
end

Expand All @@ -284,7 +302,7 @@ feature {ANY} -- Searching:
Result := -1
end
ensure
Result.in_range(start_index, upper + 1)
Result.in_range(start_index, capacity - 1)
Result /= -1 implies element = item(Result)
end

Expand Down Expand Up @@ -426,7 +444,8 @@ feature {ANY} -- Adding:
src_max >= src_min - 1
at + src_max - src_min < capacity
useful_work: src /= Current or at /= src_min
external "built_in"
do
elements.slice_copy(at, src, src_min, src_max)
end

feature {ANY} -- Other:
Expand Down Expand Up @@ -462,7 +481,7 @@ feature {ANY} -- Other:
do
set_all_with(e)
ensure
all_default(upper)
all_default
end

clear_slice (lower, upper: INTEGER) is
Expand Down Expand Up @@ -513,7 +532,7 @@ feature {ANY} -- Other:
lower >= 0
upper >= lower
lower + offset >= 0
upper + offset < capacoty
upper + offset < capacity
local
i: INTEGER
do
Expand Down Expand Up @@ -633,12 +652,14 @@ feature {ANY} -- Interfacing with other languages:
to_external: POINTER is
-- Gives access to the C pointer on the area of storage.
do
Result := to_pointer
Result := elements.to_pointer
end

from_pointer (pointer: POINTER; nb_elements: INTEGER): like Current is
-- Convert `pointer' into Current type.
external "built_in"
do
elements := from_pointer(pointer)
capacity := nb_elements
ensure
Result.capacity = nb_elements
end
Expand Down
1 change: 1 addition & 0 deletions src/tools/loadpath.se
Expand Up @@ -3,4 +3,5 @@
./syntax/
./syntax/parser/
./syntax/tree/
./syntax/tree/visitor/
./semantics/
10 changes: 3 additions & 7 deletions src/tools/syntax/parser/liberty_node_factory.e
Expand Up @@ -49,7 +49,7 @@ feature {EIFFEL_GRAMMAR}
when "Type_Definition" then
create {LIBERTY_AST_TYPE_DEFINITION}Result.make(name, names)
when "Parent_Clause" then
create {LIBERTY_AST_TYPE_PARENT_CLAUSE}Result.make(name, names)
create {LIBERTY_AST_PARENT_CLAUSE}Result.make(name, names)
when "Parent" then
create {LIBERTY_AST_PARENT}Result.make(name, names)
when "Parent_Rename" then
Expand Down Expand Up @@ -128,12 +128,8 @@ feature {EIFFEL_GRAMMAR}
create {LIBERTY_AST_R7}Result.make(name, names)
when "r8" then
create {LIBERTY_AST_R8}Result.make(name, names)
when "r9" then
create {LIBERTY_AST_R9}Result.make(name, names)
when "r10" then
create {LIBERTY_AST_R10}Result.make(name, names)
when "e0" then
create {LIBERTY_AST_E0}Result.make(name, names)
when "e1" then
create {LIBERTY_AST_E1}Result.make(name, names)
when "e2" then
Expand Down Expand Up @@ -165,7 +161,7 @@ feature {EIFFEL_GRAMMAR}
when "When" then
create {LIBERTY_AST_WHEN}Result.make(name, names)
when "When_Slice" then
create {LIBERTY_AST_WHEN_SLILCE}Result.make(name, names)
create {LIBERTY_AST_WHEN_SLICE}Result.make(name, names)
when "When_Value" then
create {LIBERTY_AST_WHEN_VALUE}Result.make(name, names)
when "Actuals" then
Expand All @@ -189,7 +185,7 @@ feature {EIFFEL_GRAMMAR}
when "Feature_Names" then
create {LIBERTY_AST_FEATURE_NAMES}Result.make(name, names)
when "Feature_Name" then
create {LIBERYT_AST_FEATURE_NAME}Result.make(name, names)
create {LIBERTY_AST_FEATURE_NAME}Result.make(name, names)
when "External" then
create {LIBERTY_AST_EXTERNAL}Result.make(name, names)
when "Alias" then
Expand Down
2 changes: 1 addition & 1 deletion src/tools/syntax/tree/liberty_ast_actual.e
Expand Up @@ -48,7 +48,7 @@ feature {ANY}
feature {}
possible_counts: SET[INTEGER] is
once
Result := {AVL_SET[INTEGER} << 1, 2 >> }
Result := {AVL_SET[INTEGER] << 1, 2 >> }
end

feature {ANY}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/syntax/tree/liberty_ast_actuals.e
Expand Up @@ -17,7 +17,7 @@ feature {ANY}
feature {}
possible_counts: SET[INTEGER] is
once
Result := {AVL_SET[INTEGER} << 0, 3 >> }
Result := {AVL_SET[INTEGER] << 0, 3 >> }
end

feature {ANY}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/syntax/tree/liberty_ast_agent_signature.e
Expand Up @@ -48,7 +48,7 @@ feature {ANY}
feature {}
possible_counts: SET[INTEGER] is
once
Result := {AVL_SET[INTEGER} << 1, 3, 4, 6 >> }
Result := {AVL_SET[INTEGER] << 1, 3, 4, 6 >> }
end

feature {ANY}
Expand Down

0 comments on commit 8f0203b

Please sign in to comment.