Giter Club home page Giter Club logo

nearley-playground's People

Contributors

antimatter15 avatar bibliofile avatar bijection avatar indatawetrust avatar lusid avatar stefanmaric avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

nearley-playground's Issues

String output should not collapse whitespace characters

This behavior was the source of much headache and confusion for me, because I thought that my parser was the problem.

For example, this simple grammar:

Main -> "foobar" {% () => "this     has \n whitespace" %}

Produces this output in the test window:

"this has whitespace"

Freezing

Hi! I really like Nearley, and I was setting up some toy examples to teach others using the web browser playground app. But, it keeps freezing a lot. I fact, now it's freezing right away even with the most simple little grammars. What could be going on? The grammar is extremely simple in this case and it ran fine just moments ago. But now it does nothing but freeze, in chrome, in firefox, in private browsing.. yeah it just keeps freezing.

The script that is failing is:
http://omrelli.ug/nearley-playground/dist/client.bundle.js:20

What could be up?

Here's an example of a grammar I've put in when it's been freezing

MIDSOMER_MURDERS_PLOT -> LOCAL PROFESSION FOUND DEAD PLACE SUSPICION SUSPECT ANGRY BLAMED THREAT THREATENED
LOCAL -> "A local "
PROFESSION -> "linguist" | "philosopher" | "novelist"
FOUND -> " is found "
DEAD -> "drowned" | "strangled" | "dead" | "tortured to death" | "hanged" | "battered" | "suffocated" | "shot" | "knifed" | "nuked"
PLACE -> " in the coffee shop." |" in the swimming pool." | " after band practice."| " behind the primary school."
SUSPICION -> " Suspicion falls on the village "
SUSPECT -> "baker" | "pastor" | "mailman" | "florist" | "nerd" | "twins"
ANGRY -> ", angry that the "
BLAMED -> "new wind farm" | "pig" | "pub" | "decline in newspaper reading" | "metric system"
THREAT -> " might threaten "
THREATENED -> "the village fabric." | "what little sexual tension the village has left." | "the Old Inn." | "the cow farm."

It fails on line 20, but I don't know what the trouble is . I'm assuming copy-pasting in that bit of the script is not necessary (it's very large).

For some unknown reason, it now works in Chrome Incognito. I have done nothing different.

It can't select anything else but the first item for PROFESSION, so it's all linguists dying all the time (in this case). Unknown why, to me at least.

Output:

"A local linguist is found battered in the coffee shop. Suspicion falls on the village nerd, angry that the pub might threaten what little sexual tension the village has left."

“A local linguist is found shot after band practice. Suspicion falls on the village mailman, angry that the pub might threaten the Old Inn.”

"A local linguist is found dead after band practice. Suspicion falls on the village florist, angry that the decline in newspaper reading might threaten the village fabric.

Builtins don't work

Trying to use

@builtin "whitespace.ne"

causes

TypeError: __webpack_require__(...).readFileSync is not a function

Refresh tests after changing grammar

Is there an easy way to refresh the tests after changing the grammar? Right now it seems like you have to change the text of the test. Seems there are a few options:

  1. Refresh all when the grammar changes
  2. Add a refresh button to each test and a refresh all button somewhere above or below the list

I'll consider a PR for this if I find some more time but wanted to see if there was something already in the works or that I missed.

Crashes and teaching

I'm wanting to use the playground to teach context-free grammars to intro linguistics students. However, I'm often having problems with crashes myself and I'm worrying that the students will have too many problems.

a) which is the best browser to recommend them?
b) will clearing cookies be enough advice when it crashes?

I'm suspecting the crashing is because of some ambiguity, but sometimes it honestly crashes even with the simplest little grammar.

Feature Request: Test Cases For a Specific Nonliteral

As I develop a grammar, I'm specifying productions for many nonliterals. Each time I complete one, I want to test it before moving on to the next.

Currently, to do this I have to tinker with the "MAIN" nonliteral, so for example if I have:

Identifier -> ...
Integer -> ...
String -> ...

Then after finishing each of these I have to set

MAIN -> Identifier 
# and after I'm done testing Identifiers, change it to next one
MAIN -> Integer
# and the next
MAIN -> String

To test out each of these.

The feature request is that with each test-case entered, a way to specify another nonliteral which the test case is meant for.

Why are there no error messages?

Reporting intuitive error messages is an important feature of a professional parser.

It seems the playground does not show any error message or error location, just a simple color red or green to indicate success failure:

Does Nearly itself not support error reporting? Or is this just a limitation of the playground?

Grammars can cause infinite loops

bob -> bob | jill
jill -> "bob"

