| getinput member? ; |
getinput member? ; |
| ' testchar? test-vector ! |
' testchar? test-vector ! |
| |
|
| : checksyncline ( -- ) |
: checksynclines ( -- ) |
| \ when input points to a newline, check if the next line is a |
\ when input points to a newline, check if the next line is a |
| \ sync line. If it is, perform the appropriate actions. |
\ sync line. If it is, perform the appropriate actions. |
| |
begin |
| rawinput @ >r |
rawinput @ >r |
| s" #line " r@ over compare if |
s" #line " r@ over compare if |
| rdrop 1 line +! EXIT |
rdrop 1 line +! EXIT |
| dup char+ rawinput ! |
dup char+ rawinput ! |
| rawinput @ c@ cookedinput @ c! |
rawinput @ c@ cookedinput @ c! |
| endif |
endif |
| drop ; |
drop |
| |
again ; |
| |
|
| : ?nextchar ( f -- ) |
: ?nextchar ( f -- ) |
| s" syntax error, wrong char" ?print-error |
s" syntax error, wrong char" ?print-error |
| 1 chars rawinput +! |
1 chars rawinput +! |
| 1 chars cookedinput +! |
1 chars cookedinput +! |
| nl-char = if |
nl-char = if |
| checksyncline |
checksynclines |
| rawinput @ line-start ! |
rawinput @ line-start ! |
| endif |
endif |
| rawinput @ c@ cookedinput @ c! |
rawinput @ c@ |
| |
cookedinput @ c! |
| endif ; |
endif ; |
| |
|
| : charclass ( set "name" -- ) |
: charclass ( set "name" -- ) |
| \ process the string at addr u |
\ process the string at addr u |
| over dup rawinput ! dup line-start ! cookedinput ! |
over dup rawinput ! dup line-start ! cookedinput ! |
| + endrawinput ! |
+ endrawinput ! |
| checksyncline |
checksynclines |
| primitives2something ; |
primitives2something ; |
| |
|
| |
: unixify ( c-addr u1 -- c-addr u2 ) |
| |
\ delete crs from the string |
| |
bounds tuck tuck ?do ( c-addr1 ) |
| |
i c@ dup #cr <> if |
| |
over c! char+ |
| |
else |
| |
drop |
| |
endif |
| |
loop |
| |
over - ; |
| |
|
| : process-file ( addr u xt-simple x-combined -- ) |
: process-file ( addr u xt-simple x-combined -- ) |
| output-combined ! output ! |
output-combined ! output ! |
| save-mem 2dup filename 2! |
save-mem 2dup filename 2! |
| slurp-file |
slurp-file unixify |
| warnings @ if |
warnings @ if |
| ." ------------ CUT HERE -------------" cr endif |
." ------------ CUT HERE -------------" cr endif |
| primfilter ; |
primfilter ; |