aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-11-20Throw error when a macro terminates while a local q-reg is edited.Robin Haberkorn1-14/+26
This is only a problem if the macro created the local Q-Register table (i.e. not when called with ":M") but resulted in segfaults. Since we do not want to save in a Q-Reg whether it is local (and that wouldn't suffice anyway), we do it in the Q-Register table cleanup. The corresponding QRegisterTable::clear() must be called explicitly, since the RBTree::clear() called on destruction does not and cannot throw errors. If QRegisterTable::clear() has been called successfully, the default object destructor will not do much. If it has thrown an error, the destructor will clean up the remaining Q-Registers.
2014-11-20throw error when macro returns with an unterminated commandRobin Haberkorn1-0/+13
it was not possible to inherit the parser state of the last command in a macro. However, it was possible to exit the macro when its last command was not properly terminated. There is no useful conscious application of this behaviour. * If something like an uncomplete E-Command was last in the macro, there was absolutely no effect. However this points to a macro programming error. * If the last command started a string parameter but did not terminate it, the command might be (partially) executed. However the State's done() method wasn't called, which means that some commands will not execute at all. Again there's no useful application of this. When on the other hand, the last command was not terminated by accident, this was not reported to the user.
2014-11-20allow a current buffer if we're editing a Q-RegisterRobin Haberkorn1-2/+2
this eases handling of the "*" register
2014-11-16cleaned up Scintilla document "updating"Robin Haberkorn1-4/+1
* allowed me to remove some obscure global functions and methods like QRegister::update_string(). * Document updating is concentrated in qregisters.cpp now * also fixes some bugs introduced earlier, like undo tokens being generated for non-undo registers (resulting in segfaults on rubout)
2014-11-16rewritten View and Interface base classes using the Curiously Recurring ↵Robin Haberkorn1-1/+2
Template Pattern. * without the one-view-per-buffer designs, many Scintilla send message (SSM) calls could be inlined * with the new design, this was no longer possible using the abstract base classes. the CRT pattern allows inlining again but introduces a strange level of code obscurity. * tests suggest that at high optimization levels, the one-view-per-buffer design and the CRT pattern reduces typical macro runtimes by 30% (e.g. for symbols-extract.tes). * only updated the NCurses UI for the time being
2014-11-16first working version of the one-view-per-buffer designRobin Haberkorn1-13/+13
The user interface provides a Scintilla view abstraction and every buffer is based on a view. All Q-Register strings use a single dedicated view to save memory and initialization time when using many string registers. * this means we can finally implement a working lexer configuration and it only has to be done once when the buffer is first added to the ring. It is unnecessary to magically restore the lexer styles upon rubout of EB (very hard to implement anyway). It is also not necessary to rerun the lexer configuration macro upon rubout which would be hard to reconcile with SciTECO's basic design since every side-effect should be attached to a character. * this means that opening buffers is slightly slower now because of the view initialization * on the other hand, macros with many string q-reg operations are faster now, since the document must no longer be changed on the buffer's view and restored later on. * also now we can make a difference between editing a document in a view and changing the current view, which reduces UI calls * the Document class has been retained as an abstraction about Scintilla documents, used by QRegister Strings. It had to be made virtual, so the view on which the document is created can be specified by a virtual function. There is no additional space overhead for Documents.
2014-11-14added ^# (XOR) operatorRobin Haberkorn1-0/+5
also changed precedence of + operator (higher than minus). the effects of this should be minimal
2014-11-11refactored SciTECO runtime errors: moved from parser.cpp to error.cppRobin Haberkorn1-84/+12
* the GError expection has been renamed to GlibError, to avoid nameclashes when working from the SciTECO namespace
2014-11-11added all of SciTECO's declarations to the "SciTECO" namespaceRobin Haberkorn1-0/+4
normally, since SciTECO is not a library, this is not strictly necessary since every library should use proper name prefixes or namespaces for all global declarations to avoid name clashes. However * you cannot always rely on that * Scintilla does violate the practice of using prefixes or namespaces. The public APIs are OK, but it does define global functions/methods, e.g. for "Document" that clashed with SciTECO's "TECODocument" class at link-time. Scintilla can put its definitions in a namespace, but this feature cannot be easily enabled without patching Scintilla. * a "SciTECO" namespace will be necessary if "SciTECO" is ever to be turned into a library. Even if this library will have only a C-linkage API, it must ensure it doesn't clutter the global namespace. So the old "TECODocument" class was renamed back to "Document" (SciTECO::Document).
2014-11-10clarified conditions when <;> should yield an errorRobin Haberkorn1-2/+11
2014-11-10support new "~" conditional: useful for implying default parameters in macrosRobin Haberkorn1-6/+17
2014-11-09current_doc_must_undo(): check for undo-necessity when operating on the ↵Robin Haberkorn1-12/+25
current document if the current document is a local q-register from a macro call, we must not generate undo tokens, since the local documents are discarded on macro termination.
2014-11-09documented EC and EG commandsRobin Haberkorn1-0/+3
2014-11-09added EG command: pipe from buffer into Q-RegisterRobin Haberkorn1-0/+1
2014-11-09implemented EC command (execute operating system command) in spawn.cppRobin Haberkorn1-0/+2
powerful command for filtering a SciTECO buffer through an external program. It will be described in the sciteco(7) man pages. The implementation uses an asynchronous background process with pipes but is platform independant thanks to glib's g_spawn functions, GIOChannels and event loops. There are however platform differences in how the operating system command is interpreted/parsed.
2014-08-02don't abort on unexpected semicolon (break from loop)Robin Haberkorn1-1/+3
the question remains what to do then. FIXME: consult TECO standard
2014-02-18removed unreliable CHR2STR() macroRobin Haberkorn1-7/+13
* referencing temporaries is unreliable/buggy in GNU C++, at least since v4.7 * in higher optimization levels it resulted in massive memory corruptions * this is responsible for the build issues (PPA build issues) * instead, always declare a buffer on the stack which guarantees that the variable lives long enough * the g_strdup(CHR2STR(x)) idiom has been replaced with String::chrdup(x)
2014-02-15updated Copyright to year 2014Robin Haberkorn1-1/+1
2014-02-15added State::StdError class for constructing errors from std::exception objectsRobin Haberkorn1-5/+7
2014-02-15use GLib's GError information to yield errorsRobin Haberkorn1-2/+3
* results in better error messages, e.g. when opening files * the case that a file to be opened (EB) exists but is not readably is handled for the first time
2014-02-15fixed Execute::macro() and Execute::file() exceptionsRobin Haberkorn1-4/+29
* might throw other exceptions that must be associated with the parent macro level's (stack frame) * add position information to "label not found" errors * Error copy constructors
2014-02-15removed most exception specifications: allow bad_allocs to propagateRobin Haberkorn1-15/+15
* specifications resulted in runtime errors (unexpected exception) when bad_alloc ocurred * specs should be used scarcely: only when the errors that may be thrown are all known and for documentary purposes
2014-02-15glib allocation functions throw std::bad_alloc exceptions now; catch all ↵Robin Haberkorn1-4/+11
bad_allocs and convert them to State::Error * will allow some degree of OOM handling * currently does not work since the exception specifications prevent bad_allocs from propagating. exception specification usage must be completely revised
2014-02-15String::get_coord() calculates line and column of a string positionRobin Haberkorn1-1/+16
* use to get line and column into a stack frame
2014-02-15added support for TECO stack tracingRobin Haberkorn1-14/+57
* when an error is thrown, stack frames are collected on clean up, up to the toplevel macro * the toplevel macro decides how to display the error * now errors in interactive and batch mode are displayed differently * in batch mode, a backtrace is displayed as a sequence of messages * Execute::file() forwards errors correctly * the correct error in the file is displayed in interactive mode * necessary to build the stack trace
2013-07-05only allow command-line replacements when actually editing the replacement ↵Robin Haberkorn1-0/+7
register I felt the urge to implement that after accidentally rubbing out my entire commandline (the work of an hour) just by pressing "}"...
2013-03-19rewritten CHR2STR() using compound statementRobin Haberkorn1-2/+2
* fixes compilation on g++ 4.7 where compound literals are suddenly temporaries (from which you cannot get a pointer) * the compound statement (also GCC extension) should ensure that the string is allocated on the stack with automatic lifetime
2013-03-18explicitly instantiate MicroStateMachine: fixes compilation with gcc-4.4Robin Haberkorn1-1/+1
2013-03-18remove all unused-attributes for parametersRobin Haberkorn1-1/+1
* compiler does not warn by default: this actually makes sense * so we don't need any unused-attributes * less GCC-extension based * on older GCCs I think -Wunused-parameters was enabled by -Wall we should add -Wno-unused-parameters if that's the case
2013-03-17^E\ string building character to format numberRobin Haberkorn1-14/+15
* new Expressions::format() * may be used format numbers as part of arrays (Q-Register names)
2013-03-16make success/failure conditional tests more consistent with the definition ↵Robin Haberkorn1-3/+9
of success/failure booleans * for the S and T conditions, nothing changes effectively (were testing for < 0 already) * the F and U conditions were testing for equality to zero which worked for condition booleans returned by commands but not for any failure condition (defined as >= 0) * may be different in classic TECOs but makes more sense IMHO
2013-03-16documented remaining commandsRobin Haberkorn1-2/+2
* flow control and other structures have not been documented this ways. I have not yet decided whether they should be documented in separate sections or use the documentation tool.
2013-03-16completed documentation of all commands in parser.cppRobin Haberkorn1-1/+220
* also updated sciteco(7): add SEE ALSO and AUTHORS
2013-03-16documented commands ending in StateStartRobin Haberkorn1-0/+311
2013-02-25EM...$ command to read macro from file and execute immediately (just like "M")Robin Haberkorn1-0/+1
* useful for using macro libraries
2013-02-22use typedef for SciTECO integers and make it configurable at configure timeRobin Haberkorn1-17/+17
* storage size should always be 64 (gint64) to aid macro portability * however, for performance reasons users compiling from source might explicitly compile with 32 bit integers
2013-02-16implemented command to query ASCII code of character (^^x)Robin Haberkorn1-0/+17
2013-02-14hide some implementation details in MicroStateMachinesRobin Haberkorn1-10/+7
2013-02-14use Q-Register micro state machine when parsing Q-Reg spec in ↵Robin Haberkorn1-38/+31
string-building commands * allows referring to long Q-Register names in string arguments * currently, long names specified this way use their own string building char parsing (I'm unsure whether this makes any sense)
2013-02-14rewritten string building state machine using a common MicroStateMachine ↵Robin Haberkorn1-100/+89
base class * uses label pointers instead of state-enum and switch case (both faster and shorter to write) * common interface for all micro state machines: makes them reusable
2013-02-08reverse Execute::step() change: no need to pass parameters by referenceRobin Haberkorn1-4/+2
cmdline and cmdline_pos is no longer modified by code executed by step() instead it is modified at the outermost macro level (commandline macro level)
2013-02-08use special Q-Register $ (<ESC>) to hold the replacement commandlineRobin Haberkorn1-24/+16
* allows us to switch between buffers/registers when editing the commandline
2013-02-08delegate commandline replacements ("}") to the cmdline macro levelRobin Haberkorn1-36/+18
allows commandline editing scripted by macros
2013-02-03first draft of commandline-editing commands ({ and } as in VideoTECO)Robin Haberkorn1-3/+75
* simplified traditional commandline editing. no need to extend cmdline string one character at a time when inserting multiple. instead there's a marker (cmdline_pos) specifying the macro length to execute in a "step" and also the anchor for generating undo tokens * implementation does not yet work in macro calls * while editing the commandline, other buffers/registers may not be edited (need push-down-list and auxiliary q-register)
2013-02-01fixed buffer Ring initializationRobin Haberkorn1-6/+11
* there was a dependency on interface initialization. it did not cause issues because destruction order was by chance. * introduced INIT_PRIO and PRIO_* macros to easy initialization order declaration (using a PRIO_* formula makes code self-documenting) * also used this to clean up QRegisterTable initialization (we do not need the explicit initialize() method) * also used to clean up symbols initialization
2013-01-23moved StateExpectQReg from parser.h to qregisters.hRobin Haberkorn1-28/+0
* parser.cpp|h should be reserved for generic and misc. stuff. the StateExpectQReg class is used almost exclusively by qregisters.cpp|h * resolves a circular header dependency issue
2013-01-23implemented special save last commandline command ("*" at beginning of ↵Robin Haberkorn1-0/+5
commandline macro) * only works as part of commandline macro, * at the beginning of other macros, it is treated like an arithmetic asterisk * variables defined in cmdline.cpp are now declared by new cmdline.h
2013-01-19updated copyright (2012-2013)Robin Haberkorn1-1/+1
2013-01-19allow <CTRL/C> to be typed; aborts last typed charRobin Haberkorn1-0/+3
* CTRL/C will be a command so it is important to be able to type it directly * aborting character processing is important because it allows aborting infinite loops * since the loop interruption currently relies on SIGINT handling, there is only limited support for XCurses and GTK - CTRL/C has to be typed in the terminal window. later support for input queue polling might be added
2012-12-04added copyright notice to every source fileRobin Haberkorn1-0/+17