> Thanks for your comment. I changed the rule(:term) as you suggested and my > "1 + 2 " expression was parsed. Unfortunately, the parser did not generate > the plus-operator. > Then I added the .as(:plus) in the rule and the parser showed the > plus-operator. >
Ok. Once you start using .as, anything you *didn't* use it on gets thrown away; parslet assumes that since you didn't ask for it, you don't need it. 99% of the time, that's a hugely useful thing as it filters out a lot of the chaff from your parse tree. > My lesson learned is that I have to experiment with Parslet as like a game > just to discover the parsing rules and the (hidden?) features. Anyhow, I'm > glad that this forum provides me the answers I needed. > It's all in the docs on the website. I think there were a couple of things that I discovered from the rdoc doco, but that's it. The problem is, there's a lot to take in, so you need to read it a good few times. The problem you describe above, for example, is covered in the docs. cheers ant
