Permalink
Browse files

More stuff

  • Loading branch information...
thomasmf committed Nov 11, 2015
1 parent aa86954 commit ead48185b150fdc07a5019499511f696c5326d45
Showing with 793 additions and 285 deletions.
  1. +3 −12 README.md
  2. +167 −0 examples/repl.n
  3. +19 −0 examples/rosettacode/loops_for.n
  4. +1 −0 examples/rosettacode/quine.n
  5. +3 −4 examples/sort.n
  6. +62 −0 examples/task.n
  7. +3 −0 makefile
  8. +2 −0 src/arg.py
  9. +1 −0 src/core/attribute.py
  10. +3 −10 src/core/documentation/overview.py
  11. +1 −0 src/core/dump.py
  12. +1 −0 src/core/function.py
  13. +1 −0 src/core/lazy.py
  14. +1 −23 src/core/method.py
  15. +15 −3 src/core/object.py
  16. +23 −2 src/core/parameter.py
  17. +4 −6 src/core/pattern.py
  18. +2 −0 src/core/pre.py
  19. +1 −1 src/core/runtime/clause/and_clause.py
  20. +1 −0 src/core/runtime/clause/clause.py
  21. +1 −0 src/core/runtime/clause/consume.py
  22. +1 −0 src/core/runtime/clause/grouping.py
  23. +1 −0 src/core/runtime/clause/not_clause.py
  24. +1 −1 src/core/runtime/clause/or_clause.py
  25. +1 −1 src/core/runtime/clause/pattern.py
  26. +1 −0 src/core/runtime/clause/plus.py
  27. +17 −1 src/core/runtime/clause/shape.py
  28. +1 −0 src/core/runtime/clause/star.py
  29. +1 −2 src/core/runtime/common.py
  30. +88 −15 src/core/runtime/control_structure/block.py
  31. +20 −0 src/core/runtime/evaluation/expression.py
  32. +0 −21 src/core/runtime/evaluation/reflective_union.py
  33. +1 −1 src/core/runtime/list/avid_map.py
  34. +93 −0 src/core/runtime/list/join.py
  35. +2 −2 src/core/runtime/list/lazy_list.py
  36. +29 −25 src/core/runtime/list/list.py
  37. +0 −45 src/core/runtime/list/produce_string.py
  38. +1 −1 src/core/runtime/list/range.py
  39. +0 −2 src/core/runtime/list/scan.py
  40. +6 −5 src/core/runtime/object/avid.py
  41. +27 −1 src/core/runtime/object/function.py
  42. +5 −4 src/core/runtime/object/lazy.py
  43. +2 −2 src/core/runtime/object/promise.py
  44. +5 −2 src/core/runtime/object/reference.py
  45. +4 −4 src/core/runtime/object/union.py
  46. +4 −4 src/core/runtime/objective/closure.py
  47. +0 −5 src/core/runtime/objective/predicate.py
  48. +2 −1 src/core/runtime/parser/integer.py
  49. +5 −1 src/core/runtime/parser/string.py
  50. +2 −1 src/core/runtime/parser/word.py
  51. +7 −1 src/core/runtime/primitives/integer.py
  52. +12 −2 src/core/runtime/primitives/string.py
  53. +6 −1 src/core/runtime/primitives/word.py
  54. +0 −28 src/core/runtime/root_scope.py
  55. +46 −0 src/core/runtime/system/console.py
  56. +0 −30 src/core/runtime/system/core.py
  57. +1 −0 src/core/runtime/system/core_unit_test.py
  58. +8 −0 src/core/runtime/system/error.py
  59. +1 −2 src/core/runtime/system/io.py
  60. +10 −0 src/core/runtime/system/nom.py
  61. +8 −0 src/core/runtime/system/stop.py
  62. +25 −7 src/core/runtime/system/task.py
  63. +13 −6 src/core/runtime/type/factory.py
  64. +3 −0 src/core/runtime/type/type.py
  65. +3 −0 src/core/test.py
  66. +1 −0 src/doc.py
  67. +14 −0 src/make.py
