1. A question about parsing
- Posted by axtens_bruce in March
- 554 views
So I'd like to create a command line tool that does its parameters the way docker does. I'm getting really tired with GUI planning tools and am designing a CLI one (so that I have TOTAL control).
task <title> (creates a task and returns an id) task <id> [dependson <id> ...] task <id> [tag <tag> ...] task <id> description <description>etc.
I suppose I'm asking for a formalised way of defining the DSL but I could do that with regexps. It'd be nice to be able to specify the syntax of the DSL to the extent of giving patterns and then having the underlying code either extract the arguments or notify of error.
task "Task Tool" description "Command-line task management tool" tag "cli" tag "euphoria" dependson "HavTim000" --> Created task "TasToo000"
Thoughts?
-Bruce
2. Re: A question about parsing
- Posted by petelomax in March
- 421 views
Hmm, I somehow missed this and just stumbled on it while looking for something else.
Are you asking/could you rephrase that as given this what's the best way to create this, where both this are text?
3. Re: A question about parsing
- Posted by axtens_bruce in March
- 421 views
So I've noticed that Euphoria has tools for defining and detecting commandline configuration. I'm wondering if there's something similar for DSLs, similar say to, but not as powerful, as a PEG parser.
At the moment, I'm using tokenize_string and pulling out the parts, viz
if length(cl) < 3 then inCli = 1 sequence parse = {} while 1 do cl = {} sequence cmd = prompt_string(prompt()) if equal("exit", cmd) then exit end if puts(STDOUT, "\n") sequence tokens = tokenize_string(cmd) parse = tokens[1] for i = 1 to length(parse) do cl = append(cl, parse[i][TDATA]) end for parse_pairs_from(1) end while end if
-Bruce
4. Re: A question about parsing
- Posted by jmduro in March
- 415 views
Once upon a time, I wrote a command-line parser: https://openeuphoria.org/forum/m/137017.wc
The code is not available at the specified location but I can provide it. Would this do the job ?
Jean-Marc
5. Re: A question about parsing
- Posted by ghaberek (admin) in March
- 412 views
I think you could accomplish this by defining a set of commands and options, then looking up the main command and dispatching it to cmd_parse() with the associated option set. I can try to throw together a few examples.
-Greg
6. Re: A question about parsing
- Posted by axtens_bruce in March
- 409 views
Don't spend too much time on it. I've done something like that already: task
-Bruce