Coder Social home page Coder Social logo

grammkit's People

Contributors

barnardb avatar brettz9 avatar dundalek avatar larshp avatar ldegen avatar mo-ba avatar mykmartin avatar sramam avatar stonecypher 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grammkit's Issues

Generate SVGs as separate files

Just a suggestion, but GrammKit might be more useful if SVGs were generated as separate files from <output>.html. They could still be included in the output file, but then people who wanted to use them differently (say by linking to them, possibly out of order, in a README) could easily do so.

Uncaught TypeError: Cannot read property 'usedBy' of undefined

Hi! Many thanks for this excellent work!

Bug report and suggested fix:

  • I observed an exception when diagramming the following PEG:
          start = num
          num = [0-9]+
          whtspace = ([ ]+)
  • Exception observed
    Uncaught TypeError: Cannot read property 'usedBy' of undefined
  • Origin
    Unused rule in given grammar: whtspace
  • To reproduce
    • Navigate to Grammkit's online editor
    • Paste offending grammar snippet into text box.
    • Exception will appear in the browser's web console (Chromium, in my case).
  • Suggested fix: Include typeof guards
    • In app/app.js::87

      // Currently
      {references[rule.name].usedBy.length > 0 && <div>
      
      // Replace by
      {typeof references[rule.name] !== "undefined" && references[rule.name].usedBy.length > 0 && <div>
      
    • In app/app.js::92

      // Currently
      {references[rule.name].references.length > 0 && <div>
      
      // Replace by
      {typeof references[rule.name] !== "undefined" && references[rule.name].references.length > 0 && <div>
      

Hope this helps! Keep up the good work!

Any reason why Grammkit fails with a valid grammar?

Hi again.

I'm trying to run a couple of grammars through Grammkit, and they seem to be failing for some reason.

I've attached one of the file I was testing.

Oddly enough, I can't get it to work here either:

https://dundalek.com/grammkit/

It looks valid enough, so I'm a bit stuck.


tcl-statement ::= begin-transaction
                | set-transaction
                | savepoint
                | rollback-transaction
                | commit-transaction


begin-transaction ::= ( 'BEGIN' | 'START' ) ( 'WORK' | 'TRAN' | 'TRANSACTION' )
                      ( 'ISOLATION' 'LEVEL' 'READ' 'COMMITTED' )?

set-transaction ::= 'SET' 'TRANSACTION' 'ISOLATION' 'LEVEL' 'READ' 'COMMITTED'

savepoint ::= 'SAVEPOINT' savepointname

rollback-transaction ::= 'ROLLBACK' ( 'WORK' | 'TRAN' | 'TRANSACTION' )?
                       ( 'TO' 'SAVEPOINT' savepointname )?


commit-transaction ::= 'COMMIT' ( 'WORK' | 'TRAN' | 'TRANSACTION' )?

savepointname ::= identifier

Please update npm

Fixing the ohmjs dep is great, except that if I install from GH, I get the same problem 😆

Would you be kind enough to bump and push to NPM please?

Install on windows

Hi, I would like to know how to install it in window 10, show me this mistake:
error

Cannot read property 'type' of undefined

Hi,
I am running into an issue after upgrading from 0.3.1 to 0.6.3.
Most of my grammar still works, but GrammKit chokes on one particular rule.
I modified the example from README.md to reproduce the problem:

var grammkit = require('grammkit');
var parse = require('pegjs/lib/parser').parse;

var grammar = parse('Atom "_atom"\n  = !\'AND\' !\'OR\' !\'NOT\' [^\\t\\n\\r ()]+ { return text().trim();}');
console.log(grammkit.diagram(grammar.rules[0]));

This produces the following error:

…/node_modules/grammkit/lib/rd-optimize-loops.js:4
  if (node.type === 'Sequence') {
           ^

TypeError: Cannot read property 'type' of undefined
    at traverse (…/node_modules/grammkit/lib/rd-optimize-loops.js:4:12)
    at Array.map (<anonymous>)
    at traverse (…/node_modules/grammkit/lib/rd-optimize-loops.js:45:33)
    at Array.map (<anonymous>)
    at traverse (…/node_modules/grammkit/lib/rd-optimize-loops.js:45:33)
    at Array.map (<anonymous>)
    at traverse (…/node_modules/grammkit/lib/rd-optimize-loops.js:5:31)
    at Array.map (<anonymous>)
    at traverse (…/node_modules/grammkit/lib/rd-optimize-loops.js:45:33)
    at diagramRd (…/node_modules/grammkit/lib/diagram.js:6:10)

I'll try to dig a bit deeper, but maybe you already have an idea?

Cheers,
--lu

Does not support ! pegjs operator

On your example site if you load the JavaScript grammar we have

ExpressionStatement
  = !("{" / FunctionToken) expression:Expression EOS {
      return {
        type:       "ExpressionStatement",
        expression: expression
      };
    }

and the diagram looks like
screen shot 2017-09-10 at 8 16 34 pm

As far as I understand, that is an invalid railroad diagram.

Investigate how `parse-ebnf` is included

I'm trying to package GrammKit up for NixOS using node2nix, and while I can build GrammKit fine, when I try to run the executable I get this error:

[~/code/mine]traveller@nivian $ ./GrammKit/result/bin/grammkit GrammKit/examples/sparql.ebnf 
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open './lib/parse-ebnf.pegjs'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Object.<anonymous> (/nix/store/9srzg40jrjbrsn952j4lc9zcbsn2rxqp-node-grammkit-0.5.0/lib/node_modules/grammkit/cli.js:14:36)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)

Is it possible that ./lib/parse-ebnf.pegjs needs to be mentioned somewhere in the package.json file? I think that's what node2nix uses to generate the Nix package.

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.