View
@@ -424,7 +424,6 @@ It is possible to have more than one definition:
<pre><code>with ( union
( function f ( Integer ) [ : that + 4 ] )
( function x [ . 100 ] )
()
) [
f ( x )
]</code></pre>
@@ -435,17 +434,9 @@ It is possible to have more than one definition:
<p>
<strong>with</strong> takes an object and a list as its arguments.
The list is the expression.
The object is scope that will be used in the evaluation of the expression.
</p>
<p>
Notice the empty parenthesis.
Recall that the initial object in an expression is the scope.
The empty parenthesis is scope.
The reason for using it in the union, specifically at the end,
is to make the new scope inherit the parent scope.
Therefore the two functions in addition to everything in the original scope is available in the expression.
The expression will be evaluated in a scope that is the union of the scope and the object,
so that terminology both from the object and the scope is available.
Terminology in the object will overshadow same terminology in the scope.
</p>
View
@@ -0,0 +1,167 @@
do [ console writeLine
"Nomen - Interactive Nomenine Evaluator - v0.1
Please use with rlwrap.
Write 'help!' for help."
]
let rootScope () [
let repl ( function ( :: scope ( Any ) ) [
do [ console write "> " ]
do [ let scope ( : that scope ) [
Task @
( union
( let repl ( : this ) [
function cycle ( :: scope ( Any ) ) [
do [ repl ( : that scope ) ]
stop
]
] )
( function return ( :: value ( Any ) ) [
do [ console writeLine ( if value [ . "" + ( : that value ) ] then [ value ] else [ dump ( : that value ) ] ) ]
: this cycle ( scope )
] )
( function fail ( :: error ( Any ) ) [
do [ console writeLine "error : " ]
do [ if [ : that error log ] ]
: this cycle ( scope )
] )
( function ( :: message ( Star @ ( Any ) ) ) [
do [ console writeLine ( . "Unrecognized message to context: " + ( : that message ) ) ]
: this cycle ( scope )
] )
)
( Closure @ ( union
( scope )
( union
( function produce ( StringExtract tid ) [
: cycle ( scope )
] )
( function help! [
do [ console writeLine
"The following extra commands are available:
help! show this message
reset! clear scope
set: ( object ) make object part of scope
def: word ( object ) make word denote object in scope
example: def: x 123
fun: ...parameters... [ phrase ] make function part of scope
example: fun: f ( :: n ( Integer ) ) [ : that n * ( : that n ) ]
ctrl-c to exit"
]
: cycle ( scope )
] )
( function reset! [
: cycle ( none )
] )
( function set: ( :: object ( Any ) ) [
: cycle ( union ( : that object ) ( scope ) )
] )
( function def: ( :: name ( Word ) ) ( :: object ( Any ) ) [
: cycle ( union ( definition ( : that name ) ( : that object ) ) ( scope ) )
] )
( function fun: ( :: parameters ( Plus @ ( Clause ) ) ) ( :: phrase ( List ) ) [
: cycle ( union ( Function @ ( Pattern @ ( : that parameters ) ) ( Closure @ ( : this ) ( : that phrase ) ) ) ( scope ) )
] )
( rootScope )
( function ( :: message ( Star @ ( Any ) ) ) [
do [ console writeLine ( . "Unrecognized message to scope: " + ( : that message ) ) ]
: cycle ( scope )
] )
)
) [
console readLine evaluate ()
] )
( none )
schedule
] ]
]
) [
repl ( none )
]
]
@@ -0,0 +1,19 @@
Range @ 1 5 reduce 0 ( closure [
do [
Range @ 1 ( : that ) reduce 0 ( closure [
console write "*"
] )
]
console writeLine ""
] )
@@ -0,0 +1 @@
let q [ console write ( . "let q " + ( q ) + [ q evaluate () ] ) ][ q evaluate () ]
View
@@ -1,5 +1,6 @@
. ( list
console writeLine ( . ( list
213 227 662 583 894 254 297 158 305 879 480 316 407 346 994 654 17 760 912 472 124 968 38 813 134 71 933 41 204 98 263 6 732 157 136 477 996 836 204
756 754 669 414 582 525 397 374 289 319 421 328 697 59 604 875 505 634 430 239 86 307 644 873 125 590 404 935 873 103 456 722 361 436 650 521 139 419 611
@@ -47,8 +48,6 @@
44 362 332 612 91 495 185 549 263 155 986 457 944 228 168 560 148 686 927 353 464 576 103 150 381 942 331 633 764 619 909 251 20 313 832 387 1 105 187
940 116 518 232 718 292 504 828 940 283 163 433 603 658 266 678 533 354 128 27 724 948 767 102 756 637 360 596 309 958 892 421 980 693 130 19 410 675 830
) sort joinToString ", "
) sort join ", " )
View
@@ -0,0 +1,62 @@
Range @ 1 10 reduce 0 ( closure [
do [ console writeLine ( . "start task " + ( : that ) ) ]
Task @
( union
( function return ( :: value ( Any ) ) [
do [ console writeLine ( . "finnish task " + ( : that value ) ) ]
stop
] )
( function fail ( :: error ( Any ) ) [
do [ console writeLine "failed task" ]
stop
] )
( function ( :: message ( Star @ ( Any ) ) ) [
do [ console writeLine "failed task with unrecognized message to context" ]
do [ console writeLine ( . "message was: " + ( : that message ) ) ]
stop
] )
)
( closure [
do [ console writeLine ( . "do task " + ( : that ) ) ]
do [ . "" + ( Map @ ( Range @ 1 1000 ) ( closure [ : that ] ) ) ]
. ( : that )
] )
( : that )
schedule
] )
View
@@ -16,12 +16,15 @@ core.o: FORCE
# python src/make.py --call_by_future
# python src/make.py --map_evaluation --map_parsing
# python src/make.py --no_optimize --type_checks --informative_errors
# python src/make.py --informative_errors --type_checks --detach_threads
python src/make.py --informative_errors --type_checks
# python src/make.py --no_optimize
# python src/make.py
# python src/make.py --detach_threads
# python src/make.py --list_used_methods
# python src/make.py --no_gc --no_optimize
# python src/make.py --no_gc
# python src/make.py --no_gc --call_by_future --detach_threads # causes unit test for lazy lists to fail sometimes
$(CC) $(CFLAGS) core.c
cp readme.html README.md
View
@@ -17,3 +17,5 @@ def DISABLED( flag, code ) :
return PRE( code )
else :
return ''
View
@@ -14,3 +14,4 @@ def __init__( self, type, name ) :
self.type = type
self.name = name
@@ -178,23 +178,16 @@
with ( union
( function f ( Integer ) [ : that + 4 ] )
( function x [ . 100 ] )
()
) [
f ( x )
]
)
$DOC_WORD( with ) takes an object and a list as its arguments.
The list is the expression.
The object is scope that will be used in the evaluation of the expression.
Notice the empty parenthesis.
Recall that the initial object in an expression is the scope.
The empty parenthesis is scope.
The reason for using it in the union, specifically at the end,
is to make the new scope inherit the parent scope.
Therefore the two functions in addition to everything in the original scope is available in the expression.
The expression will be evaluated in a scope that is the union of the scope and the object,
so that terminology both from the object and the scope is available.
Terminology in the object will overshadow same terminology in the scope.
$DOC_HEADER( If )
View
@@ -5,3 +5,4 @@ def __init__( self, pattern = '', *values ) :
self.pattern = pattern
self.values = values
View
@@ -14,3 +14,4 @@ def build_define( self ) :
'}'
] )
View
@@ -16,3 +16,4 @@ def LAZY( t, expression ) :
} )
""" )
Oops, something went wrong.

0 comments on commit ead4818

Please sign in to comment.