On Thu, Oct 31, 2013 at 12:47 PM, Jim - FooBar(); <jimpil1...@gmail.com> wrote:
> On 31/10/13 16:23, Jim - FooBar(); wrote:
>>
>> The result of this is a parser which sees everyhting as :TOKEN. That is
>> because WORD matches almost everything. However I thought that putting it
>> last would remedy the situation...it seems that the most general rule is
>> applied first. Is that by design?Am I going about it the wrong way?
>
> Nevermind I figured it out :) I can use the ordered-choice from the PEG
> extensions. This is good stuff...
>
>> also, I'd like to pass a function instead of a regex in the DRUG rule. I'd
>> like to have it check a dictionary instead of matching a regex. Is that at
>> all possible?
>
> I'm still not very clear about this though. Any help is greatly appreciated
> :)
>
> Jim

Perhaps remove DRUG from the grammar and use the transform function on
a parse-result to do something like

(insta/transform {:WORD (fn [w] (if (...) [:DRUG w] [:WORD w]))} parse-result)

so [:DRUG w] is emitted for whatever criteria you may have (lookup)
when matched, otherwise [:WORD w] to retain the original content.

Lars Nilsson

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to