[antlr-interest] BNF to ANTLR grammar conversion

Alex J. Rodriguez alexjrodriguez at yahoo.com
Fri Dec 10 16:12:54 PST 2004




How do I go from BNF to ANTLR grammar programmatically? I am looking
for a way to generate an XPath parser/evaluator from the following BNF
(the syntax is pretty small, and is really a stripped down XPath 1.0
syntax defined by the SDO spec):

path ::= '/'? (step '/')* step
step ::= '@'? property
      | property '[' index_from_1 ']'
      | property '.' index_from_0
      | reference '[' attribute '=' value ']'
      | ".."
property ::= NCName      ;; may be simple or complex type
attribute ::= NCName     ;; must be simple type
reference :: NCName      ;; must be DataObject type
index_from_0 ::= Digits
index_from_1 ::= NotZero (Digits)?
value ::= Literal 			
      | Number
      | Boolean
Literal ::= '"' [^"]* '"'
      | "'" [^']* "'"
Number ::= Digits ('.' Digits?)? 
      | '.' Digits
Boolean ::= true
      | false
NotZero ::= [1-9]
Digits ::= [0-9]+

;; leading '/' begins at the root
;; ".." is the containing DataObject
;; Only the last step have an attribute as the property


- Alex Rodriguez










 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list