etng-r2/etng-pass-common.g
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
Wed, 16 Jan 2019 17:15:58 +0000
changeset 438 1fe179d53161
parent 258 4d06e035b80e
permissions -rw-r--r--
Add missing primitive implementation for the plain interpreter.
200
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     1
-- -*- text -*-
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     2
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     3
toplevel =
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     4
	  &_:v {#define-namespace} -> v -- no code in here
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     5
	| &_:v {#declare-default-namespace} -> v -- neither
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     6
	| {#define-value :qname expr:exp ~_} -> `(define-value ,qname ,exp)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     7
	| {#define-function :qname method:meth ~_} -> `(define-function ,qname ,meth)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     8
	| expr
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
     9
;
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    10
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    11
expr =
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    12
	  {#ref :name ~_} -> `(ref ,name)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    13
	| {#lit :literal ~_} -> `(lit ,literal)
234
10e62e160cb0 Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 204
diff changeset
    14
	| {#object :selfid method*:methods ~_} -> `(object ,selfid ,@methods)
200
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    15
	| {#function method*:methods ~_} -> `(function ,@methods)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    16
	| {#tuple expr*:elts ~_} -> `(tuple ,@elts)
258
4d06e035b80e Begin adapting evaluator to codegen
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 234
diff changeset
    17
	| {#send expr:receiver expr*:message ~_} -> `(send ,receiver ,@message)
204
90899a08ca40 Parse '%assemble' construct.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 202
diff changeset
    18
	| {#assemble {assemble-binding*}:bindings {assemble-clause*}:clauses}
90899a08ca40 Parse '%assemble' construct.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 202
diff changeset
    19
	  -> `(assemble ,bindings ,clauses)
200
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    20
;
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    21
204
90899a08ca40 Parse '%assemble' construct.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 202
diff changeset
    22
assemble-binding = {:name expr:init} -> `(,name ,init);
90899a08ca40 Parse '%assemble' construct.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 202
diff changeset
    23
assemble-clause = {:language :item} -> `(,language ,item);
90899a08ca40 Parse '%assemble' construct.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 202
diff changeset
    24
200
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    25
method =
201
9b22b7a23e39 Convert constant-methods to normal methods.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 200
diff changeset
    26
	  {#method {pattern*}:patterns expr:body ~_} -> `(method ,patterns ,body)
200
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    27
;
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    28
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    29
pattern =
202
65694ce5407c Make (discard) like all other pattern ASTs: wrapped in parens.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents: 201
diff changeset
    30
	  {#discard} -> `(discard)
200
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    31
	| {#bind :name ~_} -> `(bind ,name)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    32
	| {#lit :literal ~_} -> `(lit ,literal)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    33
	| {#tuple pattern*:elts ~_} -> `(tuple ,@elts)
466a5b65f1bf Use merge-ometa with passes.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff changeset
    34
;