Tags:
create new tag
view all tags
Current spec of the Attrs module. The module can be used in "compatibility mode" (the default) where it should parse the same strings as the old etractNameValuePair.

Context:

tag        ::= '%' name args '%' ;
args       ::= '{' attrs '}' | ;
The grammar describing "compatibility mode" attributes
attrs      ::= wierdstring arglist | arglist | verywierdstring | ;
arglist    ::= arg arglist | doublequotedstring arglist | ;
arg        ::= name '=' doublequotedstring ;
Tokens expressed using Perl RE's
name:               /[A-Za-z0-9_]+/
doublequotedstring: /".*?"/ (where \" is a valid escape for ")
wierdstring:        /"(.(?:"\w\s*="))*"/
verywierdstring:    /.*/
Notes
  • the last instance of a unique 'name' in an arg is the defining instance, so %TAG{ fred="joe" fred="sam" }% assigns "sam" to name "fred".
  • The old extractNameValuePair implements the reverse (i.e. fred="joe").
  • }% is not legal in any string, and there are no escapes.

Friendly mode supports the syntax I developed for use with the ActionTrackerPlugin and CommentPlugin after many complaints about the original syntax. The major difference is that there is no support for unquoted arbitrary string parameters delimited only by the {}% and double-quoted value strings with non-escpaed embedded quotes.

In "friendly" mode, the grammar is:

attrs        ::= arglist | ;
arglist      ::= arg sep arglist | quotedstring sep arglist | ;
sep          ::= "," | ;
arg          ::= name | name '=' quotedstring ;
quotedstring ::= doublequotedstring | singlequotedstring ;
Tokens expressed using Perl RE's
name:               /[A-Za-z0-9_]+/
doublequotedstring: /".*?"/ (where \" and is a valid escape for ")
singlequotedstring: /'.*?'/ (where \' and is a valid escape for ')
wierdstring:        /"(.(?:"\w\s*="))*"/
verywierdstring:    /[^"].*/
Notes:
  • name on it's own is assigned a boolean true value
  • sep may be commas, spaces, or a mixture
  • Intended to be closer to the XHTML spec.

Implemented in DevelopBranch. Review/extend the tests in http://localhost/DEVELOP/bin/view/TestCases/TestCaseAutoAttributeParsing if you need more info.

-- CrawfordCurrie - 03 Mar 2005

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2005-03-03 - CrawfordCurrie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.