My Fellow Monks,
I am attempting to create a mini-language to allow users to set when certain events are marked on a calendar. (This is primarally used for repeated events... eg every thursday kinda things). I have come up with the base concept for what I want the language to look like, but I'm having difficulty coming up with something and then parsing it.
Samples:I'm attempting to parse this with Parse::RecDescent, and I think I'm on the right track, but it's behaving funny (or I don't know how to use it properly.)
use Parse::RecDescent; use strict; use warnings; my $grammar = qq~ RecTest: ExpSet(s) ( Expression | SubExp ) | Expression | SubExp | <error> Expression: ELEMENT COMPARE ELEMENT ExpSet: ( Expression | SubExp ) JOIN SubExp: '(' (ExpSet(s) Expression | Expression) ')' ELEMENT: 'h' COMPARE: /(?:=(?![><]=))?[><]=?/ | '!=' | '=' JOIN: /and/i | /or/i | /xor/i ~; my $parser = new Parse::RecDescent($grammar) or die; print $parser->RecTest('(h = h and h != h) and ((h > h or h < h') or d +ie;
When I run this, it prints out ')', which is not entirely useful but implies that it is succeeding, I think... The problem is, it should NOT be succeeding with those arguments because the parentheses are unbalanced, so I assume I made some mistake, but I don't really understand the syntax well enough to know where. Also, I'm having a hard time figuring out how to do anything with what it attempts to parse (so I can actually evaluate what they want and determine if it occurs on any given day).
Perhaps I'm going about this wrong, if so, I'm open to other ideas. Thanks for any help or advice you can give.
Note: This is my first time even seriously looking at Parse::RecDescent.My code doesn't have bugs, it just develops random features.
In reply to Parse::RecDescent and mini-language parsing by Flame
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |