Hello PyParsers,
I'm new to pyparsing and to this list; thanks for this module and for a
way to at last get parsing logic out of my head and written down in the
form of BNF. Its been driving me crazy!!!
The project that I'm working on involves representing signed languages
with character strings. Some aspect of a 'sign' is represented by a 1,
2, or maybe 3 character long string, which we refer to as a 'marker'. A
complete 'sign' would be represented by a character string in excess of
20 or 30 characters, composed of these individual 'markers'. We have
around 300 markers defined. I'm trying to write a parser to tokenize a
complete string into these individual markers.
I was wondering, if I have a partial sign string, is there a
straightforward way to get a listing back of the next possible markers
(tokens) ? I'm thinking that I could just pass in a list of all markers
and see which ones matched, but there must be a better way!
Also, is there a way to represent the logic that I want to match up to 4
characters from a possible 4, but I don't want any repeats? In context,
I have:
finger ::= , | : | ; | !
I want to be able to match up to a maximum of 4 fingers (not all need to
be included), but I don't want any repeats, either adjacent to each
other or within the matched group. One solution is as follows, but I was
wondering if anyone could suggest a better way:
index ::= Literal(",")
first ::= Literal(":")
middle ::= Literal(";")
little ::= Literal("!")
hand ::= ([index][first][middle][little])+max=4
(although each individual finger is optional, I need to match at least
one finger, up to a mzimum of 4)
Thanks for any help or suggestions.
Best regards,
Tim Grove
|