This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-30
Channels
- # asami (4)
- # babashka (3)
- # beginners (21)
- # biff (22)
- # cljs-dev (6)
- # clojure (11)
- # clojure-europe (3)
- # clojure-norway (35)
- # clojure-spain (4)
- # clojurescript (14)
- # datalevin (2)
- # emacs (12)
- # exercism (2)
- # fulcro (10)
- # honeysql (4)
- # humbleui (3)
- # hyperfiddle (49)
- # instaparse (1)
- # introduce-yourself (1)
- # missionary (1)
- # off-topic (109)
- # pathom (2)
- # practicalli (21)
- # random (2)
- # rdf (2)
- # releases (2)
- # scittle (3)
- # specter (2)
How can I disambiguate a grammar.
I have this a?0.1 0.3
that returns this two parses:
{:parses
([:pattern
[:cat [:degrade [:word "a"] [:op-degrade]] [:float "0.1"] [:float "0.3"]]]
[:pattern
[:cat
[:degrade [:word "a"] [:op-degrade [:degrade-amount "0.1"]]]
[:float "0.3"]]])}
I would just like to have the latter.
Relevant parts of my grammar look like this:
pattern = cat (<ws> <'.'> <ws> cat)*
ws = #"\s+"
word = #"[a-zA-Z0-9]([a-zA-Z0-9]*)"
int = #"[0-9]+"
float = #"(?<!\?)\d+(\.\d+)"
<token> = word | int | float | degrade
cat = token (<ws>? token)*
degrade-amount = #"([0-9]*[.])?[0-9]+"
op-degrade = <'?'> degrade-amount?
degrade = token op-degrade
I am trying to have different regexes for float
and degrade-amount
, but it’s not actually working. I also tried this: float = (!'?' #"\d+(\.\d+)")
but doesn’t seem to work.