Contents
Component IDETclParser
comment:This component provide classes for parsing und syntax check of
xotcl/tcl source code.
The base Classes are PrsContext and TclParser
For Parse a xotcl method use
set context [PrsContext new]
$context parseAndCheck $wholeMethodBody
if {[$context hasErrors]} {
puts [$context errors]
}
The Parser (TclParer) build a parse tree form tcl base element
PrsElement (Root)
The Checking funktionality is programed in Class PrsContext
Classes
Classes Hierarchy
Class MixPrsList
parameter: list
subclasses:
PrsQuoted
PrsCommandSubst
PrsNoSubst
PrsCommand
Instprocs:
- addElem {elem}
- getElem {index}
- visit {visitor}
Class PrsCommand
superclasses:
PrsElement
MixPrsList
Instprocs:
- argsCount {}
- checkSyntax {context notifier}
- syntaxHightlight {context}
Class PrsCommandSubst
superclasses:
PrsElement
MixPrsList
Instprocs:
- evalContents {}
Class PrsComment
superclasses:
PrsElement
Instprocs:
- syntaxHightlight {context}
Class PrsContext
parameter: {variables {}} parser errors warnings
subclasses:
PrsSyntaxHightlight
comment:The class has very important rolle by parsing xotcl/tcl sources.
In this methods are coded the meaning (syntax) of all build-in tcl functions
as loops and conditional.
The context handle/store such context information
1. where the code ist (xotcl method, tcl proc)
2. know variables
Instprocs:
- addError {text elem}
- addVariableFrom {prsObject}
- addVariableFromList {prsObject}
- checkCommand {command notifier}
- checkDirectObjectCall {object command notifier}
- checkObjectCall {command notifier}
- checkObjectMethodArgsCount {object type method command notifier}
- checkObjectSelfCall {command notifier}
- checkProcArgsCount {command procName notifier}
- checkTclCommand {name command notifier}
- checkVariable {variable}
- checkVariableFrom {prsObject notifier}
- handleForCommand {command notifier}
- handleForeachCommand {command notifier}
- handleIfCommand {command notifier}
- handleRegexpCommand {command notifier}
- handleSwitchCommand {command notifier}
- hasErrors {}
- parse {script}
- This Method parse a text and build a parse tree
It return 1 on success
- parseAndCheck {script}
- parseAndVisit {script}
- visit {obj}
Procs:
- getCommandDescription {name}
- initializeAfterLoad {}
Class PrsElement
parameter: begin end
subclasses:
PrsLiteral
PrsQuoted
PrsCommandSubst
PrsNoSubst
PrsVariable
PrsCommand
PrsComment
Instprocs:
- basicEvalContents {}
- basicSubstituteContents {}
- checkAsList {context notifier}
- checkSyntax {context notifier}
- evalContents {}
- extractList {}
- getParser {}
- printString {}
- prsString {}
- substituteContents {}
- syntaxHightlight {context}
- visit {visitor}
Class PrsLiteral
superclasses:
PrsElement
Class PrsNoSubst
superclasses:
PrsElement
MixPrsList
Instprocs:
- evalContents {}
- extractList {}
- substituteContents {}
Class PrsQuoted
parameter: {hasQuote 0}
superclasses:
PrsElement
MixPrsList
Instprocs:
- substituteContents {}
- syntaxHightlight {context}
Class PrsVariable
superclasses:
PrsElement
Instprocs:
- checkSyntax {context notifier}
- syntaxHightlight {context}
- visit {visitor}
Class ReadStringStream
parameter: string pos lastpos
comment:This class wrap a string to use it as a stream.
Additional you can set the last position (end of stream)
Instprocs:
- addPos {add}
- atEnd {}
- copyFromTo {from to}
- getChar {}
- init {}
- length {}
- nextChar {}
Class TclParser
parameter: stream root
comment:This class can parse tcl code from stream parameter
that consists ReadStringStream object or compatible and produce parse tree.
The parsing can be startet this prs-structure category commands.
getList try to parse string as list element.
parseScriptTo parse stream as command contents to and build parse tree.
substituteTo parse stream as quoted string for command and variable substitution.
The parser is used normaly from PrsContext.
Parser has a special handling of parser errors.
You should use the paraser in this way
set ret [$parser catchParseErrors {$parser parseScriptTo $parser}]
if {$ret} {
puts "parsing was ok"
} else {
puts "parsing has errors"
}
Instprocs:
- catchParseErrors {eval}
- extractListTo {parent}
- getArrayKey {parent}
- getBeginingCommandSubst {parent}
- getBeginingVariable {parent}
- getChar {}
- getCharKeySequence {parent}
- getCharSequence {parent}
- This procedure parse string that not begin with special tcl
control characters.
It can return an PrsLitaral when it is normal string with no special
characters or PrsQuoted if they consists tcl substitutions elements as
$variable or [command]
- getCharWithMasking {}
- getCommand {parent}
- getCommandOrComment {parent}
- getCommandSubst {parent}
- getComment {parent}
- getList {parent}
- getNoSubst {parent}
- getQuoted {parent}
- getVariable {parent}
- This can parse following expresions
$a $a(2) ${a} ${a(3)} $a([set b])
- hasParseErrors {}
- init {args}
- isEndList {}
- parseError {text}
- parseScriptTo {parent}
- searchCloseBrace {obrace cbrace}
- searchCloseQuote {}
- skipBlanks {}
- skipCharacters {string}
- skipSeparators {}
- skipToWordEnd {}
- skipUpTo {echar}
- skipUpToCharacters {string}
- substituteTo {parent}
Procs:
- isDevelMode {}
- setDevelMode {mode}