Closed dongli closed 11 years ago
Hi @dongli!
Perhaps it is best to study this example? https://github.com/kschiess/parslet/blob/master/example/parens.rb
Cheers, Florian
Hi @floere
I saw that example, but haven't grabbed the main point. So I need to use Transform stuff to achieve this?
Thanks!
Li
BTW, I am writing a Fortran parser for my purpose.
Hi @floere! To my knowledge, the Transform should only post-process the parsing result, and couldn't help parsing. Is that right?
If you have time, could you check out my little parser (https://gist.github.com/dongli/5791976) by running:
rspec --fail-fast rspec_fortran_parser.rb
Cheers, Li
I should have been more specific: I was just noting an example where you can see a parser for balancing parentheses.
Your example above might be best served by str('a') >> str('b') | str('c')
– in words: either (|
) match an a
followed by a b
or a c
.
I used another strategy to accomplish parentheses balancing.
Hi,
I need to use
present?
andabsent?
to write atoms conditionally. The following is a test which does not work:with error output:
I write atoms this way in order to balance parenthesis, for example, if the left parenthesis is absent, the right one should be absent too.