Hi all,

I'm starting to get the hang of instaparse and it just looks awesome! However there is a little thing that bugs me....I may be doing it wrong that why I'm asking here. The behaviour that I want sounds reasonable at least to me...so here is an example:

(insta/parser
   "S  = TOKEN (SPACE TOKEN)* END     (*any full sentence*)
   TOKEN = NUM | DRUG | PK | MECH | SIGN | EFF| NEG*| WORD*
   <WORD> = #'\\w+'
    NUM =  #'[0-9]+'
    ADV =   #'[a-z]+ly'
   <SPACE> = #'\\s+'
    DRUG =  #'(?i)didanosine|quinidine'
    PK = #'(?i)exposure|bioavailability|lower?[\\s|\\-]?clearance'
    MECH =  #'[a-z]+ed'
    EFF =  SIGN? MECH | MECH SIGN?
    SIGN =  ADV | NEG
    NEG = 'not'
    END =  '.' " ))

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?

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?

many many thanks,

Jim


--
--
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