SLabuz95 / TclToTextFileGenerator

0 stars 0 forks source link

Tcl Interpreter Engine Review + Redesign #33

Closed SLabuz95 closed 2 years ago

SLabuz95 commented 2 years ago

Tcl Interpreter Engine Review should verify contradictions between Tcl Interpreter Engine devoloped for TclToTextFileGenerator and original Tcl language by code analysis. Redesign will change how the engine works. All contradictions should be written down and fixed.

SLabuz95 commented 2 years ago

Scope

In this review, all procedures, which are called by events related to state events. State events are generated by detection of keywords.

Review

General Information

All changes are based on concepts and terminologies from following documentation referance: Summary of Tcl language syntax. All states and way of processing Tcl scripts shall be changed based on informations from above documentation reference.

Tcl Interpreter Stats

Description

Tcl Interpreter Stats can be described with the following attributes:

  1. Parent - can have childrens (other stats),
  2. Child - can be child of other stat,
  3. Processing - has method to process event related to the stat,
  4. Prodromic - confirms occurance of an event for other processing states,
  5. Pending - stat which is kept to perform all processing operations caused by events, stat has start and end events.

CommandSubbing and other related stats

All stats which are not similar to CommandSubbing (stats which do not perform any operation on ProcedureCalls, arguments control, etc.) shall be specified before CommandSubbing enum value (value less then CommandSubbing). All stats related to CommandSubbing (stats which perform any operation on ProcedureCalls, arguments control, etc.) shall be specified after CommandSubbing.

CommandSubbing and other related stats Control

Command Subbing description

DoubleQuotes description

DoubleQuotes is interpreted as Braces until VariableSubbing or CommandSubbing occurs. If so, new ProcedureCall is created with defined for DoubleQuotes stat rules. Additionally,if last parameter of ProcedureCall is Word,then ,for every word or stat interpreted as word, last parameter shall be appended.

Stats filtering while processing stats in Interpret methods

In all processing methods (Interpret methods) shall perform filtering of stats. If stat value is greater or equal then CommandSubbing value, then return CommandSubbing value.

Stat Word

Description

Attributes:

Tcl Interpreter stat Word replaced old stat UnknownString. To process all to characters, which dont contain keywords (strings which have been ignored while keywords detection (between keywords/events)).

Stat VariableSubbing

Description

Attributes:

Tcl Interpreter stat VariableSubbing replaced old stat Variable. Contains reference (by name) to variable, which has been written after VariableSubstitution sign $.

Stat CommandSubbing

Description

Attributes:

Implemantation of Namespace in Tcl (Sign ::)

Description

For any keyword "::", throw an error.

Issue: Check whitespace only while calling callInterpretFunction Method.

Description

Whitespace control

Check whitespace occurance by method, not by variable. Update whitespaceOccurance flag only in callInterpretFunction method with checkWhitespace method.

Algorithm

graph TD
WhitespaceResult[/"whitespace = (stat of lastSavedStat == Stat::Whitespace)"/] -->CheckWhitespace
CheckWhitespace{whitespace} --True--> removeLastSavedStatError[/"return result of removeLastSavedStat()"/]
CheckWhitespace --False--> returnNoError["return Error::NoError"]

CallInterpretFunction method redesign

CallInterpretFunction shall check whitespace occurance. CallInterpretFunction shall take 1 default argument (Stat = Stat::Size). If Stat is not Stat::Size (not default), then add to Stat to processingStats.

Algorithm

graph TD
CheckWhitespace["checkWhitespace()"] --> statCheck{stat != Stat::Size}
statCheck --True-->  addProcessingStat["append processingStats with stat"]
addProcessingStat --> callInterpretFunction["call interpret function for last processing stat"]
statCheck --False--> callInterpretFunction

Issue: Change way of processing UnknownString

Description

ProcessUnknownString method redesign

In processUnknownString method, call method callInterpretFunction with argument Stat::Word.

Interpret method redesign

In initialization, read UnknownString value. Dont use SavedStat.

Issue: FunctionReady flag should not be used in SavedStat

Description

FunctionReady flag should not used in SavedStat, cause this flag relates to FunctionCalls, not to SavedStat. FunctionReady probably will not be used in new implemantation of TclInterpreterEngine.

Issue: CAPLCommand type and variable in SavedStat should be changed to Command

Description

Generated data can be used for any type of file, not only CAPL scripts.