added jj_temporal source code

This commit is contained in:
2024-06-19 15:01:51 +02:00
parent d551f35d2f
commit 4df573d730
93 changed files with 13000 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,7 @@
cd d:
cd e_source
cd parser_tests
cd date_parser
cd discription_files
geyacc -t ymd_time_tokens -o ymd_time_parser.e ymd_time_parser.y
gelex -o ymd_time_scanner.e ymd_time_scanner.l

View File

@@ -0,0 +1,191 @@
%{
indexing
description: "[
Parser for reading in a string and converting it to a date.
This file was produced by 'geyacc' (from the gobo tools cluster)
using file 'ymd_time_parser.y'.
]"
date: "17 Aug 04"
author: "Jimmy J. Johnson"
copyright: "Copyright 2009, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL:$"
date: "$Date: 2009-06-25 21:37:23 -0400 (Thu, 25 Jun 2009) $"
revision: "$Revision: 7 $"
class YMD_TIME_PARSER
inherit
YY_PARSER_SKELETON
rename
make as make_parser_skeleton
redefine
default_create
end
YMD_TIME_PARSER_ROUTINES
rename
last_value as last_scanner_value
redefine
default_create
end
YMD_TIME_SCANNER
rename
last_value as last_scanner_value
redefine
default_create
end
create
default_create
feature {NONE} -- Initialization
default_create is
-- Create a new Eiffel parser.
do
Precursor {YMD_TIME_SCANNER}
make_parser_skeleton
end
feature -- Access
last_value: YMD_TIME
-- The result of parsing
feature -- Basic operations
parse_string (a_string: STRING) is
-- Parse `a_string'.
local
b: KL_CHARACTER_BUFFER
yy_buf: YY_BUFFER
f: FILE
s: STRING
do
reset
-- The `b' must end in "%U%U". I don't know why.
-- so append it onto the end of a copy of `a_string'.
s := deep_clone (a_string)
s.append ("%U%U")
create b.make_from_string (s)
create yy_buf.make_from_buffer (b)
set_input_buffer (yy_buf)
parse
end
-------------------------------------------------------------------------------------
-------------------- Following created by GeYacc ----------------------------------
%}
%token SCAN_ERROR_TOKEN
%token WEEKDAY_TOKEN
%token YEAR_TOKEN
%token MONTH_TOKEN
%token YEAR_OR_DAY_TOKEN
%token NUMBER_TOKEN
%type <YMD_TIME> Date
%type <YMD_TIME> Ambiguous_day
%type <YMD_TIME> Ambiguous_day_month
%type <YMD_TIME> Unspecified
%type <YMD_TIME> Weekday_included
%type <YMD_TIME> Three_numbers
%type <YMD_TIME> Two_numbers
%type <INTEGER> Month
%type <INTEGER> Year
%type <INTEGER> Year_or_day
%type <INTEGER> Number
--------------------------------------------------------------------------------
%%
Date: -- Empty { parsed_result := "No date entered" }
| Ambiguous_day { $$ := $1 last_value := $$ }
| Ambiguous_day_month { $$ := $1 last_value := $$ }
| Unspecified { $$ := $1 last_value := $$ }
| Three_numbers { $$ := $1 last_value := $$ }
| Two_numbers { $$ := $1 last_value := $$ }
| Weekday_included { $$ := $1 last_value := $$ }
-- | SCAN_ERROR_TOKEN { $$ := last_scanner_value last_value := $$ }
;
-- The Month and Year are known.
Ambiguous_day: Number Month Year { $$ := process_ambiguous_day ($1, $2, $3) }
| Year_or_day Month Year { $$ := process_ambiguous_day ($1, $2, $3) }
| Month Year_or_day Year { $$ := process_ambiguous_day ($2, $1, $3) }
| Month Number Year { $$ := process_ambiguous_day ($2, $1, $3) }
;
-- Only the Year is certain.
Ambiguous_day_month: Year_or_day Number Year { $$ := process_ambiguous_day ($1, $2, $3) }
| Number Year_or_day Year { $$ := process_ambiguous_day ($2, $1, $3) }
| Year Year_or_day Number { $$ := process_ambiguous_day ($2, $3, $1) }
| Year Number Year_or_day { $$ := process_ambiguous_day ($3, $2, $1) }
| Number Number Year { $$ := process_ambiguous_day_month ($1, $2, $3) }
| Year Number Number { $$ := process_ambiguous_day_month ($2, $3, $1) }
;
-- Two values input and at least one can be identified; assumptions are made about the unknowns.
Unspecified: Month Year { $$ := process_unspecified (0, $1, $2) }
| Year Month { $$ := process_unspecified (0, $2, $1) }
| Year_or_day Month { $$ := process_unspecified ($1, $2, 0) }
| Month Year_or_day { $$ := process_unspecified ($2, $1, 0) }
| Number Year { $$ := process_unspecified (0, $1, $2) }
| Year Number { $$ := process_unspecified (0, $2, $1) }
| Number Month { $$ := process_unspecified ($1, $2, 0) }
| Month Number { $$ := process_unspecified ($2, $1, 0) }
;
-- A date with the weekday included; the weekday is ignored.
Weekday_included: Weekday Ambiguous_day { $$ := $2 }
| Weekday Ambiguous_day_month { $$ := $2 }
| Weekday Unspecified { $$ := $2 }
| Weekday Three_numbers { $$ := $2 }
| Weekday Two_numbers { $$ := $2 }
;
-- The date is entered as three numbers and scanner is unable to deduce from
-- the values which one is day, year, and so on.
Three_numbers: Number Number Number { $$ := process_three_numbers ($1, $2, $3) }
| Year_or_day Number Number { $$ := process_three_numbers ($1, $2, $3) }
| Number Year_or_day Number { $$ := process_three_numbers ($1, $2, $3) }
| Number Number Year_or_day { $$ := process_three_numbers ($1, $2, $3) }
;
-- The date was enterred as only two numbers and the scanner was unable
-- to deduce thier meanings.
Two_numbers: Number Number { $$ := process_two_numbers ($1, $2) }
| Year_or_day Number { $$ := process_two_numbers ($1, $2) }
| Number Year_or_day { $$ := process_two_numbers ($1, $2) }
;
--------------------------------------------------------------------------------
Weekday: WEEKDAY_TOKEN { -- do nothing as result is not needed
}
;
Month: MONTH_TOKEN { $$ := last_integer }
;
Year: YEAR_TOKEN { $$ := last_integer }
;
Year_or_day: YEAR_OR_DAY_TOKEN { $$ := last_integer }
;
Number: NUMBER_TOKEN { $$ := last_integer }
;
%%
end -- class YMD_TIME_PARSER

View File

@@ -0,0 +1,149 @@
%{
indexing
description: "[
Scanner for reading in a string and converting it to a date.
This file was produced by 'gelex' (from the gobo tools cluster)
using file "ymd_time_scanner.l".
]"
date: "17 Aug 04"
author: "Jimmy J. Johnson"
copyright: "Copyright 2009, Jimmy J. Johnson"
license: "Eiffel Forum License v2 (see forum.txt)"
URL: "$URL:$"
date: "$Date: 2009-06-25 21:37:23 -0400 (Thu, 25 Jun 2009) $"
revision: "$Revision: 7 $"
class YMD_TIME_SCANNER
inherit
YY_COMPRESSED_SCANNER_SKELETON
export
{NONE} all
{ANY} scanning_error
redefine
default_create
end
UT_CHARACTER_CODES
export
{NONE} all
redefine
default_create
end
YMD_TIME_TOKENS
export
{NONE} all
redefine
default_create
end
YMD_TIME_SCANNER_ROUTINES
export
{NONE} all
redefine
default_create
end
create
default_create
feature {NONE} -- Initialization
default_create is
-- Create a scanner object
do
make
Precursor {YMD_TIME_SCANNER_ROUTINES}
end
feature -- Basic operations
scan_string (a_string: STRING) is
-- Scan `a_string'
local
b: KL_CHARACTER_BUFFER
yy_buf: YY_BUFFER
f: FILE
s: STRING
do
-- The `b' must end in "%U%U". I don't know why.
-- so append it onto the end of a copy of `a_string'.
s := deep_clone (a_string)
s.append ("%U%U")
create b.make_from_string (s)
create yy_buf.make_from_buffer (b)
set_input_buffer (yy_buf)
scan
end
print_values is
do
io.put_string ("token = ")
io.put_string (token_name (last_token))
io.put_string (" value = ")
if last_value /= Void then
io.put_string (last_value.out)
else
io.put_string ("Void")
end
io.new_line
end
---------------------------------------------------------------------------------
----------------------- Following code produce by Gelex ----------------------
%}
--%x IN_STR -- line 50
%option outfile="ymd_time_scanner.e"
IDENTIFIER [a-zA-Z][a-zA-Z]*
DIGIT [0-9]
INTEGER {DIGIT}+|{DIGIT}{1,3}(,{DIGIT}{3})+
SEPARATORS [:./\\,\- \t\n\r]+
%%
{INTEGER} {
last_integer := comas_removed (text).to_integer
last_value := last_integer
if last_integer > 31 then
last_token := YEAR_TOKEN
elseif last_integer > 12 then
last_token := YEAR_OR_DAY_TOKEN
else
last_token := NUMBER_TOKEN
end
print_values
}
{IDENTIFIER} { if is_month (text) then
last_token := MONTH_TOKEN
last_integer := get_month (text)
last_value := last_integer
elseif is_weekday (text) then
last_token := WEEKDAY_TOKEN
last_string := text
last_value := text
else
last_token := SCAN_ERROR_TOKEN
last_value := last_string
print_values
end
print_values
}
{SEPARATORS} { last_value := text
print_values
}
%%
end -- class YMD_TIME_SCANNER