Skip to content

Instantly share code, notes, and snippets.

@Bruno-366
Last active July 18, 2023 14:44
Show Gist options
  • Save Bruno-366/417234ca0d44dde37103616364ebf528 to your computer and use it in GitHub Desktop.
Save Bruno-366/417234ca0d44dde37103616364ebf528 to your computer and use it in GitHub Desktop.
Context-sensitive grammars in Shen-lisp

Context-sensitive grammars in Shen-lisp

Shen has its own in built version of YACC.
The irony is that YACC is less powerful in theory than the above.
Since it is based on BNF which is used to describe context-free grammars.

(1-) (defmacro infix [X + Y] -> [+ X Y])
infix
(2-) (+ 4 2)
6
(3-) (4 + 2)
6
\\ something different:
(0-) (defmacro myfunction ["explode(" X ")"] -> [explode X])
myfunction
(1-) ("explode(" "hello world" ")")
["h" "e" "l" "l" "o" " " "w" "o" "r" "l" "d"]
@Bruno-366
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment