You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jo...@apache.org on 2001/03/12 04:25:45 UTC

cvs commit: jakarta-velocity/xdocs specification-ast.xml specification-bnf.xml specification.xml

jon         01/03/11 19:25:45

  Added:       xdocs    specification-ast.xml specification-bnf.xml
                        specification.xml
  Log:
  moved the specification files into xdocs
  
  Revision  Changes    Path
  1.1                  jakarta-velocity/xdocs/specification-ast.xml
  
  Index: specification-ast.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
  
   <properties>
    <title>Velocity Specification - AST</title>
    <author email="jon@latchkey.com">Velocity Documentation Team</author>
   </properties>
  
  <body>
  
  <section name="Velocity Specification - AST">
  
  <p>
  Please note that this is currently out of date and will be updated soon.
  </p>
  
  <source><![CDATA[
  This is tentatively the AST structure for Velocity.
  
  The structure is as would be described using ANTLR
  BNF-style notation.  A tree is described by 
  #(node node node) where #() represents the tree form.  
  The first node is the root of the tree, and following 
  nodes are all children.
  
  Visually, #(A B C D E) might look like:
  
       A
       |
       B-C-D-E
  
  Root nodes must always be a terminal node, denoted by
  an all-caps identifier.
  
  Non-root nodes may be either terminal nodes, or sub-rules,
  or inlined sub-trees. 
  
  A sub-rule might describe a tree, or simple a node.
  
  
  block
  	:
  		#(	BLOCK
  				(statement)*
  		)
  
  	;
  statement
  	:
  			text
  		|	if_statement
  		|	foreach_statement
  		|	include_statement
  		|	set_statement
  		|	parse_statement
  		|	param_statement
  		|	stop_statement
  		|	reference
  	;
  
  
  text
  	:
  		TEXT
  	;
  
  //	if/elseif/else chains should be represented solely
  //	by <if_statement>.  <elseif> is simply an <if_statement>
  //	in the false-branch of the preceeding <if_statement>
  //	while <else> is simply an <if_statement> where the
  //	<expr> evaluates to TRUE always, and no false-branch
  //	is provided.
  
  if_statement
  	:
  		#(	IF
  				// The expression to test
  				expr
  
  				// True branch
  				block
  
  				// False branch
  				( block )?
  		)
  	;
  
  foreach_statement
  	:
  		#(	FOREACH
  				// Value to assign for each iteration
  				reference
  				// List of objects to iterator
  				reference
  				// command-block to execute
  				( block )?
  		)
  	;
  
  set_statement
  	:
  		#(	SET
  				// Variable to set
  				reference
  				// Value to assign
  				expr
  	;
  
  parse_statement
  	:
  		#(	PARSE
  				STRING_LITERAL
  		)
  	;
  
  include_statement
  	:
  		#(	INCLUDE
  				STRING_LITERAL
  		)
  	;
  
  stop_statement
  	:
  		STOP
  	;
  
  reference
  	:
  		#(	REFERENCE
  				postfix
  	;
  
  postfix
  	:
  		method_call
  		|
  		member
  		|
  		identifier
  	;
  
  member
  	:
  		#(	DOT
  				identifier
  				(	primary
  				|	method_call
  				)	
  	;
  
  primary
  	:
  		IDENTIFIER
  	;
  
  method_call
  		#(	CALL
  				postfix
  				// The argument list
  				( expr ) *
  		)
  	;
  ]]></source>
  
  </section>
  
  </body>
  </document>
  
  
  
  1.1                  jakarta-velocity/xdocs/specification-bnf.xml
  
  Index: specification-bnf.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
  
   <properties>
    <title>Velocity Specification - BNF</title>
    <author email="jon@latchkey.com">Velocity Documentation Team</author>
   </properties>
  
  <body>
  
  <section name="Velocity Specification - BNF">
  
  <p>
  Please note that this is currently out of date and will be updated soon.
  </p>
  
  <source><![CDATA[
  This is a tentative BNF for Velocity, right now this is
  pretty much the WM syntax. This might change, as arithmetic
  might not make it into the syntax, and the future
  velocity syntax will more then likely remove block
  markers and instead use an "#end" token to signify
  the end of a directive.
  
  
  <statement>         
      
      ::=   <text>
          | <block>
          | <if-statement>
          | <else-if-statement>
          | <foreach-statement>
          | <include-statement>
          | <set-statement>
          | <parse-statement>
          | <param-statment>
          | <stop-statement>
          | <reference>
  
  <block>
      
      ::= "#begin" { <expresion> } "#end"
  
  <if-statement>
      
      ::= "#if" "(" <expresion> ")" <statement> [ <else-statement> ]
  
  
  <else-if-statement> 
  
      ::= "#elseif" "(" <expresion> ")" <statement> [ <else-statement> ]
  
  <foreach-statement> 
  
      ::= "#foreach" <reference> "in" <reference> <statement>
  
  <include-statement> 
  
      ::= "#include" <string-literal>
  
  <set-statement>     
  
      ::= "#set" <reference> "=" <expression>
  
  <parse-statement>   
  
      ::= "#parse" <string-literal>
  
  <param-statment>    
  
      ::= "#param" <reference> "=" <string-literal>
  
  <stop-statement>    
  
      ::= "#stop"
  
  <reference>         
  
      ::= "$" <identifier> { "." <method> | <identifier> }
  
  <method>            
  
      ::= <identifier> "(" [ <parameter> { "," <parameter> } ] ")"
  
  <parameter>         
  
      ::= <reference> | <string-literal>
  
  <alpha-char>
  
      ::= "a..z, A..Z"
  
  <identifier-char>   
  
      ::= "a..z, A..Z ,0..9 ,- ,_"
  
  <identifier>        
  
      ::= <alpha-char> { <identifier-char> }
  
  <expression>        
  
      ::=   <true>
          | <false>
          | <primary-expression> "=" <assignment>
          | <conditional-or-expression>
                          
  <assignment>        
      
      ::= <primary-expression> "=" <assignment>
  
  <conditional-or-expression>
  
      ::= <conditional-and-expression> { "||" <conditional-and-expression> }
                              
  <conditional-and-expression>
  
      ::= <equality-expression> { "&&" <equality-expression> }
                          
  <equality-expression>
  
      ::= <relational-expression>
          {     "==" <relational-expression> 
              | "!=" <relational-expression> 
          }
                          
  <relational-expression>
  
      ::= <additive-expression>
          {
                "<"  <additive-expression>
              | ">"  <additive-expression>
              | "<=" <additive-expression>
              | ">=" <additive-expression>
          }
                          
  <additive-expression>
  
      ::= <multiplicative-expression>
          {
                "+" <multiplicative-expression>
              | "-" <multiplicative-expression>
          }
                          
  <multiplicative-expression>
  
      ::= <unary-expression>
          {
                "*" <unary-expression>
              | "/" <unary-expression>
              | "%" <unary-expression>
          }
                          
  <unary-expression>
  
      ::= "!" <unary-expression> | <primary-expression>
                  
  <primary-expression>
  
      ::=   <string-literal>
          | <number-literal>
          | <reference>
          | "(" <expression> ")"
  
  ]]></source>
  
  </section>
  
  </body>
  </document>
  
  
  
  1.1                  jakarta-velocity/xdocs/specification.xml
  
  Index: specification.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
  
   <properties>
    <title>Velocity Specification</title>
    <author email="jon@latchkey.com">Velocity Documentation Team</author>
   </properties>
  
  <body>
  
  <section name="Velocity Specification">
  
  <p>
  This document will eventually describe the Velocity Specification. 
  For now, we have links to our outdated BNF and AST specifications. 
  They will be updated soon.
  </p>
  
  <ul>
  <li><a href="./specification-bnf.html">BNF Specification</a></li>
  <li><a href="./specification-ast.html">AST Specification</a></li>
  </ul>
  
  </section>
  
  </body>
  </document>