Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

instantiation

  • Loading branch information...
commit d26aa3c682750883a4701a1c1530d3510f2a5895 1 parent 803d2da
@mmikulicic authored
Showing with 14 additions and 4 deletions.
  1. +4 −1 src/ast.clj
  2. +10 −3 src/doroty.clj
View
5 src/ast.clj
@@ -10,4 +10,7 @@
{:type 'Ref :name n})
(defn make-struct-def [l v]
- {:type 'StructDef :label l :value v})
+ {:type 'StructDef :label l :value v})
+
+(defn make-instantiation [set args]
+ {:type 'Inst :set set :args args})
View
13 src/doroty.clj
@@ -17,8 +17,8 @@
(def structureDef
(let-bind [label identifier
- _ (symb "=")
- val expression]
+ _ (symb "=")
+ val expression]
(result (make-struct-def label val))))
(def structure
@@ -27,7 +27,14 @@
(def literal
(either structure number stringLit reference))
+(def argList
+ (sepBy expression comma))
+(def instantiation
+ (let-bind [_ (symb "new")
+ set identifier
+ args (parens argList)]
+ (result (make-instantiation set args))))
(def predecl
@@ -37,7 +44,7 @@
(string "ugo"))
(def expression
- literal)
+ (either instantiation literal))
(def statement
Please sign in to comment.
Something went wrong with that request. Please try again.