ohm icon indicating copy to clipboard operation
ohm copied to clipboard

CLI tool available?

Open blakelapierre opened this issue 8 years ago • 5 comments

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.

blakelapierre avatar Mar 03 '16 22:03 blakelapierre

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.

mroeder avatar Mar 03 '16 22:03 mroeder

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.

alexwarth avatar Mar 03 '16 22:03 alexwarth

It looks like this was done.

$ npm install ohm-js -g
$ ohm-js $opts

justinmchase avatar May 03 '16 17:05 justinmchase

No, it actually is still in the pipeline (something that takes grammar, semantics, operation/attribute name and input and processes it).

mroeder avatar May 03 '16 18:05 mroeder

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.

robertothais avatar Feb 19 '18 17:02 robertothais

I'm going to close this as we now have an "official" CLI tool.

pdubroy avatar Nov 06 '22 16:11 pdubroy