We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In this first implementation, the goal is to make it easy to parse and apply transformations on the parsed items.
(:char #\a)
(:one #'fn)
(:string "abc")
(:and exp ...)
(:or exp ...)
(:many exp)
(:maybe exp)
A macro is used to declare all rules for the BNF.
(:= word (:many (:one #'alpha-char-p)) :call #'stringify)
:call
funcall
:apply
apply
:tag
(cons TAG RESULTS)
Parsing a valid json number:
(load #P"~/projects/cl-bnf/cl-bnf.lisp") (:= decimal-number (:many (:one #'numeric-char-p))) (:= real-number (:or (:and #'decimal-number (:char #\.) #'decimal-number) (:and #'decimal-number (:char #\.)))) (:= signed-part (:or (:char #\+) (:char #\-))) (:= exp-chars (:or (:char #\e) (:char #\E))) (:= exp-part (:or (:and #'exp-chars #'signed-part #'decimal-number) (:and #'exp-chars #'decimal-number))) (:= numeric (:or #'real-number #'decimal-number)) (:= number-literal (:or (:and #'numeric #'exp-part) #'numeric) :call (lambda (matches) (cons :number (stringify matches)))) (parse #number-literal "1e3")
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In this first implementation, the goal is to make it easy to parse and apply transformations on the parsed items.
Combinators:
(:char #\a)
test the next element on the stream with the given char.(:one #'fn)
test using a function to get the next char in the stream.(:string "abc")
test if the string is in the stream.(:and exp ...)
collect many expressions.(:or exp ...)
collect the expression that matches.(:many exp)
collect all matches of the expression, if any.(:maybe exp)
turns the failed test into a valid one.Declaration
A macro is used to declare all rules for the BNF.
Valid transformations:
:call
apply a function to the results usingfuncall
.:apply
apply a function to the results usingapply
.:tag
return a cons like(cons TAG RESULTS)
.Example
Parsing a valid json number:
The text was updated successfully, but these errors were encountered: