diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-11-30 19:26:16 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-11-30 19:26:16 +0100 |
commit | e4d5a995a037ae938d08480359a53dc097deec21 (patch) | |
tree | 22008b9228eee017c86a2eb8b4ca0772c2c953c9 /src/parser.h | |
parent | 8460f925248b99e94169bbfa9f2645de677f2e27 (diff) | |
download | sciteco-e4d5a995a037ae938d08480359a53dc097deec21.tar.gz |
allow dollar sign as another variant of ^[ (discard all arguments or return)
* some classic TECOs have this
* just like ^[, dollar works as a command only, not as a string terminator
* it improves the readability of macros using printable characters only
* it closes a gap in the language by allowing $$ (double-dollar) and
^[$ as printable ways to write the return from macro command.
^[^[ was not and is not possible.
* since command line termination is a regular interactive return-command
in SciTECO, double-dollar will also terminate the command line now.
This will be allowed unless it turns out to be a cause of trouble.
* The handling of unterminated commands has been cleaned up by
introducing State::end_of_macro().
Most commands (and thus states) except the start state cannot be
valid at the end of a macro since this indicates an unterminated/incomplete
command.
All lookahead-commands (currently only ^[) will end implicitly
at the end of a macro and so will need a way to perform their action.
The virtual method allows these actions to be defined with the rest
of the state's implementation.
Diffstat (limited to 'src/parser.h')
-rw-r--r-- | src/parser.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser.h b/src/parser.h index 3356600..a7059a9 100644 --- a/src/parser.h +++ b/src/parser.h @@ -66,6 +66,17 @@ public: */ virtual void refresh(void) {} + /** + * Called at the end of a macro. + * Most states/commands are not allowed to end unterminated + * at the end of a macro. + */ + virtual void + end_of_macro(void) + { + throw Error("Unterminated command"); + } + protected: static bool eval_colon(void); @@ -209,6 +220,8 @@ private: tecoBool delete_words(tecoInt n); State *custom(gchar chr); + + void end_of_macro(void) {} }; class StateControl : public State { @@ -233,6 +246,8 @@ public: private: State *custom(gchar chr); + + void end_of_macro(void); }; class StateFCommand : public State { |