dundalek / grammkit Goto Github PK
View Code? Open in Web Editor NEWGenerate diagrams for parser grammars
Home Page: http://dundalek.com/GrammKit/
License: The Unlicense
Generate diagrams for parser grammars
Home Page: http://dundalek.com/GrammKit/
License: The Unlicense
The idea is that it cleans up diagrams by removing all the _
and __
space matchers (and any other rules that start with _).
Would you be interested in a PR?
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.
Hi there.
I'm trying to integrate Grammkit with AsciiDoctor, and I have run into a snag or two. Is there a forum where I can ask questions?
Hi! Many thanks for this excellent work!
Bug report and suggested fix:
start = num
num = [0-9]+
whtspace = ([ ]+)
Uncaught TypeError: Cannot read property 'usedBy' of undefined
whtspace
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!
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
Hello,
When I enter https://raw.githubusercontent.com/fuhrmanator/GIFT-grammar-PEG.js/master/GIFT.pegjs as the grammar on dundalek.com/GrammKit it gets morphed to https://cdn.rawgit.com/fuhrmanator/GIFT-grammar-PEG.js/master/GIFT.pegjs
Is this normal?
I was looking for a way to link to a RR diagram of my grammar from my readme (ideally even show the diagram there). I know it worked some years ago. Cheers!
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?
In lib/rd-optimize-loops.js lodash is required, but package.json does not have the name lodash.
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
Is it possible to specify the grammar file to be loaded using query parameter? It's easier to share links that way.
How about adding an option to diagram the entire syntax in terms of its start and terminals? Sometimes it's helpful to see the entire grammar all at once.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.