version 1.20, 2012/06/23 23:20:23
|
version 1.21, 2012/07/02 21:59:48
|
Line 25
|
Line 25
|
\ The "design pattern" used here is the *factory*, even though |
\ The "design pattern" used here is the *factory*, even though |
\ the recognizer does not return a full-blown object. |
\ the recognizer does not return a full-blown object. |
\ A recognizer has the stack effect |
\ A recognizer has the stack effect |
\ ( addr u -- token table true | addr u false ) |
\ ( addr u -- token table | addr u r:fail ) |
\ where the token is the result of the parsing action (can be more than |
\ where the token is the result of the parsing action (can be more than |
\ one stack or live on other stacks, e.g. on the FP stack) |
\ one stack or live on other stacks, e.g. on the FP stack) |
\ and the table contains for actions (as array of four xts: |
\ and the table contains three actions (as array of three xts): |
\ interpret it, compile interpretation semantics |
\ interpret it, compile it, compile it as literal. |
\ compile it, compile it as literal. |
|
|
|
: recognizer: ( xt1 xt2 xt3 -- ) Create rot , swap , , ; |
: recognizer: ( xt1 xt2 xt3 -- ) Create rot , swap , , ; |
|
|