Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Jobs/projects list? Re:

From: alfred_pang:inetco at: 28-Aug-2000 15:30

This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C0113F.9CB50136 Content-Type: text/plain; charset="iso-8859-1"
> Is there a jobs/projects needing help, talent available list for Rebols > (Rebol programmers)?
Why yes!
> The Third Annual ICFP Programming Contest > http://www.cs.cornell.edu/icfp/ > > 'On Saturday, August 26, 2000 at 5PM EST a challenge task will be > posted on the Internet and mailed to all registered participants.' > > Anyone daring enought to take on the challenge with REBOL?
I have finished up a good chunk of the GML parsing (grammer.r) and started work on the renderer (renderer.r and threed.r). However RealLife and WeakMathSkills is preventing me from finishing it up. 'do %render.r' should create a tiny 'testing.ppm' file containing a picture of a rendered plane. --- Although I wasn't able to finish it, I had a lot of fun with the parsing. REBOL parses like a hot knife through butter! My problem is that I've never written any 3-d code in my life so that bit was going to be out of my reach for a while. If there are any enterprising programmers out there, feel free (no strings attached) to use this code as you please. There are still about 20 hours left till the deadline. Top prize is $1000US and unlimited bragging rights! ------_=_NextPart_000_01C0113F.9CB50136 Content-Type: application/octet-stream; name="grammer.r" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="grammer.r" REBOL [=0A Title: "GML grammer"=0A Date: 25-Aug-2000=0A]=0A=0A;--------------------------------------------------------------------------=0A;parse stuff=0A=0Adigit-char: charset "0123456789"=0Aalpha-char: charset abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ =0Awhitesp-char: charset " ^(tab)^(line)"=0Aspacers-tok: [ some whitesp-char ]=0Aoperator-tok: [=0A copy o=0A [=0A "acos" |=0A "addi" |=0A "addf" |=0A "apply" |=0A "asin" |=0A "clampf" |=0A "cone" |=0A "cos" |=0A "cube" |=0A "cylinder" |=0A "difference" |=0A "divi" |=0A "divf" |=0A "eqi" |=0A "eqf" |=0A "floor" |=0A "frac" |=0A "getx" |=0A "gety" |=0A "getz" |=0A "get" |=0A "if" |=0A "intersect" |=0A "length" |=0A "lessi" |=0A "lessf" |=0A "light" |=0A "modi" |=0A "muli" |=0A "mulf" |=0A "negi" |=0A "negf" |=0A "plane" |=0A "pointlight" |=0A "point" |=0A "real" |=0A "render" |=0A "rotatex" |=0A "rotatey" |=0A "rotatez" |=0A "scale" |=0A "sin" |=0A "sphere" |=0A "spotlight" |=0A "sqrt" |=0A "subi" |=0A "subf" |=0A "translate" |=0A "union" |=0A "uscale" ]=0A (tgml join "[gml-op " [ o " ]" ] )=0A]=0A=0Aident-rul: [=0A alpha-char 0 128 [ digit-char | alpha-char ]=0A]=0A=0Aident-tok: [=0A copy i ident-rul (tgml join "[gml-ident " [ i " ]" ] )=0A]=0Abinder-tok: [=0A "/" copy b ident-rul (tgml join "[gml-binder " [ b " ]" ] )=0A]=0Aboolean-tok: [=0A copy b ["true" | "false"] (tgml join "[gml-boolean " [ b " ]" ] )=0A]=0A=0Ainteger-tok: [ opt "-" 1 48 digit-char ]=0Aexponent-tok: [ [ "e" | "E" ] opt "-" 1 48 digit-char ]=0Areal-tok: [ opt "-" 1 48 digit-char "." 1 48 digit-char opt=0Aexponent-tok ]=0Anumber-tok: [=0A [=0A copy r real-tok=0A (tgml join "[gml-real " [ r " ]" ] )=0A ] |=0A [=0A copy i integer-tok=0A (tgml join "[gml-integer " [ i " ]" ] )=0A ]=0A]=0Astring-tok: [=0A copy s "^"" thru "^""=0A (tgml join "[gml-string " [ s " ]" ] )=0A]=0A=0Acomment-rul: [ "%" [ to "^/" | to end ] ]=0A=0Atoken: [=0Aoperator-tok ( comment { print "operator" }) |=0Aboolean-tok ( comment { print "boolean" }) |=0Anumber-tok |=0Astring-tok ( comment { print "string" }) |=0Aident-tok ( comment { print "ident" }) |=0Abinder-tok ( comment { print "binder"}) |=0Acomment-rul ( comment { print "comment" }) ]=0A=0Atoken-group: [=0A [=0A token |=0A [=0A "[" (tgml "[ gml-array ")=0A spacers-tok any token-group "]"=0A (tgml " ]")=0A ] |=0A [=0A "{" (tgml "[ gml-fn [] [" )=0A spacers-tok any token-group "}"=0A (tgml " ] ]")=0A ]=0A ]=0A [ spacers-tok | to end ]=0A]=0A=0Agml: [ any whitesp-char any token-group ]=0A=0A=0A=0Acomment {=0Aprint "test1:"=0Aprint parse/case/all test1 gml=0Aprint "^/test2:"=0Aprint parse/case/all test2 gml=0Aprint "^/test3:"=0Aprint parse/case/all test3 gml=0A}=0A=0Atgml: func [ str [string!] ] [=0A append gml-program str=0A append gml-program " "=0A]=0A=0Aparse-gml: func [ str /local parseok ] [=0A gml-program: copy "["=0A parseok: parse/case/all str gml=0A if not parseok [ throw 'gml-error-parse-problems ]=0A tgml "]"=0A do gml-program=0A]=0A=0A;---------------------------------------------------------------------=0A=0Acomment {=0A=0A[ gml-boolean true ] ; true/false=0A[ gml-integer 1 ] ; integer numbers=0A[ gml-real 1.2e10 ] ; real numbers=0A[ gml-string "alfred" ] ; strings=0A[ gml-op addi ] ; GML operators=0A[ gml-binder inc ] ; binder operation=0A[ gml-ident x ] ; identifier=0A[ gml-point 1 2 3 ] ; point=0A=0A[ gml-fn ; function=0A [ x [ gml-integer 1 ] y [ gml-integer 2 ] ] ; environment=0A [ [ gml-ident x ] [ gml-op addi ] ] ; code=0A]=0A; note that we don't have environment for the function at parse time=0A; so we will get something like this=0A[ gml-fn ; function=0A [ ] ; what environment?=0A [ [ gml-ident x ] [ gml-op addi ] ] ; code=0A]=0A; when our interpreter hits gml-fn, then we will duplicate the environment=0Afor the function=0A=0A[ gml-array [ gml-integer 1 ] [ gml-real 1.2e3 ] ] ; array=0A=0A[ gml-light [ 1 1 1 0 ] [ 1 1 1 ] ] ; direction and color=0A=0A}=0A=0A;---------------------------------------------------------------------=0A=0Agml-env: make object! [=0A env: copy []=0A get: func [ ident /local ret ] [=0A ret: select env ident=0A if none? ret [ throw 'gml-error ]=0A ret=0A ]=0A set: func [ ident val /local exist ] [=0A exist: find env ident=0A either none? exist [=0A append env ident=0A append/only env val=0A ] [=0A exist: next exist=0A remove exist=0A insert/only exist val=0A ]=0A ]=0A]=0A=0Agml-stack!: make object! [=0A=0A stack: copy []=0A push: func [o] [insert/only stack o]=0A pop: func [ /local h] [=0A if len == 0 [ throw 'gml-error-empty-stack ]=0A h: copy first stack remove stack h=0A ]=0A len: func [] [ length? stack ]=0A=0A return-real: func [ r ] [=0A gml-stack/push reduce [ 'gml-real r ]=0A ]=0A return-integer: func [ i ] [=0A gml-stack/push reduce [ 'gml-integer i ]=0A ]=0A return-boolean: func [ b ] [=0A gml-stack/push reduce [ 'gml-boolean either b ['true]['false] ]=0A ]=0A return-point: func [ x y z ] [=0A gml-stack/push reduce [ 'gml-point x y z ]=0A ]=0A pop-real: func [/local r] [=0A r: gml-stack/pop =0A if r/1 <> 'gml-real [ throw 'gml-error-not-real ]=0A r/2=0A ]=0A pop-integer: func [/local i] [=0A i: gml-stack/pop=0A if i/1 <> 'gml-integer [ throw 'gml-error-not-integer ]=0A i/2=0A ]=0A pop-boolean: func [/local b] [=0A b: gml-stack/pop=0A if b/1 <> 'gml-boolean [ throw 'gml-error-not-boolean ]=0A b/2=0A ]=0A pop-array: func [/local a] [=0A a: gml-stack/pop=0A if a/1 <> 'gml-array [ throw 'gml-error-not-array ]=0A next a=0A ]=0A pop-point: func [/local p] [=0A p: gml-stack/pop=0A if p/1 <> 'gml-point [ throw 'gml-error-not-point ]=0A next p=0A ]=0A]=0A=0A=0Amake-gml-stack!: func [] [=0A make gml-stack! []=0A]=0A=0Agml-stack: make-gml-stack!=0A=0A; note that this guy could be recursive=0Agml-eval: func [ env program /local tk ] [=0A while [ 0 < length? program ] [=0A tk: first program=0A; foreach s ss [ prin [ s/1 "," s/2 ] ]=0A; print ""=0A switch/default to-word tk/1 [=0A gml-boolean [=0A gml-stack/push tk=0A ]=0A gml-integer [=0A gml-stack/push tk=0A ]=0A gml-real [=0A gml-stack/push tk=0A ]=0A gml-string [=0A gml-stack/push tk=0A ]=0A gml-point [=0A gml-stack/push tk=0A ]=0A gml-op [=0A use [ f o ] [=0A switch/default tk/2 [=0A apply [=0A f: gml-stack/pop=0A if f/1 <> 'gml-fn [ throw 'gml-error-cannot-apply ]=0A gml-eval f/2 f/3=0A ]=0A if [=0A use [ b f1 f2 ] [=0A f2: gml-stack/pop=0A f1: gml-stack/pop=0A b: gml-stack/pop=0A either (b/2 == 'true) [=0A gml-eval f1/2 f1/3=0A ] [=0A gml-eval f2/2 f2/3=0A ]=0A ]=0A ]=0A ]=0A [=0A o: tk/2=0A gml-opeval/:o=0A ]=0A ]=0A ]=0A gml-binder [=0A env/set tk/2 gml-stack/pop=0A ]=0A gml-ident [=0A gml-stack/push env/get tk/2=0A ]=0A gml-fn [=0A tk/2: make env []=0A gml-stack/push tk=0A ]=0A gml-array [=0A gml-stack/push tk=0A ]=0A ] [=0A print "don't know"=0A ]=0A=0A program: next program=0A ]=0A]=0A=0Agml-opeval: make object! [=0A=0A addi: func [] [=0A gml-stack/return-integer (gml-stack/pop-integer + gml-stack/pop-integer)=0A ]=0A addf: func [] [=0A gml-stack/return-real (gml-stack/pop-real + gml-stack/pop-real)=0A ]=0A acos: func [ /local r1 ] [=0A r1: gml-stack/pop-real=0A if any [ r1 < -1 r1 > 1 ] [ throw 'gml-error ]=0A gml-stack/return-real (arccosine r1)=0A ]=0A asin: func [ /local r1 ] [=0A r1: gml-stack/pop-real=0A if any [ r1 < -1 r1 > 1 ] [ throw 'gml-error ]=0A gml-stack/return-real (arcsine r1)=0A ]=0A clampf: func [ /local r1 ] [=0A r1: gml-stack/pop-real=0A if r1 < 0.0 [ gml-stack/return-real 0.0 return ]=0A if r1 > 1.0 [ gml-stack/return-real 1.0 return ]=0A gml-stack/return-real r1=0A ]=0A cos: func [] [=0A gml-stack/return-real (cosine gml-stack/pop-real)=0A ]=0A divi: func [ /local i1 i2 ] [=0A i2: gml-stack/pop-integer=0A i1: gml-stack/pop-integer=0A if i2 == 0 [ throw 'gml-error ]=0A gml-stack/return-integer to-integer ( i1 / i2 )=0A ]=0A divf: func [ /local r1 r2 ] [=0A r2: gml-stack/pop-real=0A r1: gml-stack/pop-real=0A if r2 == 0.0 [ throw 'gml-error ]=0A gml-stack/return-real ( r1 / r2 )=0A ]=0A eqi: func [] [=0A gml-stack/return-boolean (gml-stack/pop-integer == gml-stack/pop-integer)=0A ]=0A eqf: func [] [=0A gml-stack/return-boolean (gml-stack/pop-real == gml-stack/pop-real)=0A ]=0A floor: func [] [=0A gml-stack/return-integer (to-integer gml-stack/pop-real)=0A ]=0A frac: func [ /local r1 ] [=0A r1: gml-stack/pop-real=0A gml-stack/return-real ( r1 - to-integer r1 )=0A ]=0A lessi: func [ /local i1 i2 ] [=0A i2: gml-stack/pop-integer=0A i1: gml-stack/pop-integer=0A gml-stack/return-boolean (i1 < i2)=0A ]=0A lessf: func [ /local r1 r2 ] [=0A r2: gml-stack/pop-real=0A r1: gml-stack/pop-real=0A gml-stack/return-boolean (r1 < r2)=0A ]=0A modi: func [ /local i1 i2 ] [=0A i2: gml-stack/pop-integer=0A i1: gml-stack/pop-integer=0A gml-stack/return-integer (i1 // i2)=0A ]=0A muli: func [] [=0A gml-stack/return-integer (gml-stack/pop-integer * gml-stack/pop-integer)=0A ]=0A mulf: func [] [=0A gml-stack/return-integer (gml-stack/pop-real * gml-stack/pop-real)=0A ]=0A negi: func [] [=0A gml-stack/return-integer ( - gml-stack/pop-integer )=0A ]=0A negf: func [] [=0A gml-stack/return-real ( - gml-stack/pop-real )=0A ]=0A real: func [] [=0A gml-stack/return-real ( gml-stack/pop-integer )=0A ]=0A sin: func [] [=0A gml-stack/return-real ( sine gml-stack/pop-real )=0A ]=0A sqrt: func [ /local r1 ] [=0A r1: gml-stack/pop-real=0A if r1 < 0 [ throw 'gml-error ]=0A gml-stack/return-real ( square-root r1 )=0A ]=0A subi: func [ /local i1 i2 ] [=0A i2: gml-stack/pop-integer=0A i1: gml-stack/pop-integer=0A gml-stack/return-integer ( i1 - i2 )=0A ]=0A subf: func [ /local r1 r2 ] [=0A r2: gml-stack/pop-real=0A r1: gml-stack/pop-real=0A gml-stack/return-integer ( r1 - r2 )=0A ]=0A=0A getx: func [ /local p ] [=0A p: gml-stack/pop-point=0A gml-stack/return-real p/1=0A ]=0A gety: func [ /local p ] [=0A p: gml-stack/pop-point=0A gml-stack/return-real p/2=0A ]=0A getz: func [ /local p ] [=0A p: gml-stack/pop-point=0A gml-stack/return-real p/3=0A ]=0A point: func [ /local x y z ] [=0A z: gml-stack/pop-real=0A y: gml-stack/pop-real=0A x: gml-stack/pop-real=0A gml-stack/return-point x y z=0A ]=0A=0A get: func [ /local a i ] [=0A i: gml-stack/pop-integer + 1=0A a: gml-stack/pop-array=0A if i > (length? a) [ throw 'gml-error-out-of-bounds ]=0A gml-stack/push (pick a i)=0A ]=0A length: func [ /local a ] [=0A a: gml-stack/pop-array=0A gml-stack/return-integer (length? a)=0A ]=0A light: func [ /local dir color ] [=0A color: gml-stack/pop-point=0A dir: gml-stack/pop-point=0A append dir 0=0A gml-stack/push reduce [ 'gml-light dir color ]=0A ]=0A]=0A=0Atest1: {=0A1 2 addi % adding 1 and 2=0A2.0e10 1.0 addf % blah=0A}=0A=0Atest2: {=0A { 1 } /id % the identity function=0A { } /id % the identity function=0A}=0A=0Atest3: {=0A ^{ 1 addi ^} /inc % the increment function=0A ^{ /x /y x y ^} /swap %swap the top two stack locations=0A}=0A=0Atest4: {=0A1 /x=0A{ x } /f=0A2 /x=0Af apply x addi=0A}=0A=0Atest5: {=0A { /n /self=0A n 2 lessi=0A { 1 }=0A { self n 1 subi self apply n muli }=0A if=0A } /fact=0A fact 4 fact apply=0A}=0A=0Atest6: {=0A ^{ 1 addi ^} /inc % the increment function=0A ^{ 5 inc apply ^} /bb=0A bb apply=0A}=0A=0Atest7: {=0A true { 1 } { 2 } if=0A false { 2 } { 1 } if=0A}=0A=0Ass: func [] [ gml-stack/stack ]=0A=0Agml-eval gml-env parse-gml test7=0A=0Agmle: func [ str ] [ =0A gml-eval gml-env parse-gml str=0A]=0A=0Ard: func [][do %grammer.r]=0A=0A ------_=_NextPart_000_01C0113F.9CB50136 Content-Type: application/octet-stream; name="ppm.r" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ppm.r" REBOl [=0A Title: "PPM handling routine"=0A]=0A=0Acomment {=0A An object to create a PPM file and write it to file.=0A}=0A=0Appm!: make object! [=0A filename: %test.ppm=0A width: 100=0A height: 100=0A image: array/initial ( 100 * 100 * 3 ) 0=0A getxy: func [ x y /local i ] [ ; x and y from 0 to 99=0A i: (y * width * 3) + (x * 3)=0A return copy/part (skip image i) 3=0A ]=0A setxy: func [ x y color /local p ] [=0A i: (y * width * 3) + (x * 3)=0A p: skip image i=0A p/1: to-integer (color/1 * 255)=0A p/2: to-integer (color/2 * 255)=0A p/3: to-integer (color/3 * 255)=0A color=0A ]=0A writeppm: func [] [=0A write filename join=0A "P6^/# Alfred Pang^/" reduce [ width " " height "^/255^/" ]=0A write/append filename to-binary image=0A write/append filename "^/"=0A ]=0A]=0A=0Amake-ppm!: func [ w h f ] [=0A make ppm! [=0A filename: to-file f=0A width: w=0A height: h=0A image: array/initial (w * h * 3) 0=0A ]=0A]=0A=0A ------_=_NextPart_000_01C0113F.9CB50136 Content-Type: application/octet-stream; name="render.r" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="render.r" REBOL [=0A Title: "Renderer"=0A]=0A=0Ado %grammer.r=0Ado %threed.r=0Ado %ppm.r=0A=0Asphere!: make object! [=0A texture: parse-gml { { /v /u /face 0.8 0.8 0.2 point 1.0 0.0 1.0 } apply }=0A]=0A=0Aray!: make object! [=0A vector: make-unit-vec [ 1 1 1 0 ]=0A point: [ 0 0 0 1 ]=0A rayt: func [ t /local rt ] [=0A rt: copy point=0A rt/1: rt/1 + (t * vector/1)=0A rt/2: rt/2 + (t * vector/2)=0A rt/3: rt/3 + (t * vector/3)=0A rt=0A ]=0A]=0A=0Amake-ray!: func [ dir pt ] [=0A make ray! [=0A vector: dir=0A point: pt=0A ]=