~tim/scheme-vm

ref: 3c0fc6fa79193278089891e19d63a0f0ddff22c7 scheme-vm/src/lisp.pest -rw-r--r-- 1007 bytes
3c0fc6faTim Morgan Remove halt option from compile method 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
whitespace = _{ "\t" | "\n" | " " }

escape = _{ "\\" ~ any }

string = ${ "\"" ~ ((!("\"" | "\\") ~ any) | escape)* ~ "\"" }

delimited_identifier_inner = ${ (!"|" ~ any)+ }

delimited_identifier = _{ "|" ~ delimited_identifier_inner ~ "|" }

simple_atom = ${ (!("(" | ")" | " " | "\t" | "\n" | "[" | "]" | "{" | "}" | "|") ~ any)+ }

quoted_atom = ${ quote ~ simple_atom }

atom = _{ quoted_atom | delimited_identifier | simple_atom }

sexp = _{ quoted_sexp | simple_sexp }

comment = { block_comment | line_comment | datum_comment }

expression = _{ string | comment | sexp | atom }

quote = !{ "'" | ",@" | "," | "`" }

quoted_sexp = ${ quote ~ simple_sexp }

simple_sexp = ${ "(" ~ whitespace* ~ expressions* ~ whitespace* ~ ")" }

block_comment = @{ "#|" ~ (!"|#" ~ any)* ~ "|#" }

line_comment = @{ ";" ~ (!"\n" ~ any)* }

datum_comment = @{ "#;" ~ " "? ~ (sexp | atom) }

expressions = _{ expression ~ (whitespace* ~ expression)* }

program = { soi ~ whitespace* ~ expressions ~ whitespace* ~ eoi }