Grammer/Parser question

Dec 8, 2008 at 11:31 AM
Hi,

can somebody help me in solving this Proplem.
I need to parse a Statement like this:

Derived From
    Class: Klasse0
    Class: Klasse1
Class Variables

 

 

 

 

I useed the following Rule:

derived.Rule = _class+colon + identifier;
derived_list.Rule = MakePlusRule(derived_list, derived);
derived_list_opt.Rule = Empty | derived_list;
derived_header.Rule = _derived + _from + derived_list_opt;

Now It seems that Class from "Class Variables", will be recognized as member of derived_list.

How solve that problem.

Thanks in advance

Wolfram

 

Coordinator
Dec 8, 2008 at 3:57 PM
Edited Dec 8, 2008 at 4:32 PM
How parser should recognize the fact that Variables is not class name?
Is your language indentation sensitive, so it recognizes that derived list is over because there's no indentation on this line? In this case you should use CodeOutllineFilter token filter, and add Indent, Unindent terminals into grammar rules.  
If your language is not indentation sensitive and "Variables" is a keyword, so class name cannot be Variables, then try to add "Variables" to the list of keywords:
 this.AddKeywords("Variables");

By the way, you can create derived_list_opt directly:
derived_list_opt.Rule = MakeStarRule(derived_list_opt, derived);
Dec 9, 2008 at 10:46 AM
Thanks for you're reply.

first I was hopefull that I can use -->Class:<--  as Symbol so that it's different to -->Class<--,
but you're presumption is correct. That language is indent based so I did as you advised
But I have to say without any success.

I break down already with the first line I want to parse.

Functional Class: TEST 
    Description: ddsfsd

NonTerminal functional_class_header = new NonTerminal("functional_class_header");
functional_class_header.Rule = _functional + _class +colon + identifier;

description_comment.Rule =
Grammar.Indent + _description + colon + identifier + Grammar.NewLine;
TokenFilters.Add(new CodeOutlineFilter(true));

 

 

ErrorMessage from Grammar Explorer:

Syntax error. (parser state: S11)
 (L:C = L0:C23)

Sorry I do not know how to handle this.

Wolfram

Coordinator
Dec 9, 2008 at 3:12 PM
Looks like you forgot NewLine at the end of functional_class_header; something is missing - where is this.Root assignment? what is a root element of the grammar?  
Dec 10, 2008 at 3:35 PM
I have decided to club the Termional "Class" and "Variables" together so that I get the terminal = ClassVariables.
So the parser can see a difference. I think  it's possible to use the indent technique later on, when I'm more familiar with irony.net.

thanks.