Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created January 1, 2010 17:18
Show Gist options
  • Select an option

  • Save lsparrish/267165 to your computer and use it in GitHub Desktop.

Select an option

Save lsparrish/267165 to your computer and use it in GitHub Desktop.
: | char: | accept ;
{{
| find $- ::: true if $ is a word. |
| accept c"- ::: parsed text (delimited by c) goes at tib |
| tib -$ ::: used to access text after parsing. |
| nip xy-y ::: shorthand for swap drop |
| dup n-nn ::: duplicate top of stack |
| char: "-c ::: macro, gets a char at compile time. |
| if f- ::: jump to then if flag is false (at execute time) |
| then - ::: macro for the place that if jumps to when flag is false. |
| not f-f ::: change false to true, true to false. |
: defined ( "-f ) 32 accept tib find nip ;
: evalTib ( - ) tib dup getLength eval ;
: block{ ( "- ) char: } accept ;
: block ( "- ) key char: { =if char: { emit block{ ;
: evalBlock ( "- ) block evalTib ;
: ifBlock ( f"- ) if evalBlock ;then block ;
---reveal---
: ifDefined ( "- ) defined ifBlock ;
: ifNotDefined ( "- ) defined not ifBlock ;
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment