Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -0,0 +1,67 @@
|
|||
#*
|
||||
|
||||
GRAMMAR OR PARSE TOKENS
|
||||
int* - an unsigned integer
|
||||
sint* - a +/- signed integer
|
||||
.* - decimal point
|
||||
|
||||
HISTORY
|
||||
12 sept 2021: written, working
|
||||
|
||||
*#
|
||||
|
||||
# remove leading space
|
||||
begin { while [:space:]; clear; }
|
||||
|
||||
read;
|
||||
[0-9] {
|
||||
while [0-9]; put; clear; add "int*"; push; .reparse
|
||||
}
|
||||
[.+-] { put; add "*"; push; .reparse }
|
||||
[:space:] { while [:space:]; clear; add "space*"; push; .reparse }
|
||||
!"" {
|
||||
put; clear;
|
||||
add "Non-numeric char at "; lines; add ":"; chars; add "\n";
|
||||
print; quit;
|
||||
}
|
||||
|
||||
parse>
|
||||
# To visualise token reduction uncomment this:
|
||||
#lines; add ":"; chars; add " "; print; clear;
|
||||
#add "\n"; unstack; print; clip; stack;
|
||||
|
||||
pop; pop;
|
||||
|
||||
# -------------
|
||||
# 2 tokens
|
||||
"+*int*","-*int*" { clear; add "sint*"; push; .reparse }
|
||||
|
||||
pop;
|
||||
# -------------
|
||||
# 3 tokens
|
||||
"sint*.*int*","int*.*int*" {
|
||||
clear; add "float*"; push; .reparse
|
||||
}
|
||||
|
||||
(eof) {
|
||||
# ignore trailing space
|
||||
stack; pop; "space*" { clear; }
|
||||
unstack;
|
||||
"int*","sint*","float*" {
|
||||
replace "sint*" "signed integer,";
|
||||
replace "int*" "integer,";
|
||||
replace "*" ",";
|
||||
put; clear;
|
||||
add "It looks like a number (of type "; get; add ")\n";
|
||||
print; quit;
|
||||
}
|
||||
replace "sint*" "signed integer,";
|
||||
replace "int*" "integer,";
|
||||
replace "*" ",";
|
||||
put; clear;
|
||||
add "Doesnt look like one number \n";
|
||||
add "It was parsed as '"; get; add "'\n";
|
||||
print; quit;
|
||||
}
|
||||
|
||||
push; push; push;
|
||||
Loading…
Add table
Add a link
Reference in a new issue