idea grammar-kit recoverWhile beaks the parser on the first element in list











up vote
0
down vote

favorite












I have a bnf grammar:



{
tokens = [
COLON = ":"
space=' '
word = 'regexp:[^rnst@${}()|#:<>]+'
nl = 'regexp:r|n|(rn)'
]
}

root ::= nlsp book_keyword COLON [space] book_title sections
book_keyword ::= 'Journal Book' | 'Fiction Book'
book_title ::= (! section (word | string) space?)+

sections ::= section+

section ::= nlsp section_keyword COLON [space] section_title {recoverWhile='sectionRecover'}
section_keyword ::= 'Section' | 'Content'
section_title ::= (!section (word | space | COLON))+

sectionRecover ::= !(nlsp| section_keyword)

nlsp ::= (NL| space)*


Text to test:



Fiction Book: Some Fiction
Section: Chapter One
Section: Chapter Two Section
Content: Chapter Three


If I make an error in second or later element all be ok, but if in the first Sectio: Chapter One all psi tree will be broken.



enter image description here










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a bnf grammar:



    {
    tokens = [
    COLON = ":"
    space=' '
    word = 'regexp:[^rnst@${}()|#:<>]+'
    nl = 'regexp:r|n|(rn)'
    ]
    }

    root ::= nlsp book_keyword COLON [space] book_title sections
    book_keyword ::= 'Journal Book' | 'Fiction Book'
    book_title ::= (! section (word | string) space?)+

    sections ::= section+

    section ::= nlsp section_keyword COLON [space] section_title {recoverWhile='sectionRecover'}
    section_keyword ::= 'Section' | 'Content'
    section_title ::= (!section (word | space | COLON))+

    sectionRecover ::= !(nlsp| section_keyword)

    nlsp ::= (NL| space)*


    Text to test:



    Fiction Book: Some Fiction
    Section: Chapter One
    Section: Chapter Two Section
    Content: Chapter Three


    If I make an error in second or later element all be ok, but if in the first Sectio: Chapter One all psi tree will be broken.



    enter image description here










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a bnf grammar:



      {
      tokens = [
      COLON = ":"
      space=' '
      word = 'regexp:[^rnst@${}()|#:<>]+'
      nl = 'regexp:r|n|(rn)'
      ]
      }

      root ::= nlsp book_keyword COLON [space] book_title sections
      book_keyword ::= 'Journal Book' | 'Fiction Book'
      book_title ::= (! section (word | string) space?)+

      sections ::= section+

      section ::= nlsp section_keyword COLON [space] section_title {recoverWhile='sectionRecover'}
      section_keyword ::= 'Section' | 'Content'
      section_title ::= (!section (word | space | COLON))+

      sectionRecover ::= !(nlsp| section_keyword)

      nlsp ::= (NL| space)*


      Text to test:



      Fiction Book: Some Fiction
      Section: Chapter One
      Section: Chapter Two Section
      Content: Chapter Three


      If I make an error in second or later element all be ok, but if in the first Sectio: Chapter One all psi tree will be broken.



      enter image description here










      share|improve this question













      I have a bnf grammar:



      {
      tokens = [
      COLON = ":"
      space=' '
      word = 'regexp:[^rnst@${}()|#:<>]+'
      nl = 'regexp:r|n|(rn)'
      ]
      }

      root ::= nlsp book_keyword COLON [space] book_title sections
      book_keyword ::= 'Journal Book' | 'Fiction Book'
      book_title ::= (! section (word | string) space?)+

      sections ::= section+

      section ::= nlsp section_keyword COLON [space] section_title {recoverWhile='sectionRecover'}
      section_keyword ::= 'Section' | 'Content'
      section_title ::= (!section (word | space | COLON))+

      sectionRecover ::= !(nlsp| section_keyword)

      nlsp ::= (NL| space)*


      Text to test:



      Fiction Book: Some Fiction
      Section: Chapter One
      Section: Chapter Two Section
      Content: Chapter Three


      If I make an error in second or later element all be ok, but if in the first Sectio: Chapter One all psi tree will be broken.



      enter image description here







      parsing grammar intellij-plugin bnf grammar-kit






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 4:28









      Viktor Sidochenko

      137114




      137114
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I see several problems:
          1) you should have whitespace token. Something like this:



          WHITESPACE="regexp:[ nrtf]"


          as a consequence, you don't need space and npsp anymore



          2) recoverWhile rule should be specified without quotes



          3) sectionRecover matching whitespaces which most likely is incorrect






          share|improve this answer





















          • It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
            – Viktor Sidochenko
            Nov 21 at 8:33













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368325%2fidea-grammar-kit-recoverwhile-beaks-the-parser-on-the-first-element-in-list%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          I see several problems:
          1) you should have whitespace token. Something like this:



          WHITESPACE="regexp:[ nrtf]"


          as a consequence, you don't need space and npsp anymore



          2) recoverWhile rule should be specified without quotes



          3) sectionRecover matching whitespaces which most likely is incorrect






          share|improve this answer





















          • It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
            – Viktor Sidochenko
            Nov 21 at 8:33

















          up vote
          0
          down vote













          I see several problems:
          1) you should have whitespace token. Something like this:



          WHITESPACE="regexp:[ nrtf]"


          as a consequence, you don't need space and npsp anymore



          2) recoverWhile rule should be specified without quotes



          3) sectionRecover matching whitespaces which most likely is incorrect






          share|improve this answer





















          • It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
            – Viktor Sidochenko
            Nov 21 at 8:33















          up vote
          0
          down vote










          up vote
          0
          down vote









          I see several problems:
          1) you should have whitespace token. Something like this:



          WHITESPACE="regexp:[ nrtf]"


          as a consequence, you don't need space and npsp anymore



          2) recoverWhile rule should be specified without quotes



          3) sectionRecover matching whitespaces which most likely is incorrect






          share|improve this answer












          I see several problems:
          1) you should have whitespace token. Something like this:



          WHITESPACE="regexp:[ nrtf]"


          as a consequence, you don't need space and npsp anymore



          2) recoverWhile rule should be specified without quotes



          3) sectionRecover matching whitespaces which most likely is incorrect







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 11:48









          Argb32

          71247




          71247












          • It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
            – Viktor Sidochenko
            Nov 21 at 8:33




















          • It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
            – Viktor Sidochenko
            Nov 21 at 8:33


















          It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
          – Viktor Sidochenko
          Nov 21 at 8:33






          It is space care grammar, so I've disabled whitespace feature. BTW, it is not fixes scope mess. As I can see the first section element is covered only by root level and not entered in sections anymore. This behavior is valid for only 1st element in sections.
          – Viktor Sidochenko
          Nov 21 at 8:33




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368325%2fidea-grammar-kit-recoverwhile-beaks-the-parser-on-the-first-element-in-list%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Ottavio Pratesi

          Tricia Helfer

          15 giugno