This project has moved and is read-only. For the latest updates, please go here.

How can I match this?

Apr 9, 2012 at 3:30 PM


Given the following grammar, my intent is to match an unlimited occurrence of "a", unless the pattern is "aab" then reduce that to the "aab" rule. 


var document = new NonTerminal("document");
var inline = new NonTerminal("inline");
var a = new NonTerminal("a");
var aab = new NonTerminal("aab");

document.Rule =
  MakeStarRule(document, inline);

inline.Rule =
  | aab;

a.Rule =

aab.Rule =
  ToTerm("a") + "a" + "b";

Root = document;

When I attempt to parse "aa" I get an "Invalid character: 'a'" error.  What do I need to rearrange to get this to work accordingly?



Apr 10, 2012 at 5:45 PM

read this thread:

you need to use this flag if your terms follow each other without spacing or delimiters

Apr 11, 2012 at 4:49 AM
Edited Apr 11, 2012 at 5:58 AM

This matches "a" and "aab" but doesnt match "aa" as two inline a rules?

Effectively what I am trying to do is match a <space> character and unlimited number of times, unless the rule is <space> <space> <NewLine>

Any thoughts on how I can do this?



Apr 11, 2012 at 6:10 AM

does it show any conflicts in grammar errors page? In general, this is not a typical use for LALR parser, to parse elements without delimitors and spacing. These kinds of things are probably better handled by regex's. So I wouldn't be surprised if there's some unpredictable behavior. Is it a real life case of you're just playing with Irony? Did you look at using Regex instead?


Apr 11, 2012 at 8:08 AM

Hi Roman,

Thanks for your replies.

I am actually trying to parse Markdown, in particular the line break which occurs when you end a line with two blank spaces. I can create the line break as a Terminal rather than a NonTerminal and it works fine, so I will stick with that. I tried playnig around with adding a CustomAction to assist in the Shifting/Reducing, but the Terminal option is by far the easiest.