Permalink
Browse files

parameter + namespace support

  • Loading branch information...
1 parent 33a3422 commit dbf35c416ae5ea5e6447d1d9fa3fb7f2f69a969a @mmikulicic committed Jan 5, 2010
Showing with 23 additions and 11 deletions.
  1. +6 −3 src/eu/dnetlib/clojure/clarsec.clj
  2. +4 −1 src/eu/dnetlib/dlms/ast.clj
  3. +13 −7 src/eu/dnetlib/dlms/parser.clj
@@ -170,10 +170,13 @@
(defn stringify [p]
(bind p #(result (if (seq? %) (apply str %) (str %)))))
+(def baseIdentifier
+ (let-bind [c letter
+ cs (many (either letter digit))]
+ (result (apply str (cons c cs)))))
+
(def identifier
- (lexeme (let-bind [c letter
- cs (many (either letter digit))]
- (result (apply str (cons c cs))))))
+ (lexeme baseIdentifier))
(def natural
(lexeme (>>== (stringify (many1 digit))
@@ -1,7 +1,7 @@
(ns eu.dnetlib.dlms.ast
(:import (eu.dnetlib.dlms.jdbc.ast
Assign BinaryPredicate Call DeclInit Expression Inst Lit NumberLit Predicate Ref RunExpr Select SimplePredicate StringLit Struct
- StructKeyValue XPathComponent XPathExpr XPath
+ StructKeyValue XPathComponent XPathExpr XPath Parameter
)))
(defn make-run-expr [e]
@@ -16,6 +16,9 @@
(defn make-reference [n]
(new Ref n))
+(defn make-parameter [n]
+ (new Parameter n))
+
(defn make-struct [defs]
(new Struct defs))
@@ -8,15 +8,17 @@
[eu.dnetlib.clojure.monad])
)
-(declare instantiation invocation literal)
+(declare instantiation invocation literal reference parameter)
(declare xpath)
(def expression
(delay (either
instantiation
invocation
- literal)))
+ literal
+ reference
+ parameter)))
(def stringLit
(>>== stringLiteral make-string-lit))
@@ -27,6 +29,9 @@
(def reference
(>>== identifier make-reference))
+(def parameter
+ (>>== (>> (symb ":") baseIdentifier) make-parameter))
+
(def structureDef
(let-bind [label identifier
_ (symb "=")
@@ -38,7 +43,7 @@
make-struct))
(def literal
- (either structure number stringLit reference))
+ (either structure number stringLit))
(def argList
(delay (sepBy expression comma)))
@@ -74,10 +79,11 @@
-(def tagname (either (symb ".")
- (let-bind [attr (option "" (string "@"))
- name (either identifier (symb "*"))]
- (result (str attr name)))))
+(def tagname (lexeme (either (symb ".")
+ (let-bind [attr (option "" (string "@"))
+ ns (option "" (stringify (m-sequence [baseIdentifier (string ":")])))
+ name (either baseIdentifier (symb "*"))]
+ (result (str attr ns name))))))
(def binaryPredicate

0 comments on commit dbf35c4

Please sign in to comment.