regex identifier

Jun 23, 2010 at 3:56 PM
Edited Jun 23, 2010 at 3:57 PM
I'm working on making a grammar for sparql to validate queries. This means I also need to validate IRI (Internationalized Resource Identifier) references, which are like URIs or URLs. Here's an example of a valid IRI ref: <http://purl.org/dc/elements/1.1/title>. I'd like to make an identifier in Irony for IRI refs that is defined by a regular expression. Is there a [n easy] way to do this?
Coordinator
Jun 23, 2010 at 4:05 PM
There's a RegexBasedTerminal there, try it
Jun 23, 2010 at 4:17 PM
oh cool! thanks! Another question: RegexBasedTerminal( string name, string pattern, string[] prefixes ) I don't quite understand what prefixes are for.
Coordinator
Jun 23, 2010 at 6:30 PM
these are any specific fixed strings that may start your terminal - if any. In your case it would probably be "<"
Jul 8, 2010 at 3:28 PM
Edited Jul 8, 2010 at 3:38 PM
I'm sorry this is kinda an old thread, but I have a problem with the RegexBasedTerminal. I want to define a identifier like so:

var identifier = new RegexBasedTerminal("[0-9a-zA-Z\\.]+");

The problem with this (I think) is that I can't go on to say that this identifier cannot be a key word. I have an unary operator (the only unary operator in the grammar) that is defined like so:

var notOp = new NonTerminal("not operator");
notOp.Rule = ToTerm("not");

But if I try to parse the text "not"... the 'not' gets recognized as an 'identifier'! I've spent hours trying to fix this. Any ideas? I'd be happy to post my whole grammar here if it helps.
Coordinator
Jul 8, 2010 at 5:20 PM
Don't declare "not operator" non-terminal, use "not" directly, but mark it as reserved word: MarkReservedWord("not"); or smth like this, don't remember exact syntax, you'll figure it out