Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar dreme::datum::Grammar;
- token TOP {
- <datum>
- [ $ || <.panic: "Syntax error"> ]
- }
- ## Lexer items
- # This <ws> rule treats # as "comment to eol".
- token ws {
- <!ww>
- <comment>*
- }
- token comment {
- | <line_comment>
- | <nested_comment>
- }
- token line_comment {
- ';' \N* \n?
- }
- token nested_comment {
- '#|' ~ '|#' .
- }
- ## Data
- rule datum {
- | <simple_datum>
- | <compound_datum>
- }
- rule simple_datum {
- | <boolean>
- | <character>
- | <number>
- | <string>
- | <symbol>
- | <bytevector>
- }
- rule compound_datum {
- | <list>
- | <vector>
- }
- rule symbol { <identifier> }
- rule list {
- | '(' ~ ')' <list_data>
- | '[' ~ ']' <list_data> # R6RS
- }
- rule list_data {
- | <datum>*
- | <datum>+ '.' <datum>
- | <datum> '.' <datum> '.' <datum> # Racket
- }
- rule abbreviation {
- | "'" <datum>
- | '`' <datum>
- | ',' <datum>
- | ',@' <datum>
- }
- rule vector {
- '#' '(' ~ ')' <datum>*
- }
- token bytevector_hash {
- | '#vu8' # R6RS
- | '#u8' # R7RS
- }
- rule bytevector {
- <bytevector_hash> '(' ~ ')' <u8>
- }
- token u8 {
- \d**1..3 <?{$/ < 256}>
- }
Advertisement
Add Comment
Please, Sign In to add comment