A lot of parsing is still done in many places in the code; two specifics are obvious to any code browser:
- Parsing Set statements
- Parsing pre and verbatim tags when processing entire topics
It would be good to centralise this parsing. I've made a start by dealing with Set statements, by adding a couple of TWiki::regexes for them
- $TWiki::regex{setRegex} does
/^(\t| )+\*\s+Set\s*/
- $TWiki::regex{setVarRegex} does
/$regex{setRegex}(\w+)\s*=\s*/
I don't propose to do any more than that for Dakar.
--
CrawfordCurrie - 25 Mar 2005
Good idea. It wasn't obvious that the setRegex was insisting on a multiple of 3 spaces (which I think is correct), so I modified it to be in fixed font to make it more obvious. I think there are some inconsistencies in these expressions with current (Cairo) implementation. The setRegex allows multiple spaces between the
*
and
Set
; the current regex requires one and only one. Also, the setRegex ends with
\s*
and is followed in setVarRegex with
(\w+)
, which means that something like
SetJUNK = foo
would set the variable
JUNK
to
foo
. Again, the current implementation requires one and only one space between
Set
and the variable name. I am OK with allowing more than one space between the
*
and
Set
and between
Set
and
=
, but I think we should require at least one space between those elements.
--
DavidBright - 25 Mar 2005
The "more than one space" lets you line up the '=' signs in the raw, whcih can help composing, But then the
HTML rendering foes and converts all those spaces to one space.
Yes, there
should be white-space between the
Set
and name of the variable and the
Set
and the =.
--
AntonAylward - 25 Mar 2005
The exprs are now:
$regex{bulletRegex} = qr/^(?:\t| )+\*/;
$regex{setRegex} = qr/$regex{bulletRegex}\s+Set\s+/o;
$regex{setVarRegex} = qr/$regex{setRegex}(\w+)\s*=\s*(.*)$/o;
Why should there be whitespace between the variable name and the =?
--
CrawfordCurrie - 26 Mar 2005
Probably because programmers know that any amount of whitespace is optional.
Why we use set statements at all is another question. I'd venture that this is 'data about pages' and therefore metadata; it'd be nice to have a panel that pops up where one is guided as to what name (ALLOWTOPICCHANGE) = value (
TWikiAdminGroup) pairs are possible.
Logically these Sets ought fit into a namespace too.
--
MartinCleaver - 26 Mar 2005