Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/rxm.git

In order traversal of stack.

Author Dave Jarvis <email>
Date 2015-03-02 23:50:55 GMT-0800
Commit 5d43eec78e26ed1a136a0c0fc95d1f644b9f68de
Parent 625e03f
Delta 53 lines added, 3 lines removed, 50-line increase
source/java/com/whitemagicsoftware/rxm/Parser.java
import java.io.IOException;
+import java.util.List;
import java.util.Stack;
/** Used to convert linear map to hierarchical form. */
- private Stack stack = new Stack();
+ private Stack<String> stack = new Stack<String>();
/**
@Override
public void enterElement( QueryParser.ElementContext context ) {
- System.out.println( "Element: " + context.getText() );
+ String popped = getStack().pop();
+
+ getStack().push( "XMLELEMENT( NAME element" );
+ getStack().push( ")" );
+ getStack().push( popped );
+ }
+
+ @Override
+ public synchronized void exitQuery( QueryParser.QueryContext context ) {
+ // Traverse the stack in order.
+ for( String s : getStack() ) {
+ System.out.println( s );
+ }
}
}
- private Stack getStack() {
+ private Stack<String> getStack() {
return this.stack;
}
where.cf
+entrypoints Where ;
+
+token ID (letter (letter | digit | '_')*) ;
+
+TTbl. Table ::= Identifier ;
+TCol. Column ::= "." Identifier ;
+TTblCol. TableColumn ::= Identifier Column ;
+TAttr. Attribute ::= "@" Identifier ;
+TParam. Parameter ::= "$" Identifier ;
+
+RXM. Where ::= [Statement] ;
+
+WCompEq. ComparatorOperatorEquality ::= "=" ;
+WCompNeq. ComparatorOperatorEquality ::= "<>" ;
+
+WCompLt. ComparatorOperator ::= "<" ;
+WCompGt. ComparatorOperator ::= ">" ;
+WCompLte. ComparatorOperator ::= "<=" ;
+WCompGte. ComparatorOperator ::= ">=" ;
+
+WAnd. LogicalOp ::= "&&" ;
+WOr. LogicalOp ::= "||" ;
+
+WEmpty. Where ::= Where ;
+WEq. Where ::= TableColumn ComparatorOperatorEquality AllValues ;
+WComp. Where ::= TableColumn ComparatorOperator Value ;
+WLogic. Where ::= Where LogicalOp Where ;
+WParen. Where ::= "(" Where ")" ;
+
+VValue. AllValues ::= Value ;
+VSet. AllValues ::= Set ;
+
+rules Value ::= Parameter | "null" | String | Double ;
+
+SBlock. Set ::= "{" SetValues "}" ;
+rules SetValues ::= Value | Value "," Value;
+