Leo now supports the importer;; abbreviation. It creates an @@file node containing an almost complete line-oriented importer for a new language. I'll be adding to it soon, but it's more than good enough as it is.
The checkin log discusses hacks to Leo's abbreviation code needed to support importer;; These changes should not affect existing abbreviations in any way. They merely add the ability to make script substitutions in headlines. Nevertheless, these changes might have changed Leo's abbreviation handling in unexpected ways. Please report any problems immediately.
Importance
The importer;; abbreviation is a huge step forward, for several reasons:
1. The abbreviation almost completely eliminates the need for endless soporific instructions about how to create a new importer. Instead of reading blah-blah-blah about cassettes and such, devs will just run the abbreviation. Everything will be created for them.
Note: Below are full instructions for running importer;; That's almost all that is needed in the way of docs!
2. importer;; will be of great practical use to me as I go about converting the remaining 14 importers. I have spent about 8 hours already on the importer;; abbreviation and needed tweaks to Leo's abbreviation code. Nevertheless, it will likely soon pay off handsomely. And even if it doesn't, using the abbreviation will be a whole lot more fun than doing the same thing over and over again.
3. Perhaps most importantly, importer;; should remove much of the sheer terror that might otherwise confront devs in the future ;-)
Enabling the abbreviation
As mentioned in the checkin log, to make importer;; functional you must:
1. Copy it from leoSettings (@settings-->Abbreviations-->@outline-data tree-abbreviations) to the corresponding location in myLeoSettings.leo.
2. Make sure @bool scripting-abbreviations is True in myLeoSettings.leo.
Using the abbreviation
1. Just type importer;; in the body pane of an empty node.
A dialog will prompt you for the name of the language. Suppose you type x.
2. Now you will be prompted for to fill in the first field:
'extensions': [comma-separated lists of extensions, with leading periods],
The italicized field will be highlighted. Type '.x' (including quotes) followed by two commas.
3. You will then be prompted to fill in the second field:
strict = True leading whitespace is significant. Otherwise False,
Again, the italicized field will be highlighted.
Type False, followed by two commas.
4. You will then be prompted for the last field:
return level
### Examples:
# self.indent # for python, coffeescript.
# self.curlies
# (self, curlies, self.parens)
Only "level" is highlighted. The comments provide some hints about what to type.
Let's type "self.curlies" followed by two commas.
5. Nothing more is highlighted, so that's it! No more substitutions remain. The outline is ready to use!
Take a look at the result. The new tree is an almost complete @@file node for the importer. Subtrees contain an X_Importer class and an X_ScanState class. Docstrings, ctors and __repr__ methods are complete.
Note: The generated tree contain ### comments showing where more work may be needed. I might remove the need for some of them, but there is no great need to do so.
None of this would have been possible without Terry Brown's initial implementation of script substitutions in abbreviations. Thanks again, Terry.
Edward
P.S: importer;; will soon generate x.get_new_table, and perhaps a one or two other nodes. It's very easy to make such changes!
EKR