Mercurial > repos > tabletprog
annotate samples/oper_impl.tp @ 358:27477c8c2823
Add support for simple type annotations in parser and update llhello sample with a possible new low-level dialect syntax leveraging those annotations
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 17 Apr 2015 17:50:47 -0700 |
parents | 9820ecd4eed4 |
children |
rev | line source |
---|---|
122
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #{ |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 pair <- :a b { |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #{ |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 first <- a |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 second <- b |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 + <- :other { |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 pair: first + (other first) second + (other second) |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 } |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 } |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 } |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 main <- { |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 foo <- pair: 5 7 |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 bar <- pair: 9 23 |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 baz <- foo + bar |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 print: ((baz first) string) . "\n" |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 print: ((baz second) string) . "\n" |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 0 |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 } |
9820ecd4eed4
Add support for implementing operators on user defined objects
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 } |