Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    ArsenShnurkov
    @ArsenShnurkov
    malformed_line := { malformed_line_unit } ; 
    malformed_line_unit := ? Terminals.AnyChar ? - '\n';
    
    > ast.Matches ["malformed_line", true].Matches[33]
    {
    }
        Name: "malformed_line_unit"
        Parser: {Eto.Parse.UnaryParser}
        Scanner: {Eto.Parse.Scanners.StringScanner}
        StringValue: "\n"
        Success: true
        Tag: (null)
        Text: "\n"
        Value: "\n"
    > 
    I don't understood how second rule matches '\n' character when i want it not to...
    ArsenShnurkov
    @ArsenShnurkov
    I tried to write
    cr := #x0D ;
    lf := #x0A ;
    in grammar - it doesn't parse the grammar then.
    ArsenShnurkov
    @ArsenShnurkov
    I also tried to take code directly from the text of standart -
    crlf := = { ? ISO 6429 character Carriage Return ? }, ? ISO 6429 character Line Feed ?, { ? ISO 6429 character Carriage Return ? };
    Curtis Wensley
    @cwensley
    I think it won't work because you are doing '\n', which is a C# escape sequence, which is not part of ebnf afaik.. using ? Terminals.Eol ? might work better.
    or if you have EbnfStyle.CharacterSets style set (not part of Iso14977), you can do: [#x13]
    CharacterSets are mutually exclusive with EbnfStyle.SquareBracketAsOptional, which is part of Iso14977.
    if character escapes are actually part of the standard, that'd be an easy fix by adding AllowEscapeCharacters = true to the terminal_string in the EbnfGrammar constructor.
    ArsenShnurkov
    @ArsenShnurkov
    I have no constructor (because I don't derive class, I use the existing one). And I don't see a way to add Parser into mygrammar object after it's construction
    So, I agree with you, that ISO is a standart which is not defining all details. But don't know what to do next.
    Curtis Wensley
    @cwensley
    no, this is in the Eto.Parse code, so it'd require a change there
    but the ? Terminals.Eol ? is what you could do
    ArsenShnurkov
    @ArsenShnurkov
    this is not the only character i want
    Curtis Wensley
    @cwensley
    or as I mentioned earlier, use the EbnfGrammar.SpecialParsers to define anything you want
    so.. ebnfGrammar.SpecialParsers["Woot"] = Terminals.Set("\r\n\tblah");
    then in your ebnf: ? Woot ?
    ArsenShnurkov
    @ArsenShnurkov
    yes, willl try this now
    Curtis Wensley
    @cwensley
    Terminals.Eol does match \r\n or \n btw
    Hm, I should add an EbnfStyle.EscapeStrings to allow for escapes in literals in ebnf though, it'd probably be very useful.
    It'd also allow for hex such as '\x013'
    Curtis Wensley
    @cwensley
    there we go
    ArsenShnurkov
    @ArsenShnurkov
    You are right, that Terminals.Eol is exactly what I need, but I can't use it because of NIH syndrome :)
    Curtis Wensley
    @cwensley
    haha
    that's a hard syndrome to overcome sometimes
    this is the error: Index=3, Context="
    nn>>>-nn
    ---n-n-
    "
    Expected:
    eol: EOL
    Curtis Wensley
    @cwensley
    hm that doesn't make sesnse
    *sense
    ArsenShnurkov
    @ArsenShnurkov
    what do you mean?
    or, what steps I should do to provide more details or to diagnose the problem ?
    I replaced nbody from 'n' to 'A', and replaced last '=' to ':=', nothing changes
    Eol does match
    (I mean the first eol in the C# string)
    ArsenShnurkov
    @ArsenShnurkov
    @cwensley And I can explain my NIH syndrome's source. I am not sure in '-' operator. I don't have successful experience with the construct := { ? Terminal.AnyChar ? } - { ? Terminal.Eol ? }
    Curtis Wensley
    @cwensley
    yeah that won't work
    cuz it'll find all AnyChar's first
    you need to do { ? Terminal.AnyChar ? - ? Terminal.Eol? }
    ArsenShnurkov
    @ArsenShnurkov
    one AnyChar will not match the 2-simbol sequence
    Curtis Wensley
    @cwensley
    all expressions in Eto are 'greedy'.. e.g. the { ? Terminal.AnyChar ? } will basically match the entire string
    ArsenShnurkov
    @ArsenShnurkov
    So, what to do about my nonworking example above
    ?
    (about syntax3.ebnf)
    Curtis Wensley
    @cwensley
    hm, not sure.. I'd have to debug it..
    I can't spot any problems at initial glance
    ArsenShnurkov
    @ArsenShnurkov