Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Terminals as regular expresions #8

Open
versae opened this Issue · 4 comments

2 participants

@versae

I need to build a grammar from user inputs, and I was trying to do something like this

parsley.makeGrammar("d = '{test}'".format(test="TeSt"), {})("TeSt").d()

But having {test} case insensitive, so I tried the next

parsley.makeGrammar("d = '(?i){test}'".format(test="TeSt"), {})("TeSt").d()
parsley.makeGrammar("d = (?i)'{test}'".format(test="TeSt"), {})("TeSt").d()

But none of them worked. Is there any way to achieve that?

@versae

Any update on this?

I almost got it working using this ugly rule

import re
parsley.makeGrammar("d = anything*:x !(re.compile('(?i){test}').match(''.join(x)) and ''.join(x))".format(test="TeSt"), {"re": re})("TeSt").d()
@washort
Owner

having an re() rule that took a regular expression could be interesting. let me know what you come up with :)

@versae
@versae

Any advance on this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.