-
-
Save ruv/84f8ff1a7c761dba030e11cecea9d283 to your computer and use it in GitHub Desktop.
A conceptual implementation for the word `missing(`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[undefined] parse-lexeme [if] | |
synonym parse-lexeme parse-name | |
[then] | |
[undefined] tt-xt [undefined] tt-sd [undefined] tt-x or or [if] | |
include https://github.com/ForthHub/fep-recognizer/blob/master/implementation/index.lib-compat.fth | |
include https://github.com/ForthHub/fep-recognizer/blob/master/implementation/variant.gamma/token-translator.fth | |
[then] | |
: extract-lexeme ( -- sd.lexeme | 0 0 ) | |
begin parse-lexeme dup if exit then 2drop refill 0= until 0 0 | |
; | |
: extract-lexeme-sure ( -- sd.lexeme ) | |
extract-lexeme dup if exit then -39 throw \ "unexpected end of the input source" | |
; | |
-81 constant exception-word-missing | |
: missing ( sd.name -- -81 | 0 ) | |
\ This implementation is for testing purposes only | |
forth-wordlist search-wordlist if drop 0 exit then exception-word-missing | |
; | |
: missing( ( compil: true ; "ccc <rparen> " -- | compil: false ; "ccc <rparen> " -- -81|0 ) | |
0 tt-x | |
begin extract-lexeme-sure | |
2dup s" )" compare \ the lexeme is not equal to ")" | |
while ( sd.lexeme ) | |
tt-sd [: missing or ;] tt-xt | |
repeat 2drop | |
; immediate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A link to the implementation for Recognizer API:
https://github.com/ForthHub/fep-recognizer/tree/master/implementation