These are chat archives for picoe/Eto.Parse

8th
Sep 2015
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 06:31
Is it possible to add such error message into parsing process? (i.e. add a method, which will check the absent rules, which may be called before calling Parse? )
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 07:09
something like
public static class GrammarExtensions
{
    public static void CheckAbsentRules(this Grammar grammar)
    {
        foreach (var rule in grammar.Children()) {
            if (grammar.Contains (rule) == false) {
                throw new NotImplementedException ();
            }
        }
    }
}
doesn't work
because I don't understood something about model
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 08:21

Now I have 2 grammars:
first one uses build-in space processing and parses as expected - https://github.com/ArsenShnurkov/mono-packaging-tools/blob/rmsub/mpt-gitmodules/bnf3/syntax1.ebnf
it parses successfully, but gives a wrong structure (on the identical text content)
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 08:34
my questions are: 1) what is wrong with second grammar; 2) what i need to do to understand it without your help
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 08:50
more metagrammars to your collection - XBNF, BS6154 ( http://www.csci.csusb.edu/dick/samples/comp.text.Meta.html )
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 09:34
I think that this fragment
subsection := subsection_header, [ [ws], list_of_body_units ] ;
list_of_body_units := variable_line, { [ws], variable_line } ;
variable_line :=  "_variable_";
doesn't work as expected
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 10:14
BSI (British Standards Institution). BS 6154:1981 Method of defining — syntactic metalanguage. 1981. ISBN 0-580-12530-0
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 11:03
"list_of_body_units := [ws], variable_line, { [ws], variable_line } ;" doesn't eat all variable lines. Instead of that rule "file_content := { [ws], section }, [ws];" starts a new section each time.
"space_between_sections" matches instead of "space_after_subsection_header"
what to do to change this ?
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 11:39
but mine earlier grammar with automatic spaces works as expected. So, no more ideas.
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 11:47
I have a hypotesis, that your parser somehow reuses whitespace rule internally, and this lead to it's confusion.
So, I think it's bug of your parsing engine, or bug in my code when I didn't give it some setup parameters.
Curtis Wensley
@cwensley
Sep 08 2015 15:56
hm, not sure I'm following exactly what the problem you're running into is.. do you have a simple example?
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 16:08
Hi, I think the example is simple. I can retell the story in short
I defined a grammar. It worked well with default space processing
Then I switched space processing off, and define rule "ws := ..." the grammar stops working
then I implement space processing as separate rules, and the same grammar start work again
this leads to conclusion that engine have a bug in rule processing
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 16:16
I think that last 2 gramars are identical, but engine thinks differently
you can checkout the whole solution, it contains almost no another code
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 16:23
The problem is that I don't understood why changing last variant to previous variant breaks the parsing
parsing start give wrong treee
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 19:06
So, i decided to reduce the sample to absolute minimum. In the process of simplification I found a bug in grammar. Now it works as expected.
wrong code was
ws := ws_unit | {ws_unit} ;
instead of
ws := ws_unit , {ws_unit} ;
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 19:13
Will continue to grow the grammar to the complete one.
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 19:28
@cwensley How to check the grammar for nondefined symbols ?
Curtis Wensley
@cwensley
Sep 08 2015 19:32
do you mean you want to find unused rules? To find all used rules, grammar.Children.Distinct(), anything that isn't used won't be in the generated grammar.
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 19:41
I mean - if inside rule i used a symbol, but not defined it later
 rule1 := rule2, rule3; rule2 := "A"; 
and there is no rule 3, but I don't know about this
I want the program to show me them
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 19:53
Oh, I completed parsing my original test file according to complete spec. That was painfull
Curtis Wensley
@cwensley
Sep 08 2015 19:55
I'm open to suggestions/contributions that make it less painful. (;
I don't think there's a way currently to figure out if you're using a rule that isn't defined elsewhere using the EbnfGrammar.. It would be a good candidate for adding a new github issue for
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 20:05
done - picoe/Eto.Parse#26
Curtis Wensley
@cwensley
Sep 08 2015 20:19
great, thank you!
ArsenShnurkov
@ArsenShnurkov
Sep 08 2015 20:21
Now I have second part of quest, with 2 parts. First part is to build AST using your object model, and second part is to provide Line/Offset info instead of position in file
may be not an AST, but my model
since I have eol literal in grammar, I can build the list of all it's occurences and use it for translation of positions to line/offset