ohm
ohm copied to clipboard
CLI tool available?
I want to be able to run files and stdin through particular grammars and semantic operations that will generate files or print results to stdout. I've started building my own tooling for doing this with my own work, but wanted to check to see if something already existed and I didn't find anything in a cursory search through the repositories posted here.
Example:
cat model | run_operation RM_PGSQL toPostgreSQL > schema.ddl
Where RM_PGSQL
refers to a grammar and toPostgreSQL
refers to a semantic action (or derivative).
Does something like this exist, or is a common solution planned?
My apologies if I have missed something.
Hi Blake,
I think that's worth a shot and we could put something like that in bin
. There currently is a script in this directory - es5bench
- that does something similar: Parse dist/ohm.js
against the ES5 grammar and compile it to JS code (using examples/ecmascript/compile.js
). It's not a semantics but I don't see why it couldn't be.
I agree that it would be useful to have something like this!
On Thu, Mar 3, 2016 at 2:47 PM, mroeder [email protected] wrote:
Hi Blake, I think that's worth a shot and we could put something like that in bin http://../blob/master/bin. There currently is a script in this directory - es5bench http://../blob/master/bin/es5bench - that does something similar: Parse dist/ohm.js against the ES5 grammar and compile it to JS code (using examples/ecmascript/compile.js http://../blob/master/examples/ecmascript/compile.js). It's not a semantics but I don't see why it couldn't be.
— Reply to this email directly or view it on GitHub https://github.com/cdglabs/ohm/issues/71#issuecomment-192003144.
It looks like this was done.
$ npm install ohm-js -g
$ ohm-js $opts
No, it actually is still in the pipeline (something that takes grammar, semantics, operation/attribute name and input and processes it).
I also had a need for this, and recently released https://github.com/robertothais/ohm-cli.
It currently only supports validating grammars and recognizing inputs. I'd like to add support for semantic actions soon. Any feedback is welcome.
I'm going to close this as we now have an "official" CLI tool.