Git Product home page Git Product logo

jams's People

Contributors

complected avatar dmfxyz avatar nmushegian avatar raddy avatar stobiewan avatar trouaux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jams's Issues

Clarify spec / tests on how to handle escapes

JSON libraries manually handling escapes will check the character after a '' to make sure it is a valid escape, eg '\' '\r', '\n', '\t' '\b', or a valid unicode escape. This kind of escape handling passes the current JAMS test suite. However, you can also pass the tests by simply blindly including anything following a '\' inside a quote string, without checking for a valid escape. Opening issue to request clarification on how best to handle in JAMS.

exhaustive string casetests

  • you can test all bareword pass cases with one test like { ok !@#$....}
  • you need a distinct fail case for each bad bareword character maybe like { bad st[ring }
  • you can test all pass cases for quoted strings with one test like { ok " ... " }, include all variations of all escapes and whitespace
  • do quoted strings even have fail cases? If all undefined \ are defined to pass through, then you can't have an invalid string? at worst you terminate the string early with "?

Make failing file-based tests

To keep our sanity this time around let's try to stick with file-based tests as much as possible
For that we need a fail folder to correspond to pass folder where we put files that are supposed to fail to parse

It is important to make sure they are failing due to JAMS parse error and not some other reason, and that 'failing failures' are not squelched

toJAMS

Duh

let’s also have a better interface than toJSON maybe put optional args into named opts

Finish string grammar

jams/jams.js

Lines 3 to 14 in 78e1459

// TODO: Here is the exact string grammar from JSON.
// It needs to be modified to escape unicode rather than utf16.
// It should be split into 2 char classes, those that need to be quoted,
// like []"{} and whitespace, and those than do not require quotes.
/*
string ::= '"' ( ( [#x20-#x21] | [#x23-#x5B] | [#x5D-#xFFFF]
) | #x5C ( #x22 | #x5C | #x2F | #x62 | #x66
| #x6E | #x72 | #x74 | #x75 HEXDIG HEXDIG HEXDIG HEXDIG
)
)* '"'
HEXDIG ::= [a-fA-F0-9]
*/

Prohibit duplicate keys at parse time

JSON spec does not say what to do if there are multiple keys and different parsers do different things.

In JAMS, duplicate keys are defined to be invalid JAMS files, they should not parse. Note this technically changes which kind of language/grammar JAMS is (not LL1 anymore I think) but it doesn’t matter

Manual parser with better errors

This will let us drop ebnf and also have comprehensible error messages
We might be able to dump the generated parser (function built at runtime) out of ebnf library somehow for guidance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.