;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\305\306\307\"\207" [require cl-lib subr-x a parseclj-lex define-error parseclj-parser-error "parseclj: Syntax error"] 3) #@207 Signal a parse error. Takes a FORMAT string and optional ARGS to be passed to `format-message'. Signals a 'parseclj-parser-error signal, which can be handled with `condition-case'. (fn FORMAT &rest ARGS) (defalias 'parseclj--error #[385 "\300\301\302\303#C\"\207" [signal parseclj-parser-error apply format-message] 8 (#$ . 274)]) #@83 Scan STACK for an opening-token matching CLOSING-TOKEN. (fn STACK CLOSING-TOKEN) (defalias 'parseclj--find-opening-token #[514 "\300!\211\301\267\202\300\302\303\"!\207\304\207\300\302\305\"!\207\306\207" [parseclj-lex-token-type #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:rparen 9 :rbracket 16 :rbrace 18)) seq-find #[257 "\300!\301>\207" [parseclj-lex-token-type (:lparen :lambda)] 3 "\n\n(fn TOKEN)"] :lbracket #[257 "\300!\301>\207" [parseclj-lex-token-type (:lbrace :set)] 3 "\n\n(fn TOKEN)"] nil] 7 (#$ . 615)]) #@505 Reduce collection based on the top of the STACK and a CLOSING-TOKEN. REDUCE-BRANCH is a function to be applied to the collection of tokens found from the top of the stack until an opening token that matches CLOSING-TOKEN. This function should return an AST token representing such collection. OPTIONS is an association list. This list is also passed down to the REDUCE-BRANCH function. See `parseclj-parser' for more information on available options. (fn STACK CLOSING-TOKEN REDUCE-BRANCH OPTIONS) (defalias 'parseclj--reduce-coll #[1028 "\300\"\301\302\303#\304\204\"\203\305\306\301\307\"\310 !#\207\207\203?\310@!=\204?\211A\262\242B\262\202\"\310@!=\203q\203a\311\312\"\211\203`\305\306\301\307\"\310!#\210\210\211A\262\242$\207\203\202\305\306\301\307\"\310 !#\207\313!\207" [parseclj--find-opening-token a-get :fail-fast t nil parseclj--error "At position %s, unmatched %S" :pos parseclj-lex-token-type seq-find parseclj-lex-token-p reverse] 13 (#$ . 1192)]) #@290 Scan STACK until a value is found. Return everything up to the value in reversed order (meaning the value comes first in the result). STACK is the current parse stack to scan. VALUE-P a predicate to distinguish reduced values from non-values (tokens and whitespace). (fn STACK VALUE-P) (defalias 'parseclj--take-value #[514 "\300\30128\2057\302@!\203\303\301\300\"\210\202@!\203*\303\301@B\"\210\202\211A\262\242B\262\2020\207" [nil --cl-block-nil-- parseclj-lex-token-p throw] 7 (#$ . 2222)]) #@438 Scan STACK until a token of a certain type is found. Returns nil if a value is encountered before a matching token is found. Return everything up to the token in reversed order (meaning the token comes first in the result). STACK is the current parse stack to scan. VALUE-P a predicate to distinguish reduced values from non-values (tokens and whitespace). TOKEN-TYPES are the token types to look for. (fn STACK VALUE-P TOKEN-TYPES) (defalias 'parseclj--take-token #[771 "\300\3012I\205H\302@!\235\203\303\301@B\"\210\202@!\203,\303\301\300\"\210\202\304@!\203;\303\301\300\"\210\202\211A\262\242B\262\2020\207" [nil --cl-block-nil-- parseclj-lex-token-type throw parseclj-lex-token-p] 8 (#$ . 2747)]) #@259 Return t if STACK only has a single node for which VALUE-P is true. This checks if the stack contains a single, fully reduced value, and no dangling unmatched tokens. When parsing with `:read-one' this indicates a form can be returned. (fn STACK VALUE-P) (defalias 'parseclj-single-value-p #[514 "\300\301\302\303$?\205\304\"\207" [cl-reduce #[514 "\206\300!\207" [parseclj-lex-token-p] 4 "\n\n(fn BOOL NODE)"] :initial-value nil parseclj--take-value] 7 (#$ . 3486)]) #@1903 Clojure/EDN stack-based shift-reduce parser. REDUCE-LEAF does reductions for leaf nodes. It is a function that takes the current value of the stack and a token, and either returns an updated stack, with a new leaf node at the top (front), or returns the stack unmodified. REDUCE-BRANCH does reductions for branch nodes. It is a function that takes the current value of the stack, the type of branch node to create, and a list of child nodes, and returns an updated stack, with the new node at the top (front). What "node" means in this case is up to the reducing functions, it could be AST nodes (as in the case of `parseclj-parser-clojure'), or plain values/sexps (as in the case of `parseedn-read'), or something else. The only requirement is that they should not put raw tokens back on the stack, as the parser relies on the presence or absence of these to detect parse errors. OPTIONS is an association list which is passed on to the reducing functions. Additionally the following options are recognized - `:fail-fast' Raise an error when a parse error is encountered, rather than continuing with a partial result. - `:value-p' A predicate function to differentiate values from tokens and whitespace. This is needed when scanning the stack to see if any reductions can be performed. By default anything that isn't a token is considered a value. This can be problematic when parsing with `:lexical-preservation', and which case you should provide an implementation that also returns falsy for :whitespace, :comment, and :discard AST nodes. - `:tag-readers' An association list that describes tag handler functions for any possible tag. This options in only available in `parseedn-read', for more information, please refer to its documentation. - `:read-one' Return as soon as a single complete value has been read. (fn REDUCE-LEAF REDUCE-BRANCH &optional OPTIONS) (defalias 'parseclj-parser #[770 "\302\303\304#\302\305\"\302\306\307#\310\311 \203\312\"\204\313!\314=\204\2039\315!\2039\316\317\302\320\"\321!#\210\322!\203K#\262\202c\323!\203^\324  $\262\202c\211B\262\325\"\326G\233#\310\203\247\203\247GG\\\233\262 @\327A\"\f$\262\325\"\262\326G\233#\262\202p\266\325\"\325G\233\"\326GG\\\233 #\310\203\203\203\330\331\332\333E\"\"\233\262\n@\327A # $\262\325\"\262\325G\233\"\262\326GG\\\233 #\262\202\301\266\311 \262\202\2037\334\335\"\211\2036\316\336\302\320\"\313!#\210\210\203A\325\"@\207\310\337\340\341\342#\343! $@\207" [parseclj-lex--prefix-tokens parseclj-lex--prefix-2-tokens a-get :fail-fast t :read-one :value-p #[257 "\300!?\207" [parseclj-lex-token-p] 3 "\n\n(fn E)"] nil parseclj-lex-next parseclj-single-value-p parseclj-lex-token-type :eof parseclj-lex-error-p parseclj--error "Invalid token at %s: %S" :pos parseclj-lex-token-form parseclj-lex-leaf-token-p parseclj-lex-closing-token-p parseclj--reduce-coll parseclj--take-value parseclj--take-token append apply + mapcar length seq-find parseclj-lex-token-p "At position %s, unmatched %S" parseclj-lex-token :root "" 1 reverse] 19 (#$ . 3974)]) (provide 'parseclj-parser)