This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-06
Channels
- # announcements (14)
- # babashka (12)
- # beginners (61)
- # biff (2)
- # calva (16)
- # clj-kondo (22)
- # cljdoc (7)
- # clojure (131)
- # clojure-europe (52)
- # clojure-losangeles (9)
- # clojure-norway (54)
- # clojure-spec (5)
- # clojure-uk (4)
- # clojurescript (18)
- # cursive (14)
- # datomic (19)
- # deps-new (14)
- # emacs (8)
- # events (7)
- # fulcro (6)
- # graphql (3)
- # hyperfiddle (42)
- # instaparse (5)
- # lsp (10)
- # malli (21)
- # nbb (1)
- # off-topic (3)
- # pathom (3)
- # polylith (7)
- # reagent (14)
- # releases (2)
Hi. I am trying to create a very simple parser but I don’t undestand why it fails. If I have the following parser:
S = E; E = 'N' | 'W' | 'S' | 'E'
Then
(parser "N")
=> [:S [:E "N"]]
but if I add a rule to expand to multiple it stops parsing:
S = E; E = 'N' | 'W' | 'S' | 'E'; E = E E;
(parser "N")
=> Parse error at line 1, column 1:
N
^
Seems odd that adding more production rules would make it parse less….am not sure, but I would try adding the second E production as an alternative to the first E production
Hm I’ll just rewrite it all I think
Another puzzle:
S = DIR+; DIR = ('N' | 'W' | 'S' | 'E')+;
This produces:
(parser2 "WWWW")
=> [:S [:DIR "W"] [:DIR "W"] [:DIR "W"] [:DIR "W"]]
I would prefers that DIR
was greedy in that it would only parse as a single element if there are multiple letters in a row… how would I do that?