New syntax mechanism - tracking issue
Project: | JNode Core |
Component: | Code |
Category: | task |
Priority: | normal |
Assigned: | Stephen Crawley |
Status: | closed |
Jump to:
I have just committed the initial release of the new command syntax mechanisms. I've thoroughly tested that the old mechanisms (both old-style command parsing and completion) are working properly. However, if there are any show-stopper problems, please feel free to revert revision 3844 which contains all of the changes.
I would encourage people to do a 'svn up' and take a look at the new code. The guts of the new syntax mechanism is in the new org.jnode.shell.syntax package, and I've written a suite of unit tests.
So far, I have just converted one existing command: SetCommand. If you look at it, you will see that the old "static Help.Info help" is no longer there. Indeed, the command class no longer defines the command-line syntax at all. Instead, it declares a bunch of XxxArgument objects that will act as holders for argument values, and "registers" them in the constructor.
The command-line syntax is specified in XML in a new plugin extension point; see the org.jnode.shell.command.xml plugin descriptor for the syntax for the set command. Note that the syntax is associated with the alias name, rather than the command class. The syntax information is read from the plugin extension by the DefaultSyntaxManager class.
If you delve into the code, you will see that the XxxSyntax classes that have a 1-to-1 correspondence with the syntax elements in the plugin descriptor. The MuXxxxx classes represent the lower level BNF-like syntax that is used for parsing. The XxxSyntax classes "prepare" themselves into MuXxxxx classes, and the MuParser class parses the CommandLine against the MuSyntax, binding values to the XxxArgument objects, and performing full backtracking if required. The layering allows for a rich repertoire of Syntax constructs while keeping the Mu-level parsing code fairly simple.
Tasks that remain to be done include:
- Extending the MuParser, etc to support command completion.
- Converting more command classes, and define the corresponding syntax descriptors in the relevant plugin files.
- Implementing more XxxArgument classes.
- Writing JNode "book" pages ...
I would really appreciate any constructive feedback that will allow me to improve on what I've done so far.
- Login to post comments
#1
Revision #3859 is an overhaul of the completion mechanisms. The old version of the completion code could only cope with completion alternatives coming from one Syntax. If multiple Syntaxes matched the partial command-line, one was chosen heuristically. The new version of the code gathers the completions for all matching syntaxes and offers them to the user. It also fixes a couple of minor regressions.
In order to do this, it was necessary to change the CompletionInfo data structure and the interactions between the various parties; the console, command shell, interpreter, command line, syntax and argument. Instead of returning the completed command line, the 'complete' methods take a CompletionInfo as an argument, and add any completions to it as they are found. The whole lot get returned to the console layer which edits the completion into the command line.
The end result is that the code is a lot easier to understand, and we don't have that nasty callback into the command shell to deal with the case where one argument has multiple completions.
I do not believe I've introduced any new bugs / regressions. But if I have, there is just one checkin to revert.
Next I'm going to look at / fix the completion bugs I've noticed on the way.
#2
Since the last update, I have fixed some old completion bugs in the "redirecting" interpreter, improved completion for new-style syntaxes, and fixed a regression in the behavior of the "thread" and "proclet" invokers when the user provided command arguments that don't match an (old-style) syntax.
Next I will be tracking down a problem I noticed in the "default" invoker and changing the shell's default invoker to "proclet" so that secondary consoles behave better by default.
#3
After a lot more testing, I've change the initial invoker for the command shell to be ProcletCommandInvoker. This should fixing some of the strange behavior of the output streams when you use a secondary console; e.g. using console -n, leed or GUI-based console.
The revision for this change is #3919. As always, if the change is problematical, please roll back to the previous revision.
#4
Here's a summary of recent changes, in no particular order:
#5
I've created a new "syntax" command for dumping and loading new-style syntax specs as XML. So it is now possible to develop and test new syntaxes while JNode is running. You can also override the syntax specs defined in the JNode plugin descriptors ... for the current shell.
I'll write a Book page for the command tomorrow. Until then, "help syntax" should give you the basics.
#6
The Book pages are starting to take shape. Let me know what you think.
#7
Latest bulletin:
#8
Progress:
Work to be done:
#1
Progress:
#2
There are no immediate plans to do further development. So I'm marking this as fixed. Feel free to open new Feature Requests and Bugs.
#3
Automatically closed -- issue fixed for two weeks with no activity.