mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-08 15:52:26 +01:00
Renamed current as trunk.
git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1433 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
[[Property:title|eiffel_scan console input]]
|
||||
[[Property:weight|2]]
|
||||
[[Property:uuid|ce4da828-6772-e1c3-0917-82f6669cccf9]]
|
||||
<code>
|
||||
-- Example of a lexical analyzer based on the Eiffel syntax.
|
||||
-- The analyzer itself is found in the file ``eiffel_lex'', which
|
||||
-- is created according to the file ``eiffel_token'' if not
|
||||
-- previously built and stored.
|
||||
|
||||
class EIFFEL_SCAN
|
||||
|
||||
inherit
|
||||
|
||||
SCANNING
|
||||
rename
|
||||
make as scanning_make
|
||||
end;
|
||||
|
||||
ARGUMENTS
|
||||
undefine
|
||||
copy, consistent, is_equal, setup
|
||||
end
|
||||
|
||||
create
|
||||
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make
|
||||
-- Create a lexical analyser for Eiffel if none,
|
||||
-- then use it to analyze the file of name
|
||||
-- `file_name'.
|
||||
local
|
||||
file_name: STRING;
|
||||
do
|
||||
if argument_count < 1 then
|
||||
io.error.putstring ("Usage: eiffel_scan eiffel_class_file.e%N")
|
||||
else
|
||||
file_name := argument (1);
|
||||
scanning_make;
|
||||
build ("eiffel_lex", "eiffel_regular");
|
||||
io.putstring ("Scanning file `");
|
||||
io.putstring (file_name);
|
||||
io.putstring ("'.%N");
|
||||
analyze (file_name)
|
||||
end
|
||||
end -- make
|
||||
|
||||
end -- class EIFFEL_SCAN
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
[[Property:title|eiffel_scan console output]]
|
||||
[[Property:weight|3]]
|
||||
[[Property:uuid|a233d1b0-b964-ba44-7b24-7204d9fa6932]]
|
||||
<code>
|
||||
Scanning file `eiffel_scan.e'.
|
||||
|
||||
|
||||
--------------- LEXICAL ANALYSIS: ----
|
||||
|
||||
Token type 11: -- Example of a lexical analyzer based on the Eiffel syntax.
|
||||
-- The analyzer itself is found in the file ``eiffel_lex'', which
|
||||
-- is created according to the file ``eiffel_token'' if not
|
||||
-- previously built and stored.
|
||||
|
||||
Keyword: class Code: 1819086195
|
||||
Token type 32: EIFFEL_SCAN
|
||||
Keyword: inherit Code: 1080299636
|
||||
Token type 32: SCANNING
|
||||
Keyword: rename Code: 2076787557
|
||||
Token type 32: make
|
||||
Keyword: as Code: 24947
|
||||
Token type 32: scanning_make
|
||||
Keyword: end Code: 6647396
|
||||
Token type 15: ;
|
||||
Token type 32: ARGUMENTS
|
||||
Keyword: undefine Code: 1472863845
|
||||
Token type 32: copy
|
||||
Token type 17: ,
|
||||
Token type 32: consistent
|
||||
Token type 17: ,
|
||||
Token type 32: is_equal
|
||||
Token type 17: ,
|
||||
Token type 32: setup
|
||||
Keyword: end Code: 6647396
|
||||
Token type 32: create
|
||||
Token type 32: make
|
||||
Keyword: feature Code: 1951938661
|
||||
Token type 32: make
|
||||
Keyword: is Code: 26995
|
||||
Token type 11: -- Create a lexical analyser for Eiffel if none,
|
||||
-- then use it to analyze the file of name
|
||||
|
||||
Token type 11: -- `file_name'.
|
||||
|
||||
Keyword: local Code: 1869613420
|
||||
Token type 32: file_name
|
||||
Token type 16: :
|
||||
Token type 32: STRING
|
||||
Token type 15: ;
|
||||
Keyword: do Code: 25711
|
||||
Keyword: if Code: 26982
|
||||
Token type 32: argument_count
|
||||
Token type 10: <
|
||||
Token type 2: 1
|
||||
Keyword: then Code: 1952998766
|
||||
Token type 32: io
|
||||
Token type 13: .
|
||||
Token type 32: error
|
||||
Token type 13: .
|
||||
Token type 32: putstring
|
||||
Token type 20: (
|
||||
Token type 3: "Usage: eiffel_scan eiffel_class_file.e%N"
|
||||
Token type 21: )
|
||||
Keyword: else Code: 1701606245
|
||||
Token type 32: file_name
|
||||
Token type 18: :=
|
||||
Token type 32: argument
|
||||
Token type 20: (
|
||||
Token type 2: 1
|
||||
Token type 21: )
|
||||
Token type 15: ;
|
||||
Token type 32: scanning_make
|
||||
Token type 15: ;
|
||||
Token type 32: build
|
||||
Token type 20: (
|
||||
Token type 3: "eiffel_lex"
|
||||
Token type 17: ,
|
||||
Token type 3: "eiffel_regular"
|
||||
Token type 21: )
|
||||
Token type 15: ;
|
||||
Token type 32: io
|
||||
Token type 13: .
|
||||
Token type 32: putstring
|
||||
Token type 20: (
|
||||
Token type 3: "Scanning file `"
|
||||
Token type 21: )
|
||||
Token type 15: ;
|
||||
Token type 32: io
|
||||
Token type 13: .
|
||||
Token type 32: putstring
|
||||
Token type 20: (
|
||||
Token type 32: file_name
|
||||
Token type 21: )
|
||||
Token type 15: ;
|
||||
Token type 32: io
|
||||
Token type 13: .
|
||||
Token type 32: putstring
|
||||
Token type 20: (
|
||||
Token type 3: "'.%N"
|
||||
Token type 21: )
|
||||
Token type 15: ;
|
||||
Token type 32: analyze
|
||||
Token type 20: (
|
||||
Token type 32: file_name
|
||||
Token type 21: )
|
||||
Keyword: end Code: 6647396
|
||||
Keyword: end Code: 6647396
|
||||
Token type 11: -- make
|
||||
|
||||
Keyword: end Code: 6647396
|
||||
Token type 11: -- class EIFFEL_SCAN
|
||||
|
||||
Token type -1:
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
[[Property:title|EIFFEL_SCAN Text]]
|
||||
[[Property:weight|1]]
|
||||
[[Property:uuid|092bd183-2fc4-ae65-02b9-d66933492a50]]
|
||||
<code>
|
||||
|
||||
class
|
||||
EIFFEL_SCAN
|
||||
|
||||
inherit
|
||||
SCANNING
|
||||
rename
|
||||
make as scanning_make
|
||||
end
|
||||
|
||||
ARGUMENTS
|
||||
undefine
|
||||
copy,
|
||||
consistent,
|
||||
is_equal,
|
||||
setup
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make
|
||||
-- Create a lexical analyser for Eiffel if none,
|
||||
-- then use it to analyze the file of name
|
||||
-- file_name.
|
||||
local
|
||||
file_name: STRING
|
||||
do
|
||||
if argument_count < 1 then
|
||||
io.error.putstring ("Usage: eiffel_scan eiffel_class_file.e%N")
|
||||
else
|
||||
file_name := argument (1)
|
||||
scanning_make
|
||||
build ("eiffel_lex", "eiffel_regular")
|
||||
io.putstring ("Scanning file `")
|
||||
io.putstring (file_name)
|
||||
io.putstring ("'.%N")
|
||||
analyze (file_name)
|
||||
end
|
||||
end
|
||||
|
||||
end -- class EIFFEL_SCAN
|
||||
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
[[Property:title|EiffelLex Samples]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|2e4911de-4838-00fc-1742-a8ebd1ae05ff]]
|
||||
<code>
|
||||
|
||||
|
||||
Real $R
|
||||
Integer $Z
|
||||
String ("\"" -> "\"")
|
||||
Div "//"
|
||||
Mod "\\"
|
||||
Quotient '/'
|
||||
Product '*'
|
||||
Plus '+'
|
||||
Minus '-'
|
||||
Relational ('=' | '<' | '>' | ('<' '=') | ('>' '=') | ('/' '='))
|
||||
Comment ("--" -> "\n") *(' '| '\t') *("--" -> "\n")
|
||||
FeatureAddress '$'
|
||||
Dot '.'
|
||||
Dotdot ".."
|
||||
Semicolon ';'
|
||||
Colon ':'
|
||||
Comma ','
|
||||
Assign ":="
|
||||
ReverseAssign "?="
|
||||
Lparan '('
|
||||
Rparan ')'
|
||||
Lcurly '{'
|
||||
Rcurly '}'
|
||||
Lsquare '['
|
||||
Rsquare ']'
|
||||
Bang '!'
|
||||
LeftArray "<<"
|
||||
RightArray ">>"
|
||||
Power '^'
|
||||
Constraint "->"
|
||||
Character (('\''$P'\'') | ('\'''\\'['t'|'n'|'r'|'f']'\'') | ('\''+('0'..'7')'\''))
|
||||
Identifier ~('a'..'z') *(~('a'..'z') | '_' | ('0'..'9'))
|
||||
-- Keywords
|
||||
as
|
||||
and
|
||||
check
|
||||
class
|
||||
current
|
||||
debug
|
||||
deferred
|
||||
do
|
||||
else
|
||||
elseif
|
||||
end
|
||||
ensure
|
||||
expanded
|
||||
export
|
||||
external
|
||||
false
|
||||
feature
|
||||
from
|
||||
if
|
||||
implies
|
||||
indexing
|
||||
infix
|
||||
inherit
|
||||
inspect
|
||||
integer
|
||||
invariant
|
||||
is
|
||||
language
|
||||
like
|
||||
local
|
||||
loop
|
||||
not
|
||||
obsolete
|
||||
old
|
||||
once
|
||||
or
|
||||
prefix
|
||||
real
|
||||
redefine
|
||||
require
|
||||
rename
|
||||
rescue
|
||||
result
|
||||
retry
|
||||
select
|
||||
strip
|
||||
then
|
||||
true
|
||||
undefine
|
||||
unique
|
||||
until
|
||||
variant
|
||||
void
|
||||
when
|
||||
xor
|
||||
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[[Property:title|Eiffel scanner]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|c0d6ad9d-2bac-c5ad-69b6-873db2e47aa9]]
|
||||
In the directory '''$ISE_EIFFEL/examples/lex''' you will find a system that scans Eiffel classes. It consists of the class [[EIFFEL_SCAN Text|EIFFEL_SCAN]] . It uses the file [[EiffelLex Samples|eiffel_regular]] as lexical grammar to analyze an Eiffel class passed on the command line.
|
||||
|
||||
When compiling the example, the executable '''eiffel_scan(.exe)''' is created. Use the program as follows:
|
||||
<code>eiffel_scan <Eiffel class file>;</code>
|
||||
|
||||
As an example, when the [[eiffel_scan console input|source code]] of the root class is run through the scanner, it outputs a [[eiffel_scan console output|list]] of all consecutive tokens and keywords in that class to the console.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[[Property:title|EiffelLex Sample]]
|
||||
[[Property:weight|2]]
|
||||
[[Property:uuid|79ad35f3-75a9-429c-ad47-f304fec23306]]
|
||||
* [[Eiffel scanner|Eiffel scanner]]
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user