add example comment
This commit is contained in:
parent
90c8538be4
commit
a2fe1cdb14
|
@ -120,10 +120,20 @@
|
|||
[(lparen exp rparen) $2])
|
||||
(apply-args
|
||||
[(exp) (list $1)]
|
||||
[(exp comma apply-args) (cons $1 $3)])
|
||||
]))
|
||||
[(exp comma apply-args) (cons $1 $3)])]))
|
||||
|
||||
;; kaitai expr AST
|
||||
;; it's like racket mostly. builtins are
|
||||
;; - all the builtin operators
|
||||
;; - (apply func args ...): applies a function
|
||||
;; - (array args ...): constructs array
|
||||
;; - (get obj attr): references an attribute on an object
|
||||
;; primitive types: boolean, number, string, symbol (identifier)
|
||||
|
||||
(define test2 "true and 'a' != 'b' ? -1 + ~bits : ('hello' + 'world').substring(2, 3)")
|
||||
;; => '(if (and #t (!= "a" "b"))
|
||||
;; (+ -1 (~ bits))
|
||||
;; (apply (get (+ "hello" "world") substring) 2 3))
|
||||
|
||||
(let ([input (open-input-string test2)])
|
||||
(kaitai-parser (lambda () (kaitai-lexer input))))
|
||||
|
|
Loading…
Reference in New Issue