File: minilisp.tt

package info (click to toggle)
ruby-parslet 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 908 kB
  • ctags: 473
  • sloc: ruby: 5,220; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (6)
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
grammar MiniLisp
  rule root
    (expression)
  end
  rule expression
    ((space_p) "(" (space_p) (body) ")")
  end
  rule space_p
    (space)0..1
  end
  rule body
    ((expression) / (identifier) / (float) / (integer) / (string))0..
  end
  rule space
    \s1..
  end
  rule identifier
    (([a-zA-Z=*] [a-zA-Z=*_]0..) (space_p))
  end
  rule float
    (((integer) (("." [0-9]1..) / ("e" [0-9]1..))) (space_p))
  end
  rule integer
    ((("+" / "-")0..1 [0-9]1..) (space_p))
  end
  rule string
    ("\"" (("\\" .) / (!"\"" .))0.. "\"" (space_p))
  end
end