Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[cardinal] Adding initial support for Range, Time, Math, GC, and Kern…

…el classes. Much more to come :-)

git-svn-id: https://svn.parrot.org/parrot/trunk/languages/cardinal@31774 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 3356e2341d7e1cf3d583f5528d4d624205a25c54 1 parent 0f17d8e
@damianknopp damianknopp authored
View
3  cardinal.pir
@@ -37,7 +37,8 @@ object.
.namespace [ 'cardinal::Compiler' ]
-.loadlib 'cardinal_group'
+#no caridinal_group found on my machine
+#.loadlib 'cardinal_group'
.sub 'onload' :anon :load :init
load_bytecode 'PCT.pbc'
View
6 config/makefiles/root.in
@@ -55,7 +55,13 @@ BUILTINS_PIR = \
src/classes/Integer.pir \
src/classes/Array.pir \
src/classes/Hash.pir \
+ src/classes/Any.pir \
+ src/classes/Range.pir \
src/classes/Bool.pir \
+ src/classes/Kernel.pir \
+ src/classes/Time.pir \
+ src/classes/Math.pir \
+ src/classes/GC.pir \
src/builtins/globals.pir \
src/builtins/eval.pir \
View
8 src/builtins/control.pir
@@ -61,6 +61,14 @@ src/builtins/control.pir - Cardinal Control functions
throw e
.end
+=item sleep(num)
+Sleep for number of seconds.
+=cut
+.sub 'sleep'
+ .param num a
+ sleep a
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
View
1  src/builtins/eval.pir
@@ -121,7 +121,6 @@ such as C<eval>, C<require>, and C<use>.
$P0 = 'require'(file, 'file'=>1)
.end
-
=back
=cut
View
23 src/builtins/globals.pir
@@ -29,6 +29,29 @@ src/builtins/globals.pir - initialize miscellaneous global variables
## set up %*INC
$P0 = new 'CardinalHash'
set_hll_global '%INC', $P0
+
+ ## global record separator
+ #$P1 = new 'CardinalString'
+ #$P1 = "\n"
+ $P1 = get_hll_global ['NilClass'], '!CARDINALMETA'
+ set_hll_global '$/', $P1
+
+ $P2 = new 'CardinalString'
+ $P2 = "parrot"
+ set_hll_global 'RUBY_PLATFORM', $P2
+
+ $P3 = new 'CardinalString'
+ $P3 = "1.9"
+ set_hll_global 'RUBY_VERSION', $P3
+.end
+
+=item
+ Uses Parrot builtin Random type, doesnt seem to be working
+=cut
+.sub 'rand'
+ $P0 = new 'Random'
+ $I0 = $P0
+ .return ($I0)
.end
# Local Variables:
View
17 src/builtins/op.pir
@@ -136,6 +136,23 @@ src/builtins/op.pir - Cardinal ops
.end
+## autoincrement
+.sub 'postfix:++' :multi(_)
+ .param pmc a
+ $P0 = clone a
+ inc a
+ .return ($P0)
+ #.return (a)
+.end
+
+.sub 'postfix:--' :multi(_)
+ .param pmc a
+ $P0 = clone a
+ dec a
+ .return ($P0)
+.end
+
+
=back
=cut
View
22 src/builtins/say.pir
@@ -33,6 +33,28 @@ builtin functions for Ruby.
'print'($S0, "\n")
.end
+.sub 'readline'
+ #.param pmc sep :optional #record sep
+ $P0 = getstdin
+ $S0 = $P0.readline('')
+ .return($S0)
+.end
+
+.sub 'printf'
+ .param pmc fmt
+ .param pmc args :slurpy
+ $P0 = get_hll_global ['Kernel'], '!CARDINALMETA'
+ $P0.'printf'(fmt, args :flat)
+.end
+
+.sub 'sprintf'
+ .param pmc fmt
+ .param pmc args :slurpy
+ $P0 = get_hll_global ['Kernel'], '!CARDINALMETA'
+ $P1 = $P0.'sprintf'(fmt, args :flat)
+ .return ($P1)
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
View
54 src/classes/Any.pir
@@ -0,0 +1,54 @@
+## $Id: Any.pir 29590 2008-07-18 16:46:36Z jonathan $
+
+=head1 TITLE
+
+Any - Perl 6 Any class
+
+=head1 DESCRIPTION
+
+This file implements the Any class.
+
+=head2 Basic C<Any> methods
+
+=over 4
+
+=cut
+
+.namespace []
+.sub 'onload' :anon :init :load
+ .local pmc meta
+ meta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ meta.'new_class'('CardinalAny', 'parent'=>'CardinalObject')
+.end
+
+
+=item can($x)
+
+=cut
+
+.namespace ['CardinalAny']
+.sub 'can' :method
+ .param pmc x
+ $P0 = self.'HOW'()
+ .return $P0.'can'(self, x)
+.end
+
+=item isa($x)
+
+=cut
+
+.sub 'isa' :method
+ .param pmc x
+ $P0 = self.'HOW'()
+ .return $P0.'isa'(self, x)
+.end
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
108 src/classes/Array.pir
@@ -26,7 +26,6 @@ Stolen from Rakudo
.end
-
=item get_string() (vtable method)
Return the elements of the list concatenated.
@@ -40,6 +39,23 @@ Return the elements of the list concatenated.
.return ($S0)
.end
+.sub 'initialize' :method :multi(_)
+ noop
+.end
+
+.include "hllmacros.pir"
+.sub 'initialize' :method :multi(_,CardinalInteger)
+ .param pmc size
+ .local pmc i
+ i = new 'CardinalInteger'
+ i = 0
+ $P0 = get_hll_global 'nil'
+ .DoWhile( {
+ self[i] = $P0
+ inc i
+ }, i < size)
+.end
+
=item to_s() (method)
Return a CardinalString representing the Array.
@@ -74,6 +90,35 @@ Removes all elements from the array.
self = 0
.end
+=item fill(value)
+
+Fill C<self> with C<value>
+Doesnt work, but it should be close...
+
+=cut
+
+.sub 'fill' :method
+ .param pmc value
+ .param int offset :optional
+ .param int end_index :optional
+
+ unless end_index goto set_index
+ unless offset goto set_offset
+ goto do_fill
+
+ set_index:
+ end_index = self.'length'()
+ unless offset goto set_offset
+ goto do_fill
+ set_offset:
+ offset = 0
+ goto do_fill
+ do_fill:
+ $P0 = new 'CardinalString'
+ $P0 = value
+ splice self, value, offset, end_index
+ .return (self)
+.end
=item ACCEPTS(topic)
@@ -128,6 +173,16 @@ Return the number of elements in the list.
.return ($I0)
.end
+=item
+
+Return the class name
+
+=cut
+
+.sub 'class' :method
+ .return self.'WHAT'()
+.end
+
=item sort()
Return a sorted copy of the list
@@ -227,6 +282,15 @@ Return a sorted copy of the list
self.append($P0)
.end
+.sub 'max' :method
+ $P0 = 'infix:max'(self)
+ .return($P0)
+.end
+
+.sub 'min' :method
+ $P0 = 'infix:min'(self)
+ .return($P0)
+.end
=item include?(ELEMENT)
@@ -250,6 +314,21 @@ Return true if self contains ELEMENT
.return($P0)
.end
+=item
+Return true is C<self> is of size 0
+=cut
+.sub 'empty?' :method
+ .local int len
+ len = self.'length'()
+ if len == 0 goto empty
+ goto not_empty
+ empty:
+ $P0 = get_hll_global ['Bool'], 'True'
+ .return ($P0)
+ not_empty:
+ $P0 = get_hll_global ['Bool'], 'False'
+ .return ($P0)
+.end
=item unshift(ELEMENTS)
@@ -657,8 +736,8 @@ Checks to see if the specified index or indices have been assigned to. Returns
.sub grep :method
.param pmc test
+ .param pmc block :named('!BLOCK')
.local pmc retv
- .local pmc block
.local pmc block_res
.local pmc block_arg
.local int narg
@@ -671,15 +750,14 @@ Checks to see if the specified index or indices have been assigned to. Returns
loop:
if i == narg goto done
block_arg = self[i]
-
- newclosure block, test
+ $P0 = 'infix:=~'(block_arg, test)
+ unless $P0 goto next
block_res = block(block_arg)
-
if block_res goto grepped
goto next
grepped:
- retv.'push'(block_arg)
+ retv.'push'(block_res)
goto next
next:
@@ -1176,7 +1254,7 @@ The min operator.
=cut
.sub 'infix:min'
- .param pmc args :slurpy
+ .param pmc args
# If we have no arguments, undefined.
.local int elems
@@ -1191,11 +1269,14 @@ have_args:
.local int i
cur_min = args[0]
i = 1
+ .local pmc compare
+ compare = get_hll_global 'infix:<=>'
find_min_loop:
if i >= elems goto find_min_loop_end
$P0 = args[i]
- $I0 = 'infix:cmp'($P0, cur_min)
- if $I0 != -1 goto not_min
+ #$I0 = cur_min.'infix:cmp'($P0)
+ $I0 = cur_min.compare($P0)
+ if $I0 != 1 goto not_min
set cur_min, $P0
not_min:
inc i
@@ -1213,7 +1294,7 @@ The max operator.
=cut
.sub 'infix:max'
- .param pmc args :slurpy
+ .param pmc args
# If we have no arguments, undefined.
.local int elems
@@ -1228,11 +1309,14 @@ have_args:
.local int i
cur_max = args[0]
i = 1
+ .local pmc compare
+ compare = get_hll_global 'infix:<=>'
find_max_loop:
if i >= elems goto find_max_loop_end
$P0 = args[i]
- $I0 = 'infix:cmp'($P0, cur_max)
- if $I0 != 1 goto not_max
+ #$I0 = 'infix:<=>'($P0, cur_max)
+ $I0 = cur_max.compare($P0)
+ if $I0 != -1 goto not_max
set cur_max, $P0
not_max:
inc i
View
101 src/classes/Failure.pir
@@ -0,0 +1,101 @@
+.namespace ['CardinalFailure']
+
+.sub 'onload' :anon :init :load
+ .local pmc meta, failureproto, exceptionproto
+ meta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ failureproto = meta.'new_class'('CardinalFailure', 'parent'=>'Undef CardinalAny', 'attr'=>'$!exception')
+ meta.'register'('Undef', 'parent'=>failureproto, 'protoobject'=>failureproto)
+ exceptionproto = meta.'new_class'('CardinalException', 'parent'=>'CardinalAny', 'attr'=>'$!exception')
+ meta.'register'('Exception', 'protoobject'=>exceptionproto)
+.end
+
+
+.sub '' :method :vtable('get_integer')
+ self.'!throw_unhandled'()
+ .return (0)
+.end
+
+.sub '' :method :vtable('get_number')
+ self.'!throw_unhandled'()
+ .return (0.0)
+.end
+
+.sub '' :method :vtable('get_string')
+ self.'!throw_unhandled'()
+ .return ('')
+.end
+
+
+.sub '!exception' :method
+ .local pmc exception
+ exception = getattribute self, '$!exception'
+ if null exception goto make_exception
+ $I0 = isa exception, 'Exception'
+ if $I0 goto have_exception
+ make_exception:
+ exception = new 'Exception'
+ exception['message'] = 'Use of uninitialized value'
+ setattribute self, '$!exception', exception
+ have_exception:
+ .return (exception)
+.end
+
+
+.sub '!throw_unhandled' :method
+ $I0 = self.'handled'()
+ if $I0 goto done
+ $P0 = self.'!exception'()
+ $S0 = $P0['message']
+ $S0 = concat $S0, "\n"
+ printerr $S0
+ done:
+.end
+
+.sub 'ACCEPTS' :method
+ .param pmc other
+ $I0 = defined other
+ if $I0 goto defined
+ .return(1)
+ defined:
+ .return(0)
+.end
+
+
+.sub 'defined' :method
+ $P0 = self.'!exception'()
+ $P0['handled'] = 1
+ $P1 = get_hll_global ['Bool'], 'False'
+ .return ($P1)
+.end
+
+
+.sub 'handled' :method
+ .local pmc exception
+ exception = self.'!exception'()
+ $I0 = exception['handled']
+ .return ($I0)
+.end
+
+
+.sub 'perl' :method
+ .return ('undef')
+.end
+
+
+.namespace []
+.sub 'undef'
+ .param pmc x :slurpy
+ ## 0-argument test, RT#56366
+ ## but see also C<< term:sym<undef> >> in STD.pm
+ unless x goto no_args
+ die "Obsolete use of undef; in Perl 6 please use undefine instead"
+ no_args:
+ $P0 = new 'Failure'
+ .return ($P0)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
94 src/classes/GC.pir
@@ -0,0 +1,94 @@
+## $Id: GC.pir 1 2008-09-27 00:00:00Z dmknopp $
+
+=head1 TITLE
+
+GC - Cardinal GC class
+
+=head1 DESCRIPTION
+
+=head2 Functions
+
+=over
+
+=item onload()
+
+Perform initializations and create the GC class
+
+=cut
+
+.namespace ['GC']
+
+.sub 'onload' :anon :init :load
+ .local pmc cardinalmeta
+ $P0 = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ cardinalmeta = $P0.'new_class'('GC', 'parent'=>'', 'attr'=>'$!disabled')
+ #$P2 = cardinalmeta.'HOW'()
+ #$P1 = new 'CardinalInteger'
+ #$P1 = 0
+ #setattribute $P2, '$!disabled', $P1
+ #set_hll_global ['GC'], '!CARDINALMETA', cardinalmeta
+.end
+
+.sub 'get_bool' :vtable
+ .return (1)
+.end
+
+#.sub 'get_string' :vtable
+# $S0 = 'GC'
+# .return ($S0)
+#.end
+
+.sub 'init' :vtable('init')
+ $P1 = new 'CardinalInteger'
+ $P1 = 0
+ setattribute self, '$!disabled', $P1
+.end
+
+.sub 'disable' :method
+ $P0 = getattribute self, "$!disabled"
+ #could have been null, need to make this class a singleton with these a class methods, not instance methods
+ if $P0 == 1 goto already_disabled
+ goto disable
+ disable:
+ $P1 = new 'CardinalInteger'
+ $P1 = 1
+ setattribute self, '$!disabled', $P1
+ collectoff
+ $P0 = 'CardinalString'
+ $P0 = 'false'
+ .return ($P0)
+ already_disabled:
+ $P0 = 'CardinalString'
+ $P0 = 'true'
+ .return ($P0)
+.end
+
+.sub 'enable' :method
+ $P0 = getattribute self, "$!disabled"
+ if $P0 == 1 goto enable
+ goto already_enabled
+ already_enabled:
+ $P0 = 'CardinalString'
+ $P0 = 'false'
+ .return ($P0)
+ enable:
+ $P1 = new 'CardinalInteger'
+ $P1 = 0
+ setattribute self, '$!disabled', $P1
+ collecton
+ $P0 = 'CardinalString'
+ $P0 = 'true'
+ .return ($P0)
+.end
+
+.sub 'start' :method
+ collect
+ $P0 = get_hll_global 'nil'
+ .return ($P0)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
112 src/classes/Integer.pir
@@ -46,6 +46,10 @@ Returns a Perl representation of the CardinalInteger.
.return($S0)
.end
+.sub 'integer?' :method
+ $P0 = get_hll_global['Bool'], 'True'
+ .return($P0)
+.end
=item to_s()
@@ -59,6 +63,71 @@ Returns a CardinalString representation of the CardinalInteger.
.return($P0)
.end
+=item
+to_i()
+to_int()
+floor()
+ceil()
+round()
+truncate()
+
+All return C<self>
+
+=cut
+
+.sub 'to_i' :method
+ .return(self)
+.end
+
+.sub 'to_int' :method
+ .return(self)
+.end
+
+.sub 'floor' :method
+ .return(self)
+.end
+
+.sub 'ceil' :method
+ .return(self)
+.end
+
+.sub 'round' :method
+ .return(self)
+.end
+
+.sub 'truncate' :method
+ .return(self)
+.end
+
+.sub 'numerator' :method
+ .return(self)
+.end
+
+=item
+
+Returns 1
+
+=cut
+
+.sub 'denominator' :method
+ $P0 = new 'CardinalInteger'
+ $P0 = 1
+ .return($P0)
+.end
+
+
+=item gcd(num)
+
+Return the greatest common divisor of C<self> and num
+
+=cut
+
+.sub 'gcd' :method
+ .param num other
+ $N0 = self
+ gcd $I0, $N0, other
+ .return($I0)
+.end
=item downto(n, block)
@@ -99,6 +168,49 @@ Runs C<block> for each integer from the current value of the Integer up to n.
upto_done:
.end
+=item
+
+Runs C<block> for integer from 0 to value of C<self>
+
+=cut
+
+.include "hllmacros.pir"
+.sub 'times' :method
+ .param pmc block
+ $I0 = 0
+ $I1 = self
+ .While($I0 < $I1, {
+ block($I0)
+ inc $I0
+ })
+.end
+
+=item succ()
+
+Return C<self> plus 1
+
+=cut
+
+.sub 'succ' :method
+ $P0 = new 'CardinalInteger'
+ $P0 = 1
+ $P1 = 'infix:+'($P0, self)
+ .return ($P1)
+.end
+
+=item next()
+
+Return C<self> plus 1
+
+=cut
+
+.sub 'next' :method
+ $P0 = new 'CardinalInteger'
+ $P0 = 1
+ $P1 = 'infix:+'($P0, self)
+ .return ($P1)
+.end
+
=back
View
156 src/classes/Kernel.pir
@@ -0,0 +1,156 @@
+## $Id: Object.pir 29852 2008-07-29 17:49:39Z dmknopp $
+
+=head1 TITLE
+
+Kernel - Cardinal Kernel class
+
+=head1 DESCRIPTION
+
+=head2 Functions
+
+=over
+
+=item onload()
+
+Perform initializations and create the kernel class
+
+=cut
+
+.namespace ['Kernel']
+
+.sub 'onload' :anon :init :load
+ .local pmc cardinalmeta, kernelprototype
+ load_bytecode 'P6object.pbc'
+ $P0 = get_hll_global 'P6metaclass'
+ kernelprototype = $P0.'new_class'('Kernel', 'attr'=>'%!properties')
+ #cardinalmeta = $P0.'HOW'()
+ cardinalmeta = kernelprototype.'new'()
+ set_hll_global ['Kernel'], '!CARDINALMETA', cardinalmeta
+ #.local pmc cardinalmeta
+ #cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ #cardinalmeta.'new_class'('CardinalKernel')
+ #$P0 = cardinalmeta.'HOW'()
+ #set_hll_global ['CardinalKernel'], '!CARDINALMETA', $P0
+.end
+
+
+=item WHENCE()
+
+Return the invocant's auto-vivification closure.
+
+=cut
+
+.sub 'WHENCE' :method
+ $P0 = self.'WHAT'()
+ $P1 = $P0.'WHENCE'()
+ .return ($P1)
+.end
+
+=item get_bool(vtable)
+
+Returns true if the object is defined, false otherwise
+
+=cut
+
+.sub '' :vtable('get_bool')
+ $I0 = 'defined'(self)
+ .return ($I0)
+.end
+
+=item print() prints to stdout
+
+=item puts() print to stdout
+
+=item readline() read from stdin
+
+=cut
+
+.sub 'print' :method
+ .param pmc args :slurpy
+ $P0 = get_hll_global 'print'
+ .return $P0(self)
+.end
+
+.sub 'puts' :method
+ .param pmc args :slurpy
+ $P0 = get_hll_global 'puts'
+ .return $P0(args :flat)
+.end
+
+.sub 'readline' :method
+ .param pmc args :slurpy
+ $P0 = get_hll_global 'readline'
+ .return $P0(args)
+.end
+
+.sub 'printf' :method
+ .param pmc fmt
+ .param pmc args :slurpy
+ $P0 = get_hll_global 'print'
+ $P99 = get_hll_global ['Kernel'], '!CARDINALMETA'
+ $P1 = $P99.'sprintf'(fmt, args :flat)
+ .return $P0($P1)
+.end
+
+.sub 'sprintf' :method
+ .param pmc fmt
+ .param pmc args :slurpy
+ $P0 = new 'CardinalString'
+ sprintf $P0, fmt, args
+ .return ($P0)
+.end
+
+=item `(cmd)
+Call the OS with C<cmd>, return the ouput.
+=cut
+.sub '`' :method
+ .param string cmd
+ .local pmc pipe
+ print "cmd="
+ pipe = open cmd, "-|"
+ .local string buffer
+ .local pmc output
+ output = new 'CardinalString'
+ $S0 = pop pipe # pop buf layer
+ goto lp
+ lp:
+ buffer = read pipe, 256
+ output.'concat'(buffer)
+ if pipe goto lp
+ goto done
+ done:
+ .return(output)
+.end
+
+=item
+Call the OS, return C<true> if successful, otherwise C<false>
+=cut
+.sub 'system' :method
+ .param string syscall
+ spawnw $I0, syscall
+ if $I0 == 0 goto done_t
+ goto done_f
+ done_t:
+ $S0 = "true"
+ goto ret
+ done_f:
+ $S0 = "false"
+ goto ret
+ ret:
+ .return ($S0)
+.end
+
+.sub 'exit!' :method
+ .param int return
+ exit return
+.end
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
140 src/classes/Math.pir
@@ -0,0 +1,140 @@
+## $Id: Math.pir 1 2008-09-27 17:49:39Z dmknopp $
+
+=head1 TITLE
+
+Math - Cardinal Math class
+
+=head1 DESCRIPTION
+
+=head2 Functions
+
+=over
+
+=item onload()
+
+Perform initializations and create the Math class
+
+=cut
+
+.namespace ['Math']
+
+.sub 'onload' :anon :init :load
+ .local pmc cardinalmeta
+ $P0 = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ cardinalmeta = $P0.'new_class'('Math', 'parent'=>'', 'attr'=>'$!PI')
+ #cardinalmeta = $P0.'HOW'()
+ #set_hll_global ['Math'], '!CARDINALMETA', cardinalmeta
+
+ #.local pmc math_clazz, base_clazz
+ #base_clazz = class $P0
+ ###newclass math_clazz, 'Math'
+ ###math_clazz.'add_parent'(base_clazz)
+ #get_class $P0, "CardinalObject"
+ #subclass math_clazz, $P0, "Math"
+ #set_hll_global ['Math'], '!CARDINALMETA', math_clazz
+
+
+.end
+
+#=item WHENCE()
+#
+#Return the invocant's auto-vivification closure.
+#
+#=cut
+#.sub 'WHENCE' :method
+# $P0 = self.'WHAT'()
+# $P1 = $P0.'WHENCE'()
+# .return ($P1)
+#.end
+
+.sub 'get_bool' :vtable
+ .return (1)
+.end
+
+.sub 'initialize' :method
+ noop
+.end
+
+.sub 'get_string' :vtable
+ $S0 = 'Math'
+ .return ($S0)
+.end
+
+.sub 'cos' :method
+ .param num arg
+ cos $N0, arg
+ .return ($N0)
+.end
+
+.sub 'sin' :method
+ .param num arg
+ sin $N0, arg
+ .return ($N0)
+.end
+
+.sub 'acos' :method
+ .param num arg
+ acos $N0, arg
+ .return ($N0)
+.end
+
+.sub 'asin' :method
+ .param num arg
+ asin $N0, arg
+ .return ($N0)
+.end
+
+.sub 'asec' :method
+ .param num arg
+ asec $N0, arg
+ .return ($N0)
+.end
+
+.sub 'atan' :method
+ .param num arg
+ atan $N0, arg
+ .return ($N0)
+.end
+
+.sub 'cosh' :method
+ .param num arg
+ cosh $N0, arg
+ .return ($N0)
+.end
+
+.sub 'sinh' :method
+ .param num arg
+ sinh $N0, arg
+ .return ($N0)
+.end
+
+.sub 'sech' :method
+ .param num arg
+ sech $N0, arg
+ .return ($N0)
+.end
+
+.sub 'tanh' :method
+ .param num arg
+ tanh $N0, arg
+ .return ($N0)
+.end
+
+.sub 'log' :method
+ .param num arg
+ log2 $N0, arg
+ .return ($N0)
+.end
+
+.sub 'log10' :method
+ .param num arg
+ log10 $N0, arg
+ .return ($N0)
+.end
+
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
88 src/classes/Object.pir
@@ -133,7 +133,10 @@ Create a new object having the same class as the invocant.
.sub 'new' :method
.param pmc args :slurpy
.param pmc named_args :named :slurpy
-
+#say 'constructing a new object'
+#say self
+#say args
+#say named_args
# Instantiate.
.local pmc cardinalmeta
cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
@@ -185,6 +188,17 @@ Defines the .true method on all objects via C<prefix:?>.
.return 'prefix:?'(self)
.end
+=item get_bool(vtable)
+
+Returns true if he object is defined, false otherwise
+
+=cut
+
+.sub '' :vtable('get_bool')
+ $I0 = 'defined'(self)
+ .return ($I0)
+.end
+
=item print()
=item say()
@@ -215,11 +229,55 @@ Return a CardinalString representation of the object.
.return ($P0)
.end
+=item inspect()
+
+This is the same a to_s by default unless overriden
+
+=cut
+
+.sub 'inspect' :method
+ $P0 = self.'to_s'()
+.end
+
.sub 'puts' :method
$P0 = get_hll_global 'puts'
.return $P0(self)
.end
+=item !cloneattr(attrlist)
+
+Create a clone of self, also cloning the attributes given by attrlist.
+
+=cut
+
+.sub '!cloneattr' :method
+ .param string attrlist
+ .local pmc result
+ .local pmc cardinalmeta
+ cardinalmeta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ $P0 = cardinalmeta.get_parrotclass(self)
+ result = new $P0
+
+ .local pmc attr_it
+ attr_it = split ' ', attrlist
+ attr_loop:
+ unless attr_it goto attr_end
+ $S0 = shift attr_it
+ unless $S0 goto attr_loop
+ $P1 = getattribute self, $S0
+ unless $P1 goto set_default
+ $P1 = clone $P1
+ setattribute result, $S0, $P1
+ goto attr_loop
+ set_default:
+ $P2 = new 'CardinalInteger'
+ $P2 = 0
+ setattribute result, $S0, $P2
+ goto attr_loop
+ attr_end:
+ .return (result)
+.end
+
=item methods()
Get a list of all methods in the object.
@@ -243,6 +301,34 @@ Get a list of all methods in the object.
.return(method_list)
.end
+.sub 'class' :method
+ .return self.'WHAT'()
+.end
+
+.sub 'defined' :method
+ $P0 = get_hll_global ['Bool'], 'False'
+ .return ($P0)
+.end
+
+.sub 'nil?' :method
+ $P0 = get_hll_global 'nil'
+ if self == $P0 goto yes
+ goto no
+ yes:
+ $P0 = get_hll_global ['Bool'], 'True'
+ .return ($P0)
+ no:
+ $P0 = get_hll_global ['Bool'], 'False'
+ .return ($P0)
+.end
+
+.sub 'freeze' :method
+ freeze $S0, self
+ #self = $S0
+ #.return ($S0)
+ .return (self)
+.end
+
=back
=cut
View
524 src/classes/Range.pir
@@ -0,0 +1,524 @@
+## $Id: CardinalRange.pir 30797 2008-09-05 18:58:32Z dmknopp $
+
+=head1 NAME
+
+src/classes/CardinalRange.pir - methods for the CardinalRange class
+
+=head1 DESCRIPTION
+
+=head2 Methods
+
+=over 4
+
+=cut
+
+.namespace ['CardinalRange']
+
+.sub 'onload' :anon :load :init
+ .local pmc meta, proto
+ meta = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ proto = meta.'new_class'('CardinalRange', 'parent'=>'CardinalAny CardinalObject', 'attr'=>'$!from $!to $!from_exclusive $!to_exclusive')
+ #meta.'register'('CardinalRange', 'CardinalObject', 'protoobject'=>proto)
+.end
+
+=item VTABLE_get integer (vtable method)
+
+=item VTABLE_get_number (vtable method)
+
+=item VTABLE_get_string (vtable method)
+
+=cut
+
+.sub 'VTABLE_get_integer' :method :vtable('get_integer')
+ $P0 = self.'list'()
+ $I0 = $P0
+ .return ($I0)
+.end
+
+.sub 'VTABLE_get_number' :method :vtable('get_number')
+ $P0 = self.'list'()
+ $N0 = $P0
+ .return ($N0)
+.end
+
+.sub 'VTABLE_get_string' :method :vtable('get_string')
+ $P0 = self.'list'()
+ $S0 = $P0
+ .return ($S0)
+.end
+
+
+=item ACCEPTS(topic)
+
+Determines if topic is within the range or equal to the range.
+
+=cut
+
+.sub 'ACCEPTS' :method
+ .param pmc topic
+
+ $I0 = isa topic, 'CardinalRange'
+ unless $I0 goto value_in_range_check
+ $I0 = self.'from'()
+ $I1 = topic.'from'()
+ if $I0 != $I1 goto false
+ $I0 = self.'to'()
+ $I1 = topic.'to'()
+ if $I0 != $I1 goto false
+ $P0 = getattribute self, "$!from_exclusive"
+ $P1 = getattribute topic, "$!from_exclusive"
+ if $P0 != $P1 goto false
+ $P0 = getattribute self, "$!to_exclusive"
+ $P1 = getattribute topic, "$!to_exclusive"
+ if $P0 != $P1 goto false
+ goto true
+
+ value_in_range_check:
+ $I0 = self.'!from_test'(topic)
+ unless $I0 goto false
+ $I0 = self.'!to_test'(topic)
+ unless $I0 goto false
+
+ true:
+ $P0 = get_hll_global ['Bool'], 'True'
+ .return ($P0)
+ false:
+ $P0 = get_hll_global ['Bool'], 'False'
+ .return ($P0)
+.end
+
+
+=item clone() (vtable method)
+
+Create a clone of the CardinalRange.
+
+=cut
+
+.sub 'clone' :method :vtable
+ $P0 = self.'!cloneattr'('$!from $!to $!from_exclusive $!to_exclusive')
+ .return ($P0)
+.end
+
+
+=item from()
+
+=item to()
+
+Gets the beginning or end of the range.
+
+=cut
+
+.sub 'from' :method
+ $P0 = getattribute self, '$!from'
+ .return ($P0)
+.end
+
+=item
+
+=cut
+
+.sub 'to' :method
+ $P0 = getattribute self, '$!to'
+ .return ($P0)
+.end
+
+=item to_a
+
+ Generates and returns this range as an array. This will eventually be refactored w/ the other Enumerable methods This will eventually be refactored w/ the other Enumerable methods.
+
+=cut
+
+.sub 'to_a' :method
+ $P0 = self.'list'()
+ .return ($P0)
+.end
+
+.sub 'to_s' :method
+ $P0 = getattribute self, '$!from_exclusive'
+ $P1 = getattribute self, '$!to_exclusive'
+ $P2 = $P0 && $P1
+ if $P2 goto build_exclusive
+ goto build_inclusive
+ build_inclusive:
+ $S0 = '..'
+ goto build_return
+ build_exclusive:
+ $S0 = '...'
+ goto build_return
+ build_return:
+ $P0 = getattribute self, '$!from'
+ $P1 = getattribute self, '$!to'
+ $P3 = new 'CardinalString'
+ $P3.'concat'($P0)
+ $P3.'concat'($S0)
+ $P3.'concat'($P1)
+ .return ($P3)
+.end
+
+=item iterator() (vtable method)
+
+Return an iterator for the CardinalRange. Since CardinalRanges are already
+iterators, we can just return a clone.
+
+=cut
+
+.sub 'iterator' :method :vtable('get_iter')
+ $P0 = clone self
+ .return ($P0)
+.end
+
+
+=item list()
+
+Generate the CardinalRange in list context. Currently we generate all
+of the elements in the range; when we have lazy lists we can
+just return a clone of the CardinalRange.
+
+=cut
+
+.sub 'list' :method
+ .local pmc range_it, result
+ range_it = self.'iterator'()
+ result = new 'CardinalArray'
+ range_loop:
+ unless range_it goto range_end
+ $P0 = shift range_it
+ push result, $P0
+ goto range_loop
+ range_end:
+ .return (result)
+.end
+
+
+=item min()
+
+=item minmax()
+
+=item max()
+
+=cut
+
+.namespace ['CardinalRange']
+
+=item
+ Return first element in CardinalRange. Will later be refactored as part of the Enumerable module.
+=cut
+.sub 'min' :method
+ .return self.'from'()
+.end
+
+=item
+ Return first element in CardinalRange.
+=cut
+.sub 'begin' :method
+ .return self.'from'()
+.end
+
+=item
+ Return first element in CardinalRange.
+=cut
+.sub 'first' :method
+ .return self.'from'()
+.end
+
+.sub 'minmax' :method
+ $P0 = self.'from'()
+ $P1 = self.'to'()
+ $P2 = get_hll_global 'list'
+ .return $P2($P0, $P1)
+.end
+
+=item
+ Return last element in CardinalRange. Will later be refactored as part of the Enumerable module.
+=cut
+.sub 'max' :method
+ .return self.'to'()
+.end
+
+=item
+ Return last element in CardinalRange.
+=cut
+.sub 'last' :method
+ .return self.'to'()
+.end
+
+=item
+ Return last element in CardinalRange.
+=cut
+.sub 'end' :method
+ .return self.'to'()
+.end
+
+=item
+Return true if the parameter is located with this CardinalRange
+=cut
+.sub 'covers?' :method
+ .param pmc test
+ $P0 = self.'include?'(test)
+ .return ($P0)
+.end
+
+=item
+Return true if the parameter is located with this CardinalRange
+1.9 does a succ on the last element if it isnt a integer, so this doesnt work
+=cut
+.sub 'include?' :method
+ .param pmc test
+ $P0 = self.'from'()
+ $P1 = self.'to'()
+
+ $I0 = self.'!from_test'(test)
+ if $I0 == 0 goto out_of_bounds
+ $I0 = self.'!to_test'(test)
+ if $I0 == 0 goto out_of_bounds
+ #if test <= $P0 goto out_of_bounds
+ #if test >= $P1 goto out_of_bounds
+ $P3 = get_hll_global ['Bool'], 'True'
+ .return ($P3)
+ out_of_bounds:
+ $P3 = get_hll_global ['Bool'], 'False'
+ say 'out of bounds'
+ #throw 'out of bounds!'
+ .return ($P3)
+.end
+
+=item
+
+Return C<True> if the parameter is a member of this CardinalRange
+
+=cut
+
+.sub 'member?' :method
+ .param pmc test
+ $P0 = self.'include?'(test)
+ .return ($P0)
+.end
+
+
+=item pop() (vtable_method)
+
+Generate the next element at the end of the CardinalRange.
+
+=cut
+
+.sub 'pop' :method :vtable('pop_pmc')
+ .local pmc to, toexc, value
+ to = getattribute self, '$!to'
+ toexc = getattribute self, '$!to_exclusive'
+ value = 'postfix:--'(to)
+ unless toexc goto have_value
+ value = clone to
+ have_value:
+ $I0 = self.'!from_test'(value)
+ if $I0 goto success
+ #value = '!FAIL'('Undefined value popped from empty range')
+ value = new 'Undef'
+ success:
+ .return (value)
+.end
+
+
+=item shift() (vtable_method)
+
+Generate the next element at the front of the CardinalRange.
+
+=cut
+
+.sub 'shift' :method :vtable('shift_pmc')
+ .local pmc from, fromexc, value
+ from = getattribute self, '$!from'
+ fromexc = getattribute self, '$!from_exclusive'
+ value = 'postfix:++'(from)
+ unless fromexc goto have_value
+ value = clone from
+ have_value:
+ $I0 = self.'!to_test'(value)
+ if $I0 goto success
+ #value = '!FAIL'('Undefined value shifted from empty range')
+ value = new 'Undef'
+ success:
+ .return (value)
+.end
+
+
+=item true()
+
+Return true if there are any more values to iterate over.
+
+=cut
+
+.sub 'true' :method :vtable('get_bool')
+ .local pmc from, fromexc
+ from = getattribute self, '$!from'
+ fromexc = getattribute self, '$!from_exclusive'
+ unless fromexc goto have_value
+ from = clone from
+ 'postfix:++'(from)
+ have_value:
+ $I0 = self.'!to_test'(from)
+ .return ($I0)
+.end
+
+
+.sub 'initialize' :method :multi(_)
+ .param pmc hash :named :slurpy
+ $P1 = hash["$!from_exclusive"]
+ defined $I0, $P1
+ $I0 = !$I0
+ if $I0 goto default
+ setattribute self, '$!from_exclusive', $P1
+ $P2 = hash["$!to_exclusive"]
+ setattribute self, '$!to_exclusive', $P2
+ goto finish
+ default:
+ $P0 = new 'CardinalInteger'
+ $P0 = 0
+ setattribute self, '$!from_exclusive', $P0
+ setattribute self, '$!to_exclusive', $P0
+ goto finish
+ finish:
+ $P3 = hash["$!from"]
+ setattribute self, '$!from', $P3
+ $P4 = hash["$!to"]
+ setattribute self, '$!to', $P4
+.end
+
+.sub 'initialize' :method :multi(_,_,_)
+ .param pmc from
+ .param pmc to
+ $P0 = new 'CardinalInteger'
+ $P0 = 0
+ setattribute self, '$!from_exclusive', $P0
+ setattribute self, '$!to_exclusive', $P0
+ setattribute self, '$!from', from
+ setattribute self, '$!to', to
+.end
+
+=item each(block)
+
+Run C<block> once for each item in C<self>, with the item passed as an arg.
+
+=cut
+
+.sub 'each' :method
+ .param pmc block :named ("!BLOCK")
+ $P0 = self.'first'()
+ $P1 = $P0.'HOW'()
+ $I0 = $P1.can(self,'succ')
+ if $I0 != 0 goto continuous_range
+ $P0 = self.'iterator'()
+ goto each_loop
+ continuous_range:
+ $P1 = new 'CardinalString'
+ $P1 = "Cant iterate from "
+ $P2 = $P0.'class'()
+ $P1.'concat'($P2)
+#say "continous_range..."
+#say $P2
+ .return ($P2)
+ #throw $P2
+ each_loop:
+ unless $P0 goto each_loop_end
+ $P1 = shift $P0
+ block($P1)
+ goto each_loop
+ each_loop_end:
+.end
+
+=back
+
+=head2 Operators
+
+=over 4
+
+=item infix:<..>
+
+=item infix:<...>
+
+Construct a range from the endpoints.
+
+=cut
+
+.namespace []
+.sub 'infix:..'
+ .param pmc from
+ .param pmc to
+ .local pmc proto
+ proto = get_hll_global 'CardinalRange'
+ $P1 = proto.'new'('$!from'=>from, '$!to'=>to)
+ .return ($P1)
+.end
+
+.sub 'infix:...'
+ .param pmc from
+ .param pmc to
+ .local pmc proto, true, false
+ proto = get_hll_global 'CardinalRange'
+ true = get_hll_global ['Bool'], 'True'
+ false = get_hll_global ['Bool'], 'False'
+ $P0 = proto.'new'('$!from'=>from, '$!to'=>to, '$!from_exclusive'=>false, '$!to_exclusive'=>true)
+ .return ($P0)
+.end
+
+=back
+
+=head2 Private methods
+
+=over 4
+
+=item !from_test(topic)
+
+=item !to_test(topic)
+
+Returns true if C<topic> is greater than C<.from> / less than C<.to>,
+honoring exclusive flags.
+
+=cut
+
+.namespace ['CardinalRange']
+.sub '!from_test' :method
+ .param pmc topic
+ .local pmc from, fromexc
+ from = getattribute self, '$!from'
+ fromexc = getattribute self, '$!from_exclusive'
+ if fromexc goto exclusive_test
+ $I0 = isge topic, from
+ .return ($I0)
+ exclusive_test:
+ $I0 = isgt topic, from
+ .return ($I0)
+.end
+
+.sub '!to_test' :method
+ .param pmc topic
+ .local pmc to, toexc
+ to = getattribute self, '$!to'
+ $I0 = isa to, 'String'
+ unless $I0 goto test_value
+ $S0 = topic
+ $I0 = length $S0
+ $S1 = to
+ $I1 = length $S1
+ eq $I0, $I1, test_value
+ $I0 = islt $I0, $I1
+ .return ($I0)
+ test_value:
+ toexc = getattribute self, '$!to_exclusive'
+ if toexc goto exclusive_test
+ $I0 = isle topic, to
+ .return ($I0)
+ exclusive_test:
+ $I0 = islt topic, to
+ .return ($I0)
+.end
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
View
6 src/classes/String.pir
@@ -309,6 +309,9 @@ Returns a copy of C<self> with all lower case letters converted to upper case
.return (retv)
.end
+=item
+ TODO: Read from the global record separator
+=cut
.sub 'chomp' :method
.param string splitby :optional
.param int custom_split :opt_flag
@@ -335,6 +338,9 @@ Returns a copy of C<self> with all lower case letters converted to upper case
.return(retv)
.end
+=item
+ TODO: Read from the global record separator
+=cut
.sub 'chomp!' :method
.param string splitby :optional
.param int custom_split :opt_flag
View
206 src/classes/Time.pir
@@ -0,0 +1,206 @@
+## $Id: Time.pir 29852 2008-07-29 17:49:39Z dmknopp $
+
+=head1 TITLE
+
+Time - Cardinal Time class
+
+=head1 DESCRIPTION
+
+=head2 Functions
+
+=over
+
+=item onload()
+
+Perform initializations and create the Time class
+
+=cut
+
+
+.namespace ['Time']
+
+.include "tm.pasm"
+
+.sub 'onload' :anon :init :load
+ .local pmc cardinalmeta
+ $P0 = get_hll_global ['CardinalObject'], '!CARDINALMETA'
+ cardinalmeta = $P0.'new_class'('Time', 'parent'=>'CardinalObject', 'attr'=>'$!time_in_millis $!gmt')
+ cardinalmeta = $P0.'HOW'()
+ set_hll_global ['Time'], '!CARDINALMETA', cardinalmeta
+.end
+
+
+=item WHENCE()
+
+Return the invocant's auto-vivification closure.
+
+=cut
+
+.sub 'WHENCE' :method
+ $P0 = self.'WHAT'()
+ $P1 = $P0.'WHENCE'()
+ .return ($P1)
+.end
+
+=item get_bool(vtable)
+
+Returns true if he object is defined, false otherwise
+
+=cut
+
+.sub '' :vtable('get_bool')
+ $I0 = 'defined'(self)
+ .return ($I0)
+.end
+
+.sub 'initialize' :method
+ time $I0
+ $P0 = new 'CardinalInteger'
+ $P0 = $I0
+ setattribute self, '$!time_in_millis', $P0
+ $P1 = get_hll_global['Bool'], 'False'
+ setattribute self, '$!gmt', $P1
+.end
+
+#.sub 'now'
+ #call CardinalObject super .new
+ #return the object returned by super
+#.end
+
+.sub 'to_s' :method :vtable('get_string')
+ .local pmc is_gmt, to_s
+ to_s = new 'CardinalString'
+ $P0 = getattribute self, '$!time_in_millis'
+ $I0 = $P0
+ is_gmt = getattribute self, '$!gmt'
+ if is_gmt goto g_time
+ goto l_time
+ g_time:
+ $S0 = gmtime $I0
+ to_s = $S0
+ goto done
+ l_time:
+ $S0 = localtime $I0
+ to_s = $S0
+ goto done
+ done:
+ .return (to_s)
+.end
+
+.sub 'to_i' :method
+ .local int epoch_sec
+ $P0 = getattribute self, '$!time_in_millis'
+ epoch_sec = $P0
+ .return (epoch_sec)
+.end
+
+.sub 'to_f' :method
+ .local pmc epoch_sec
+ $P0 = getattribute self, '$!time_in_millis'
+ epoch_sec = new 'Float'
+ epoch_sec = $P0
+ .return (epoch_sec)
+.end
+
+.sub 'gmt?' :method
+ $P0 = getattribute self, '$!gmt'
+ .return ($P0)
+.end
+
+.sub 'gmtime' :method
+ .local pmc is_gmt
+
+ is_gmt = getattribute self, '$!gmt'
+ if is_gmt goto done
+
+ $P1 = get_hll_global['Bool'], 'True'
+ setattribute self, '$!gmt', $P1
+ goto done
+
+ done:
+ .return (self)
+.end
+
+.sub '#!parse_time_array' :method
+ .param int offset
+ .local pmc is_gmt
+ .local pmc return_value
+ return_value = new 'CardinalInteger'
+ $P0 = getattribute self, '$!time_in_millis'
+ $I0 = $P0
+ is_gmt = getattribute self, '$!gmt'
+
+ if is_gmt goto decodegmt
+ goto decodelocal
+
+ decodegmt:
+ decodetime $P1, $I0
+ $I0 = $P1[offset]
+ return_value = $I0
+ goto done
+ decodelocal:
+ decodelocaltime $P1, $I0
+ $I0 = $P1[offset]
+ return_value = $I0
+ goto done
+ done:
+ .return (return_value)
+
+ #print out all values in the time array
+ #$P2 = new 'Iterator', $P0
+ #each_loop:
+ # unless $P2 goto done
+ # $P3 = shift $P2
+ # say $P3
+ # goto each_loop
+.end
+
+.sub 'sec' :method
+ $P0 = self.'#!parse_time_array'(.TM_SEC)
+ .return ($P0)
+.end
+
+.sub 'min' :method
+ $I0 = self.'#!parse_time_array'(.TM_MIN)
+ .return ($I0)
+.end
+
+.sub 'hour' :method
+ $I0 = self.'#!parse_time_array'(.TM_HOUR)
+ .return ($I0)
+.end
+
+.sub 'day' :method
+ .return self.'mday'()
+.end
+
+.sub 'mday' :method
+ $I0 = self.'#!parse_time_array'(.TM_MDAY)
+ .return ($I0)
+.end
+
+.sub 'yday' :method
+ $I0 = self.'#!parse_time_array'(.TM_YDAY)
+ .return ($I0)
+.end
+
+.sub 'wday' :method
+ $I0 = self.'#!parse_time_array'(.TM_WDAY)
+ .return ($I0)
+.end
+
+.sub 'month' :method
+ $I0 = self.'#!parse_time_array'(.TM_MON)
+ .return ($I0)
+.end
+
+.sub 'year' :method
+ $I0 = self.'#!parse_time_array'(.TM_YEAR)
+ .return ($I0)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
2  src/parser/actions.pm
@@ -351,6 +351,8 @@ method constant_variable($/) {
if $name eq 'Array' { $name := "CardinalArray"; }
elsif $name eq 'Hash' { $name := "CardinalHash"; }
elsif $name eq 'String' { $name := "CardinalString"; }
+ elsif $name eq 'Range' { $name := "CardinalRange"; }
+ elsif $name eq 'Integer' { $name := "CardinalInteger"; }
my $past := PAST::Var.new( :name($name), :scope('package'), :node($/), :viviself('Undef'), :namespace( @a ) );
make $past;
}
View
20 src/parser/grammar.pg
@@ -136,6 +136,12 @@ rule super_call {
}
token operation {
+ 'class'|
+ 'nil?' |
+ 'next' |
+ 'begin'|
+ 'end' |
+ '`' |
<.identifier> ('!'|'?')?
}
@@ -410,7 +416,7 @@ token local_variable {
}
token constant_variable {
- <before <[A..Z]>> <ident>
+ <.before <[A..Z]>> <.ident>
{*}
}
@@ -498,11 +504,11 @@ proto 'infix:**=' is equiv('infix:=')
proto 'ternary:? :' is tighter('infix:=')
is pirop('if') { ... }
-proto 'infix:..' is tighter('ternary:? :')
- is parsed(&primary) { ... }
+proto 'infix:..' is tighter('ternary:? :') { ... }
+ #is parsed(&primary) { ... }
#is pirop('add') { ... }
-proto 'infix:...' is equiv('infix:...') { ... }
+proto 'infix:...' is equiv('infix:..') { ... }
proto 'infix:||' is tighter('infix:..')
is pasttype('unless') { ... }
@@ -546,6 +552,12 @@ proto 'infix:/' is equiv('infix:*') { ... }
proto 'infix:%' is equiv('infix:*')
is pirop('mod') { ... }
+proto 'postfix:++' is tighter('infix:*')
+ is pirop('n_add') { ... }
+
+proto 'postfix:--' is tighter('infix:*')
+ is pirop('n_sub') { ... }
+#
#proto 'prefix:+' is tighter('infix:*') { ... }
#proto 'prefix:-' is equiv('prefix:+') { ... }
#proto 'prefix:!' is equiv('prefix:+') { ... }
View
8 test.rb
@@ -35,6 +35,14 @@ def is(got,expected,desc='')
proclaim(got == expected, desc)
end
+def isgt(got,expected,desc='')
+ proclaim(got > expected, desc)
+end
+
+def isge(got,expected,desc='')
+ proclaim(got >= expected, desc)
+end
+
def isnt(got,expected,desc='')
proclaim(got != expected, desc)
end
Please sign in to comment.
Something went wrong with that request. Please try again.