If you add a test with "bob", the page hangs. There should probably be something that catches grammars that seem to take too long to run, or to run the grammars on a webworker so it doesn't interrupt the user.

Importing moo to use as a lexer

Hey, love the playground! Super handy for testing stuff out. However, I've gotten to the point in my grammar testing that I'd like to introduce a lexer to the code, but I'm not sure how to do that. In your examples, you use require, which is a node.js thing, so I don't believe it will work in the browser. Supporting that, is that when I do use require, the console reports the following error:

Uncaught ReferenceError: require is not defined
    at eval (eval at get_exports (tester.js?3b08:26), <anonymous>:7:16)
    at eval (eval at get_exports (tester.js?3b08:26), <anonymous>:223:3)
    at get_exports (tester.js?3b08:71)
    at Tester.render (tester.js?3b08:41)
    at eval (ReactCompositeComponent.js?063f:795)
    at measureLifeCyclePerf (ReactCompositeComponent.js?063f:75)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js?063f:794)
    at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?063f:821)
    at ReactCompositeComponentWrapper._updateRenderedComponent (ReactCompositeComponent.js?063f:745)
    at ReactCompositeComponentWrapper._performComponentUpdate (ReactCompositeComponent.js?063f:723)

I've tried messing with ES6 imports a bit but can't seem to get it to work. That one yields a different error message:

Uncaught SyntaxError: Unexpected identifier
    at get_exports (tester.js?3b08:71)
    at Tester.render (tester.js?3b08:41)
    at eval (ReactCompositeComponent.js?063f:795)
    at measureLifeCyclePerf (ReactCompositeComponent.js?063f:75)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js?063f:794)
    at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?063f:821)
    at ReactCompositeComponentWrapper._updateRenderedComponent (ReactCompositeComponent.js?063f:745)
    at ReactCompositeComponentWrapper._performComponentUpdate (ReactCompositeComponent.js?063f:723)
    at ReactCompositeComponentWrapper.updateComponent (ReactCompositeComponent.js?063f:644)
    at ReactCompositeComponentWrapper.receiveComponent (ReactCompositeComponent.js?063f:546)

The above is produced when using import moo from "moo", import lexer from "myLexer" and import lexer from "myLexer.js" with the "myLexer.js" script in the same dir as the other default grammars such as sentence.ne and arithmetic.ne.

So that brings me to the solution the two possible solutions:
Either the functionality to import a lexer is available, and I'm just not sure how to do it in the playground, or
import functionality is not available, and I'd like for support for it to be added in.

Though, at this point, it might be worth my time moving away from the playground for my development purposes. It was very useful for getting started! Thanks again! Let me know if I can provide any more info, etc. etc.

Literally the best thing ever

Hey! I'm the guy who made nearley, and I just stumbled onto your work here. This is amazing!

People have been asking for something like this since the beginning of time (see issues #106, #37, #68, #142, #78 on the issue tracker…). Would it be okay if I put links to nearley-playground on nearley.js.org, and also on the README?

Thanks! (And once again, this is so cool.)

Add an option to expand more stuff in the parse tree display

Underneath each test there is a parse tree display which we have to expand one structure at a time, but I generally want to expand lots of stuff and it would be nice if there was a way to expand everything, or all children of an element, or down one level, or something faster than clicking on each triangle one at a time.

Awesome project, super useful!

rendering a lot of outputs to DOM causes browser and computer to freeze

example

MAIN -> "a":+:+:+

test with "aaaa" and add "a" one by one.

note:

  • it freezes the page and some times the computer
  • it uses alot of ram and hard disk

cause

this problem caused by rendering a lot of elements to the DOM.

solution

I think it could be fixed by limiting the outputs to 100 item

.then(outputs => this.setState({outputs}))

.then(outputs => this.setState({outputs: outputs.slice(0, 100)})) 

thank you 👍

CodeMirror Mode

Hi @bijection! Playground is still lookin' fine :-)

@Hardmath123 and I were wondering if you'd thought of publishing the CodeMirror mode included here as a separate package? Might be useful for building future tools, who knows... No particular project in mind right now though!

Cheers.

Allow importing/exporting of test cases individually or by importing/exporting a tab

You can save the grammar to a file, but you are unable to save the test cases to a file(s).

What would be nice is to allow importing/exporting a tab in the playground as a zip file where the grammar and each individual test case is contained in the zip file. In addition, it would be nice to include a nodejs console app in the zip file that would require the grammar and take zero or more test dataset names on the command line, then it would produce a pass/fail for each test case, e.g., a simple test runner. Test datasets would be plain text files.

👍 kudos for putting the playground together!!

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.