These are chat archives for picoe/Eto.Parse

4th
Sep 2015
I see Index and Length
but doesn't see Line
(and position)
Curtis Wensley
@cwensley
Sep 04 2015 02:23
ah, whoopsie.. I haven't committed that yet. d;
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 02:23
The same in the ErrorMessage property of GrammarMatch class
Curtis Wensley
@cwensley
Sep 04 2015 02:25
hm, I should really do a few updates to Eto.Parse. I was starting to work on an AST builder
which would be really cool to get poco's out of a grammar match
having a baby really gets in the way of time for my open source projects..
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 02:29
how to write a rule to match any symbol (except specific)?
in EBNF
ISO version
Curtis Wensley
@cwensley
Sep 04 2015 02:30
? Terminals.Symbol ? - '?'
anything except ?
any symbol except ? that is
Curtis Wensley
@cwensley
Sep 04 2015 02:39
you can use any of the terminals from the Terminals class using ? Terminals.<name of terminal> ?
you can also register other extensions via the EbnfGrammar.SpecialParsers dictionary..
for example, if you want to use the StringParser, you can do: myEbnfGrammar.SpecialParsers["StringParser"] = new StringParser();
then in the grammar: My String Parser := ? StringParser ?
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 02:43
If I have errors during parsing - can i see upper parsers in the syntax tree (i.e. something like callstack) ?
I am talking about Errors collection
in GrammarMatch class
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 02:50
this is part of my grammar:
    dquote = '"' ;
    non_dquote = ? Terminals.Symbol ? - dquote ;
    backslash = "\\" ;
    specialsequence = backslash, dquote | backslash, backslash | backslash, "\n" | backslash, "t" | backslash, "b" ;
    sectiontitleunit = non_dquote | specialsequence ;
    sectiontitle = sectiontitleunit, {sectiontitleunit} ;
this is text of error message:
Index=0, Context=">>>/var/calculate/remote/distfile"
Expected:
space: Alternative
spaces: Sequence
lineseparator: Repeat: Char: Letter or Digit
backslash: Literal: '\'
letterrussian: Repeat: Char: Letter or Digit
Z: Repeat: Char: Letter or Digit
A: Repeat: Char: Letter or Digit
I don't understood which rules should I check (i don't see them in the list of parsers)
Curtis Wensley
@cwensley
Sep 04 2015 03:04
it's giving you a list of things that it is expecting.. for that particular instance, the backslash rule is what you are expecting, but it is a forward slash in the string you are passing
as for the grammar, it appears that Terminals.Symbol is not what you're looking for - that is all symbol characters.. e.g. !@#%^&*.. if you want any character, use Terminals.AnyChar
unless I'm misreading it
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 03:51
I see which rules it expects. I don't see the previous context. Which part of tree it is parsing during the error? I fixed grammar a bit, so this is new message:
Index=16, Context="[submodule "main>>>/external/cecil"]
    path = main"
Expected:
ABCDEFGHIJKLMNOPQRSTUVWXYZ: Repeat: Char: Letter or Digit
dquote: Literal: '"'
i see that it expects 2 things
but why these?
i expect to see something like <filecontent> -- <section> -- <subsection> -- <subsectionheader> -- <subsectiontitle> -- <sectiontitleunit> -- <non_dquote>
this is the file which i am parsing - https://github.com/mono/monodevelop/blob/master/.gitmodules
@cwensley so i think there is no "Parent" property for Match
Curtis Wensley
@cwensley
Sep 04 2015 05:24
@ArsenShnurkov, it doesn't appear that your grammar is expecting a forward slash at that point
raw_symbol_inside_quotes = ? Terminals.AnyChar ? - ( dquote | specialsequence | linecontinuation );
Terminals.AnyChar is here as you recommended
cwensley: how i should debug this?
Curtis Wensley
@cwensley
Sep 04 2015 05:29
subsectiontitleunit doesn't appear to be used?
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 05:32
cwensley: yes, ArsenShnurkov/mono-packaging-tools@184e203
but I am asking in general. I want to print all existing parsers from root
Curtis Wensley
@cwensley
Sep 04 2015 05:35
You can do that using the DisplayParserWriter.. e.g. Console.WriteLine(new DisplayParserWriter().Write(myGrammarOrParser));
Eto.Parse.Writers.DisplayParserWriter
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 05:39
it writes internal type names. Is it possible to output names from my grammar?
Curtis Wensley
@cwensley
Sep 04 2015 05:43
hm, it should write the rule names
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 06:56
no, it write only content of terminal symbols
Index=40, Context=" "main/external/cecil"]
    path >>>= main/external/cecil
    url = g"
Expected:
letterenglishlarge: Alternative
letterenglishsmall: Alternative
letterenglish: Alternative
digit: Alternative
I still don't understood how to debug why it requires letterenglish or digit.
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 07:03
for this state it shoud write the rule "variable_assignment = variablename, [ {separator}, "=", {separator}, variablevalue ] ;"
looks like it took the short form, and don't see the long form
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 07:49
i found one more error in the rule "variablename" - it was () brackets instead of {}, which means that variable names was limited to 3 symbols. But I am still at the same place with the same error message. (but now for another reason which I don't know)
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 11:49
The root of my problem is coming from not detecting \r \n
I don't understood, how to write Terminals.Set from .ebnf
lf = ? Terminals.Set("\0x0A") ? ;
cr = ? Terminals.Set("\0x0D") ? ;
doesn't compile
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 12:26
var myGrammar = ebnfGrammar.Build(myEbnfString, "filecontent"); gives myGrammar.Separator == null. But somehow the parser eats my spaces!!!
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 12:32
here is my simplified grammar:
filecontent = subsection , {  subsection } ;
subsection = section_start, { section_line } ;
section_start =  '[',  { ? Terminals.AnyChar ? - ']' },  ']' ;
section_line = { line_symbol };
line_symbol = ? Terminals.AnyChar ? - "[" ;
It removes spaces, when i told it nothing about this
Lost ~16 man hours on that...
ArsenShnurkov
@ArsenShnurkov
Sep 04 2015 12:43
Will start from scratch with code from README.md ( ws := {? Terminals.WhiteSpace ?}; and := for choosen rules )