Replies: 3 comments
-
gah. It should be wsdelim_string = ~(((data_token | save_token) + ZeroOrMore(anp)) | loop_token) + OneOrMore(anp) shouldn't it.... |
Beta Was this translation helpful? Give feedback.
-
Use `CaselessKeyword` instead of `CaselessLiteral`, and pyparsing will verify that you only match “data_” and not “data_1” or “data_set” or “data_that_i_downloaded_from_the_internet”.
I also scanned that document, and there is a lot of BNF around quoted strings. I think if you use the new pyparsing `python_quoted_string` builtin, it will cover all the bases (and you won’t need the single-quote, etc. pieces).
From: Matthew Rowles ***@***.***>
Sent: Friday, July 7, 2023 10:39 AM
To: pyparsing/pyparsing ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [pyparsing/pyparsing] Best interpretation of this BNF grammar? (Discussion #494)
I'm trying to implement this piece of grammar <https://www.iucr.org/__data/assets/text_file/0009/112131/CIF2-ENBF.txt>
# { } : ZeroOrMore
# ( ) : a group
# | : or
# - : exception: it matchs group on it's left, but not on its right.
# , : concatenation
wsdelim-string = ( alphas, { alphas } ) - ( ( ( data-token | save-token ), { alphas } ) | loop-token ) ;
So far, I've got
# alphas as per pyparsing
data_token = CaselessLiteral("data_")
save_token = CaselessLiteral("save_")
loop_token = CaselessLiteral("loop_")
wsdelim-string = OneOrMore(alphas) + ~(((data_token | save_token) + ZeroOrMore(alphas )) | loop_token)
But I don't thing that's right.
Essentially, I want to match a group of one or more chars, unless they match something like data_somechars, or save_, in which case, I want the rule to fail.
—
Reply to this email directly, view it on GitHub <#494> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAC5XAZPP7JWKKUHO7VHJMLXPAUQVANCNFSM6AAAAAA2B7GVUI> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/AAC5XA7RIMSFBTMK2S5V5DDXPAUQVA5CNFSM6AAAAAA2B7GVUKWGG33NNVSW45C7OR4XAZNKIRUXGY3VONZWS33OVJRW63LNMVXHIX3JMTHAAUQSM4.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
I'm using your quote builtins for those. They are very useful. I need |
Beta Was this translation helpful? Give feedback.
-
I'm trying to implement this piece of grammar
So far, I've got
But I don't thing that's right.
Essentially, I want to match a group of one or more chars, unless they match something like
data_somechars
, orsave_
, in which case, I want the rule to fail.Beta Was this translation helpful? Give feedback.
All reactions