diff options
author | Nguyễn Gia Phong <cnx@loang.net> | 2024-04-05 15:24:17 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <cnx@loang.net> | 2024-04-05 15:35:22 +0900 |
commit | 3cfda858dcdd50743593aa28527d21603748d859 (patch) | |
tree | a77b5aa1a50b94be7b64bf985003c57d7a9e64b9 | |
parent | f5382344577fd053e004a4ba25a0d4cb232fb19d (diff) | |
download | quy-3cfda858dcdd50743593aa28527d21603748d859.tar.gz |
Pass parsing spec/grammar/tests/line_comment_after_doc_comment.zig
-rw-r--r-- | src/parse.janet | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/parse.janet b/src/parse.janet index 58e8f79..bb329b5 100644 --- a/src/parse.janet +++ b/src/parse.janet @@ -43,8 +43,9 @@ [& kwargs] (let [container @{:doc @[] :field @[] :decl @[]}] (each i (range 0 (length kwargs) 2) - (array/push (container (kwargs i)) - (kwargs (inc i)))) + (if (container (kwargs i)) + (array/push (container (kwargs i)) (kwargs (inc i))) + (set (container (kwargs i)) (kwargs (inc i))))) (freeze container))) (def grammar @@ -281,16 +282,18 @@ :expr/assign (* :expr (+ (* :op/assign :expr) (+ (some (* :comma :expr)) := :expr) 0)) - :expr/container (* (+ :keyword/extern :keyword/packed 0) - (+ (* :keyword/struct - (? (* :paren/l :expr :paren/r))) - :keyword/opaque - :proto/enum - (* :keyword/union - (? (* :paren/l - (+ :proto/enum :expr) - :paren/r)))) - :brace/l :container/members :brace/r) + :expr/container (/ (* (+ :keyword/extern :keyword/packed 0) + (constant :kind) + (+ (* (constant :struct) :keyword/struct + (? (* :paren/l :expr :paren/r))) + (* (constant :opaque) :keyword/opaque) + :proto/enum + (* (constant :union) :keyword/union + (? (* :paren/l + (+ :proto/enum :expr) + :paren/r)))) + :brace/l :container/members :brace/r) + ,collect) :expr/type (* (any :proto/type) :expr/error-union) :expr/type/primary (+ :literal/char :literal/float @@ -422,8 +425,8 @@ (/ (* (? :doc-comment) (? :keyword/comptime) (! :keyword/fn) - (? (* :ident (drop ::))) - :expr/type + (? (* (constant :ident) :ident (drop ::))) + (constant :type) :expr/type (? :byte-align) (? (* := :expr))) ,struct)) @@ -431,7 +434,8 @@ (any :container/decl) (any (* :container/field :comma)) (+ :container/field (any :container/decl))) - :main (/ (* :skip :container/members -1) + :main (/ (* :skip (constant :kind) (constant :struct) + :container/members -1) ,collect)}))) (defn ast |