Skip to content

Instantly share code, notes, and snippets.

@val314159
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save val314159/8965b772d6c9973e2e35 to your computer and use it in GitHub Desktop.
Save val314159/8965b772d6c9973e2e35 to your computer and use it in GitHub Desktop.
self describing parser language
ident::& ([$_A-Za-z]*);;
pat ::& (\(.*\)) ;;
item ::| ident pat ;;
stmt ::& expr (\;\;) ;;
list ::* item ;;
and ::& (\:\:\&) list;;
or ::& (\:\:\|) list;;
arr ::& (\:\:\*) list;;
expr ::| and or arr ;;
prog ::* expr ;;
prog:
ident: [ "&", "[$_A-Za-z]*"]
pat : [ "&", "\\(.*\\)" ]
item : [ "|", ident, pat ]
stmt : [ "&", expr, ";;" ]
list : [ "*", item ]
and : [ "&", "::&", list ]
or : [ "&", "::|", list ]
arr : [ "&", "::*", list ]
expr : [ "|", and, or, arr ]
prog : [ "*", expr ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment