Menu

#5 __parse() should return %% of the top rule

open-accepted
None
5
2010-05-17
2009-07-30
No

Currently __parse() returns an error count. There is no clean way to return %% from the top rule to the __parse() caller. The only way is to use an ugly global variable. And this makes parsing non thread safe.

Instead __parse() could return an object containing:
- src: the parsed string
- errors: the error list
- result: %% of the top grammar rule
For an attempt to implement this around the current (0.30) JS/CC generated code, see http://registry-files-tools.googlecode.com/svn-history/r3/trunk/msreg.par

Discussion

  • Olivier Mengué

    Olivier Mengué - 2009-07-30
    • labels: --> 1037902
     
  • beachcoder

    beachcoder - 2010-05-17
    • labels: 1037902 -->
    • assigned_to: nobody --> beachcoder
    • status: open --> open-accepted
     
  • beachcoder

    beachcoder - 2010-05-17

    This is a good idea, especially because ECMAScript is typeless.

     
  • Philippe Rathe

    Philippe Rathe - 2010-11-08

    I also need this behavior.

    The code generated should have a namespace and everything could be inside.
    Then a call that could look like this:

    JSCC.parse('my string to parse')

    would return what the parser returned as the top rule.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.