New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deploy it from the commandline? #506
Comments
So you want to create a command line tool that use's the .peg you created and validate files based on a command line parameter. am i right? for ex: |
@jodevsa That's what I'm trying to achieve..! |
The generated tldr.js is just a general library invoked by parse function, you gotta write a program that does this ! 1- read the file PEG.js generated library function definition:
extract data from the file you want and use parser(fileContent) ! |
If you're using Node, here's a more concrete example:
Maybe it would be helpful to have an app that does that more generally. |
@mikeaustin Clearly this isn't the easiest way for him to understand what you did
|
@mikeaustin I don't seem to have What I am after is a generalized node script that I could call like: Or, if pegjs could optionally output a script that incorporates |
@jodevsa Thanks!
So I added
I guess my javascript-fu is not strong enough... |
@pepa65 i updated the code, check it again |
@pepa65 i'm using node v 8.0.0 , if another error pop's out just replace each "let" and "const" with var |
@pepa65
|
|
weird, javascript doesn't even contain a "printf" function; even older versions |
O, sorry, reviewing my peg, I saw that I had wrongly added
|
@pepa65 That's because the running script that @jodevsa gave you logs the result of running the peg grammar; because your top-level You can either change the Hope that helps! |
Right, silly of me. Makes it easier! I think I got things to where I can proceed. Thank you all! |
I guess, as a summary to those who come here looking for the final answer, use this script, perhaps call it
Do |
Looks good! Thanks for making a more complete example, @jodevsa. I was assuming he knew JavaScript. But that kind of brings up the idea that people may want to use PEG.js without even knowing JavaScript at all. I think it would be handy to provide a program that can generically read a grammar and input file, and output to a file or standard output. |
Shall this issue be reopened, then? |
@mikeaustin @waldyrious perhaps instead of making a separate "program" - this can just be mentioned in the readme? With an example of implementing such a thing. |
Feel free to use the working example above..! |
@mikeaustin's comment suggests that a separate program does have a convenience benefit for end users, and I agree with that. |
@waldyrious This issue was a question, I'm going to open a new issue for what @mikeaustin suggested, one that should see the feature implemented for 0.11 (if it's a simple addition with no problems), but might be pushed to 1.0 (if it raises some error's, I'll push it back to sort out later). Should be simple to implement though after I'm done with the command line tool rewrite. Sorry @pepa65 for not replying earlier, but to be honest with you, until @waldyrious posted his comment today, I didn't even know the issue existed 😆 |
I made a .peg file (online) that validates. I would like to use in at home on the commandline. I installed pegjs from the Ubuntu 16.04 repos. I did
pegjs tldr.peg
and it produced atldr.js
file.How do I use that on the commandline? I have files I'd like to check.
The text was updated successfully, but these errors were encountered: