[TransWarp] fmtparse - recursive grammar
alex at ank-sia.com
Fri Jun 20 16:09:30 EDT 2003
Phillip J. Eby wrote:
> At 03:16 PM 6/16/03 +0400, Oleg Broytmann wrote:
>> My first attempt was unsuccsessful.
Oleg gave up on using fmtparse and i took the baton from him. i read
the papers on packrat parsing, and i found TDPL very attractive. i am
very much interested in working parser engine for TDP grammars.
> openingChars is used to tell a preceding item at the same rule level
> what its terminators are. So if I have a rule that's like
> Sequence(Named('foo'), ',' Named('bar')), the openingChars of ',' is
> ',', and we take the 'withTerminators()' of Named('foo') so it has the
> chance to take the ',' terminator into account.
as far as i uderstand, the terminators are used only to break the
greedyness of MatchString. and the only real provider of openingChars
is StringConstant. am i right?
also i see that you have reversed the flow of the parsing: the papers on
packrat parsing show right-to-left parsing, starting from the end of the
string. but fmtparse does left-to-right parsing. i suppose this was
done in order to utilize the regexp engine. i do not mean that there is
something wrong; i just want to ensure that i understand things right.
i propose to use the Input object to keep track of the rules being
applied. since Input.parse is called from each non-trivial Rule.parse,
i think there will be no problems in memorizing the rule before calling
rule.parse. then, a rule having need in terminators could request them
from it's envelope Sequence via the Input object. this wold allow the
lazy evaluation of the terminators at the time when they are really needed.
what do you think?
ps. i am going away for 4 days, so i will not be able to follow this
thread till wednesday.
More information about the PEAK