vidarh / writing-a-compiler-in-ruby

Code from my series on writing a Ruby compiler in Ruby

This URL has Read+Write access

writing-a-compiler-in-ruby / testargs.rb
100644 19 lines (14 sloc) 0.293 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Comments are now allowed
 
def f test, *arr
  i = 0
  while i < (numargs - 1)
    printf("test=%ld, i=%ld, numargs=%ld, arr[i]=%ld\n",test,i,numargs,arr[i])
    i = i + 1
  end
end
 
def g i, j
  k = 42
  printf("numargs=%ld, i=%ld,j=%ld,k=%ld\n",numargs,i,j,k)
end
 
f(123,42,43,45)
g(23,67)