You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(116) |
May
(220) |
Jun
(52) |
Jul
(30) |
Aug
(35) |
Sep
(24) |
Oct
(49) |
Nov
(44) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(21) |
Feb
(30) |
Mar
(9) |
Apr
(44) |
May
(2) |
Jun
|
Jul
(10) |
Aug
(20) |
Sep
(25) |
Oct
(12) |
Nov
(16) |
Dec
(4) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(25) |
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(10) |
2006 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(33) |
2007 |
Jan
(4) |
Feb
(57) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Gerardo H. <ma...@us...> - 2004-08-02 05:45:33
|
Update of /cvsroot/jrman/drafts/slcompiler/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3000/shaders Added Files: spotlight.sl Log Message: Fixed '^' and '.' priority. --- NEW FILE: spotlight.sl --- light spotlight( float intensity = 1; color lightcolor = 1; point from = point "shader" (0, 0, 0); point to = point "shader" (0, 0, 1); float coneangle = radians(30); float conedeltaangle = radians(5); float beamdistribution = 2;) { float atten, cosangle; uniform vector A = (to - from) / length(to - from); illuminate(from, A, coneangle) { cosangle = L. A / length(L); atten = pow(cosangle, beamdistribution) / L . L; atten *= smoothstep(cos(coneangle), cos(coneangle - conedeltaangle), cosangle); CI = atten * intensity * lightcolor; } } |
From: Gerardo H. <ma...@us...> - 2004-08-02 01:57:13
|
Update of /cvsroot/jrman/drafts/slcompiler/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9603/shaders Modified Files: shinymetal.sl Added Files: ambientlight.sl distantlight.sl paintedplastic.sl pointlight.sl Log Message: Improved & fixed test code generation. Index: shinymetal.sl =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/shaders/shinymetal.sl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** shinymetal.sl 1 Aug 2004 22:56:08 -0000 1.1 --- shinymetal.sl 2 Aug 2004 01:57:00 -0000 1.2 *************** *** 2,6 **** metal( float Ka = 1; ! float Kd = 1; float Kr = 1; float roughness = .1; --- 2,6 ---- metal( float Ka = 1; ! float Ks = 1; float Kr = 1; float roughness = .1; --- NEW FILE: paintedplastic.sl --- surface paintedplastic( float Ka = 1; float Kd = .5; float Ks = .5; float roughness = .1; color specularcolor = 1; string texturename = "";) { normal Nf = faceforward(normalize(N), I); vector V = -normalize(I); Oi = Os; Ci = Os * (Cs * color texture(texturename) * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness)); } --- NEW FILE: pointlight.sl --- light pointlight( float intensity = 1; color lightcolor = 1; point from = point "shader" (0, 0, 0);) { illuminate (from) CI = intensity * lightcolor / L . L; } --- NEW FILE: ambientlight.sl --- light ambientlight( float intensity = 1; color lightcolor = 1;) { CI = intensity * lightcolor; } --- NEW FILE: distantlight.sl --- light distantlight( float intensity = 1; color lightcolor = 1; point from = point "shader" (0, 0, 0); point to = point "shader" (0, 0, 1);) { solar(to - from, 0.0) CI = intensity * lightcolor; } |
From: Gerardo H. <ma...@us...> - 2004-08-02 01:57:08
|
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9603 Modified Files: DefaultVisitor.java SLCompiler.java SLCompiler.jj SLCompiler.jjt SLCompilerTreeConstants.java SLCompilerVisitor.java TestsVisitor.java Added Files: ASTdotOrPowerExpression.java Log Message: Improved & fixed test code generation. Index: SLCompiler.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SLCompiler.java 1 Aug 2004 04:50:40 -0000 1.3 --- SLCompiler.java 2 Aug 2004 01:56:56 -0000 1.4 *************** *** 1197,1200 **** --- 1197,1208 ---- jj_consume_token(COMMA); expression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + sixteentuple(); + break; + default: + jj_la1[26] = jj_gen; + ; [...2190 lines suppressed...] *** 3907,3911 **** final private void jj_rescan_token() { jj_rescan = true; ! for (int i = 0; i < 19; i++) { JJCalls p = jj_2_rtns[i]; do { --- 3975,3979 ---- final private void jj_rescan_token() { jj_rescan = true; ! for (int i = 0; i < 20; i++) { JJCalls p = jj_2_rtns[i]; do { *************** *** 3932,3935 **** --- 4000,4004 ---- case 17: jj_3_18(); break; case 18: jj_3_19(); break; + case 19: jj_3_20(); break; } } Index: DefaultVisitor.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/DefaultVisitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DefaultVisitor.java 1 Aug 2004 00:29:36 -0000 1.1 --- DefaultVisitor.java 2 Aug 2004 01:56:56 -0000 1.2 *************** *** 180,183 **** --- 180,187 ---- } + public Object visit(ASTdotOrPowerExpression node, Object data) { + return node.childrenAccept(this, data); + } + public Object visit(ASToperatorUnaryExpression node, Object data) { return node.childrenAccept(this, data); Index: SLCompilerTreeConstants.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompilerTreeConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompilerTreeConstants.java 31 Jul 2004 22:36:31 -0000 1.1 --- SLCompilerTreeConstants.java 2 Aug 2004 01:56:57 -0000 1.2 *************** *** 43,60 **** public int JJTADDITIVEEXPRESSION = 38; public int JJTMULTIPLICATIVEEXPRESSION = 39; ! public int JJTOPERATORUNARYEXPRESSION = 40; ! public int JJTCASTEXPRESSION = 41; ! public int JJTRETURNSTATEMENT = 42; ! public int JJTLOOPMODSTMT = 43; ! public int JJTLOOPMOD = 44; ! public int JJTIFSTATEMENT = 45; ! public int JJTWHILESTATEMENT = 46; ! public int JJTFORSTATEMENT = 47; ! public int JJTSOLARSTATEMENT = 48; ! public int JJTILLUMINATESTATEMENT = 49; ! public int JJTILLUMINANCESTATEMENT = 50; ! public int JJTEXPRESSIONLIST = 51; ! public int JJTVARIABLEDEFINITIONS = 52; ! public int JJTEXTERNSPEC = 53; --- 43,61 ---- public int JJTADDITIVEEXPRESSION = 38; public int JJTMULTIPLICATIVEEXPRESSION = 39; ! public int JJTDOTORPOWEREXPRESSION = 40; ! public int JJTOPERATORUNARYEXPRESSION = 41; ! public int JJTCASTEXPRESSION = 42; ! public int JJTRETURNSTATEMENT = 43; ! public int JJTLOOPMODSTMT = 44; ! public int JJTLOOPMOD = 45; ! public int JJTIFSTATEMENT = 46; ! public int JJTWHILESTATEMENT = 47; ! public int JJTFORSTATEMENT = 48; ! public int JJTSOLARSTATEMENT = 49; ! public int JJTILLUMINATESTATEMENT = 50; ! public int JJTILLUMINANCESTATEMENT = 51; ! public int JJTEXPRESSIONLIST = 52; ! public int JJTVARIABLEDEFINITIONS = 53; ! public int JJTEXTERNSPEC = 54; *************** *** 100,103 **** --- 101,105 ---- "additiveExpression", "multiplicativeExpression", + "dotOrPowerExpression", "operatorUnaryExpression", "castExpression", Index: SLCompilerVisitor.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompilerVisitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompilerVisitor.java 31 Jul 2004 22:36:31 -0000 1.1 --- SLCompilerVisitor.java 2 Aug 2004 01:56:57 -0000 1.2 *************** *** 43,46 **** --- 43,47 ---- public Object visit(ASTadditiveExpression node, Object data); public Object visit(ASTmultiplicativeExpression node, Object data); + public Object visit(ASTdotOrPowerExpression node, Object data); public Object visit(ASToperatorUnaryExpression node, Object data); public Object visit(ASTcastExpression node, Object data); --- NEW FILE: ASTdotOrPowerExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTdotOrPowerExpression.java */ public class ASTdotOrPowerExpression extends SimpleNode { public ASTdotOrPowerExpression(int id) { super(id); } public ASTdotOrPowerExpression(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } Index: SLCompiler.jjt =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.jjt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SLCompiler.jjt 1 Aug 2004 04:50:40 -0000 1.3 --- SLCompiler.jjt 2 Aug 2004 01:56:57 -0000 1.4 *************** *** 478,482 **** {} { ! "," expression() ","expression() } --- 478,482 ---- {} { ! "," expression() ","expression() [ sixteentuple() ] } *************** *** 566,577 **** { ( ! unaryExpression() ! (LOOKAHEAD(2) ( t = "." ! | t = "*" ! | t = "/" ! | t = "^" ) unaryExpression() { jjtThis.add(t.image); })* ) #multiplicativeExpression(>1) } void unaryExpression() #void : {} --- 566,585 ---- { ( ! dotOrPowerExpression() ! (LOOKAHEAD(2) ( t = "*" ! | t = "/" ) dotOrPowerExpression() { jjtThis.add(t.image); })* ) #multiplicativeExpression(>1) } + void dotOrPowerExpression() #void : + { Token t; } + { + ( + unaryExpression() + [LOOKAHEAD(2) ( t = "." + | t = "^" ) unaryExpression() { jjtThis.add(t.image); }] + ) #dotOrPowerExpression(>1) + } + void unaryExpression() #void : {} Index: SLCompiler.jj =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.jj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SLCompiler.jj 1 Aug 2004 04:50:40 -0000 1.3 --- SLCompiler.jj 2 Aug 2004 01:56:56 -0000 1.4 *************** *** 1223,1227 **** try { /*@egen*/ ! "," expression() ","expression()/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { --- 1223,1227 ---- try { /*@egen*/ ! "," expression() ","expression() [ sixteentuple() ]/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { *************** *** 1587,1595 **** /*@egen*/ ( unaryExpression() ! (LOOKAHEAD(2) ( t = "." ! | t = "*" ! | t = "/" ! | t = "^" ) unaryExpression() { jjtn001.add(t.image); })* )/*@bgen(jjtree)*/ } catch (Throwable jjte001) { --- 1587,1630 ---- /*@egen*/ ( + dotOrPowerExpression() + (LOOKAHEAD(2) ( t = "*" + | t = "/" ) dotOrPowerExpression() { jjtn001.add(t.image); })* + )/*@bgen(jjtree)*/ + } catch (Throwable jjte001) { + if (jjtc001) { + jjtree.clearNodeScope(jjtn001); + jjtc001 = false; + } else { + jjtree.popNode(); + } + if (jjte001 instanceof RuntimeException) { + throw (RuntimeException)jjte001; + } + if (jjte001 instanceof ParseException) { + throw (ParseException)jjte001; + } + throw (Error)jjte001; + } finally { + if (jjtc001) { + jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); + } + } + /*@egen*/ + } + + void dotOrPowerExpression() : + { Token t; } + {/*@bgen(jjtree) #dotOrPowerExpression(> 1) */ + { + ASTdotOrPowerExpression jjtn001 = new ASTdotOrPowerExpression(JJTDOTORPOWEREXPRESSION); + boolean jjtc001 = true; + jjtree.openNodeScope(jjtn001); + } + try { + /*@egen*/ + ( unaryExpression() ! [LOOKAHEAD(2) ( t = "." ! | t = "^" ) unaryExpression() { jjtn001.add(t.image); }] )/*@bgen(jjtree)*/ } catch (Throwable jjte001) { Index: TestsVisitor.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/TestsVisitor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestsVisitor.java 1 Aug 2004 22:56:07 -0000 1.4 --- TestsVisitor.java 2 Aug 2004 01:56:57 -0000 1.5 *************** *** 137,153 **** public Object visit(ASTsingle node, Object data) { ! return node.jjtGetChild(0).jjtAccept(this, data); } public Object visit(ASTadditiveExpression node, Object data) { int n = node.jjtGetNumChildren(); ! String var1 = (String) node.jjtGetChild(n - 2).jjtAccept(this, data); ! String var2 = (String) node.jjtGetChild(n - 1).jjtAccept(this, data); String temp = "T" + tempCounter++; ! code.add(temp + " <- " + var1 + " " + node.ops.get(n - 2) + " " + var2); ! for (int i = n - 3; i >= 0; i--) { ! var1 = (String) node.jjtGetChild(i).jjtAccept(this, data); String newTemp = "T" + tempCounter++; ! code.add(newTemp + " <- " + var1 + " " + node.ops.get(i) + " " + temp); temp = newTemp; } --- 137,172 ---- public Object visit(ASTsingle node, Object data) { ! String val = (String) node.jjtGetChild(0).jjtAccept(this, data); ! if (node.jjtGetNumChildren() == 2) ! val = "(" + val + (String) node.jjtGetChild(1).jjtAccept(this, data) + ")"; ! return val; ! } ! ! public Object visit(ASTtriple node, Object data) { ! StringBuffer sb = new StringBuffer(); ! sb.append(", ").append((String) node.jjtGetChild(0).jjtAccept(this, data)); ! sb.append(", ").append((String) node.jjtGetChild(1).jjtAccept(this, data)); ! if (node.jjtGetNumChildren() == 3) ! sb.append((String) node.jjtGetChild(2).jjtAccept(this, data)); ! return sb.toString(); ! } ! ! public Object visit(ASTsixteentuple node, Object data) { ! StringBuffer sb = new StringBuffer(); ! for (int i = 0; i < 13; i++) ! sb.append(", ").append((String) node.jjtGetChild(i).jjtAccept(this, data)); ! return sb.toString(); } public Object visit(ASTadditiveExpression node, Object data) { int n = node.jjtGetNumChildren(); ! String var1 = (String) node.jjtGetChild(0).jjtAccept(this, data); ! String var2 = (String) node.jjtGetChild(1).jjtAccept(this, data); String temp = "T" + tempCounter++; ! code.add(temp + " <- " + var1 + " " + node.ops.get(0) + " " + var2); ! for (int i = 2; i < n; i++) { ! var2 = (String) node.jjtGetChild(i).jjtAccept(this, data); String newTemp = "T" + tempCounter++; ! code.add(newTemp + " <- " + temp + " " + node.ops.get(i - 1) + " " + var2); temp = newTemp; } *************** *** 157,168 **** public Object visit(ASTmultiplicativeExpression node, Object data) { int n = node.jjtGetNumChildren(); ! String var1 = (String) node.jjtGetChild(n - 2).jjtAccept(this, data); ! String var2 = (String) node.jjtGetChild(n - 1).jjtAccept(this, data); String temp = "T" + tempCounter++; ! code.add(temp + " <- " + var1 + " " + node.ops.get(n - 2) + " " + var2); ! for (int i = n - 3; i >= 0; i--) { ! var1 = (String) node.jjtGetChild(i).jjtAccept(this, data); String newTemp = "T" + tempCounter++; ! code.add(newTemp + " <- " + var1 + " " + node.ops.get(i) + " " + temp); temp = newTemp; } --- 176,202 ---- public Object visit(ASTmultiplicativeExpression node, Object data) { int n = node.jjtGetNumChildren(); ! String var1 = (String) node.jjtGetChild(0).jjtAccept(this, data); ! String var2 = (String) node.jjtGetChild(1).jjtAccept(this, data); String temp = "T" + tempCounter++; ! code.add(temp + " <- " + var1 + " " + node.ops.get(0) + " " + var2); ! for (int i = 2; i < n; i++) { ! var2 = (String) node.jjtGetChild(i).jjtAccept(this, data); String newTemp = "T" + tempCounter++; ! code.add(newTemp + " <- " + temp + " " + node.ops.get(i - 1) + " " + var2); ! temp = newTemp; ! } ! return temp; ! } ! ! public Object visit(ASTdotOrPowerExpression node, Object data) { ! int n = node.jjtGetNumChildren(); ! String var1 = (String) node.jjtGetChild(0).jjtAccept(this, data); ! String var2 = (String) node.jjtGetChild(1).jjtAccept(this, data); ! String temp = "T" + tempCounter++; ! code.add(temp + " <- " + var1 + " " + node.ops.get(0) + " " + var2); ! for (int i = 2; i < n; i++) { ! var2 = (String) node.jjtGetChild(i).jjtAccept(this, data); ! String newTemp = "T" + tempCounter++; ! code.add(newTemp + " <- " + temp + " " + node.ops.get(i - 1) + " " + var2); temp = newTemp; } *************** *** 217,226 **** String val = (String) node.jjtGetChild(1).jjtAccept(this, data); String temp = "T" + tempCounter++; ! code.add(temp + " <- (" + type + ") " + val); return temp; } public Object visit(ASTtypecast node, Object data) { ! return node.type; } --- 251,267 ---- String val = (String) node.jjtGetChild(1).jjtAccept(this, data); String temp = "T" + tempCounter++; ! code.add(temp + " <- " + type + " " + val); return temp; } public Object visit(ASTtypecast node, Object data) { ! String type = "(" + node.type + ")"; ! if (node.jjtGetNumChildren() == 1) ! type = type + " (" + ((String) node.jjtGetChild(0).jjtAccept(this, data)) + ")"; ! return type; ! } ! ! public Object visit(ASTspacetype node, Object data) { ! return node.jjtGetChild(0).jjtAccept(this, data); } *************** *** 274,277 **** --- 315,383 ---- } + public Object visit(ASTsolarStatement node, Object data) { + List exprs = new ArrayList(); + if (node.jjtGetNumChildren() == 2) { + exprs = (List) node.jjtGetChild(0).jjtAccept(this, data); + } + StringBuffer sb = new StringBuffer(); + sb.append("begin solar ["); + for (int i = 0; i < exprs.size(); i++) { + sb.append(exprs.get(i)); + if (i < exprs.size() - 1) + sb.append(", "); + } + sb.append("]"); + code.add(sb.toString()); + Object result = node.jjtGetChild(node.jjtGetNumChildren() - 1).jjtAccept(this, data); + code.add("end solar"); + return result; + } + + public Object visit(ASTilluminateStatement node, Object data) { + List exprs = new ArrayList(); + if (node.jjtGetNumChildren() == 2) { + exprs = (List) node.jjtGetChild(0).jjtAccept(this, data); + } + StringBuffer sb = new StringBuffer(); + sb.append("begin illuminate ["); + for (int i = 0; i < exprs.size(); i++) { + sb.append(exprs.get(i)); + if (i < exprs.size() - 1) + sb.append(", "); + } + sb.append("]"); + code.add(sb.toString()); + Object result = node.jjtGetChild(node.jjtGetNumChildren() - 1).jjtAccept(this, data); + code.add("end illuminate"); + return result; + } + + public Object visit(ASTilluminanceStatement node, Object data) { + List exprs = new ArrayList(); + if (node.jjtGetNumChildren() == 2) { + exprs = (List) node.jjtGetChild(0).jjtAccept(this, data); + } + StringBuffer sb = new StringBuffer(); + sb.append("begin illuminance ["); + for (int i = 0; i < exprs.size(); i++) { + sb.append(exprs.get(i)); + if (i < exprs.size() - 1) + sb.append(", "); + } + sb.append("]"); + code.add(sb.toString()); + Object result = node.jjtGetChild(node.jjtGetNumChildren() - 1).jjtAccept(this, data); + code.add("end illuminance"); + return result; + } + + public Object visit(ASTexpressionList node, Object data) { + List exprs = new ArrayList(); + int n = node.jjtGetNumChildren(); + for (int i = 0; i < n; i++) + exprs.add(node.jjtGetChild(i).jjtAccept(this, data)); + return exprs; + } + void showCode() { for (Iterator iter = code.iterator(); iter.hasNext(); ) |
From: Gerardo H. <ma...@us...> - 2004-08-01 22:56:16
|
Update of /cvsroot/jrman/drafts/slcompiler/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16250/shaders Added Files: shinymetal.sl Log Message: Code generation for textures and casts. --- NEW FILE: shinymetal.sl --- surface metal( float Ka = 1; float Kd = 1; float Kr = 1; float roughness = .1; string texturename = "";) { normal Nf = faceforward(normalize(N), I); vector V = -normalize(I); vector D = reflect(I, normalize(Nf)); D = vtransform("current", "world", D); Oi = Os; Ci = Os * Cs * (Ka * ambient() + Ks * specular(Nf, V, roughness) + Kr * color environment(texturename, D)); } |
From: Gerardo H. <ma...@us...> - 2004-08-01 22:56:16
|
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16250 Modified Files: TestsVisitor.java Log Message: Code generation for textures and casts. Index: TestsVisitor.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/TestsVisitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestsVisitor.java 1 Aug 2004 05:58:04 -0000 1.3 --- TestsVisitor.java 1 Aug 2004 22:56:07 -0000 1.4 *************** *** 209,212 **** --- 209,277 ---- } + public Object visit(ASTstringconstant node, Object data) { + return "\"" + node.value + "\""; + } + + public Object visit(ASTcastExpression node, Object data) { + String type = (String) node.jjtGetChild(0).jjtAccept(this, data); + String val = (String) node.jjtGetChild(1).jjtAccept(this, data); + String temp = "T" + tempCounter++; + code.add(temp + " <- (" + type + ") " + val); + return temp; + } + + public Object visit(ASTtypecast node, Object data) { + return node.type; + } + + public Object visit(ASTtexture node, Object data) { + String type = (String) node.jjtGetChild(0).jjtAccept(this, data); + String filename = (String) node.jjtGetChild(1).jjtAccept(this, data); + int next = 2; + String channel = ""; + List args = new ArrayList(); + if (node.jjtGetNumChildren() > 2) { + Object o = node.jjtGetChild(2).jjtAccept(this, data); + if (o instanceof String) + channel = (String) o; + else + args = (List) o; + } + if (node.jjtGetNumChildren() > 3) + args = (List) node.jjtGetChild(3).jjtAccept(this, data); + String temp = "T" + tempCounter++; + StringBuffer sb = new StringBuffer(); + sb.append(temp).append(" <- TEXTURE(").append(type).append(", "); + sb.append(filename).append(", [").append(channel).append("], ("); + for (int i = 0; i < args.size(); i++) { + sb.append(args.get(i)); + if (i < args.size() - 1) + sb.append(", "); + } + sb.append("))"); + code.add(sb.toString()); + return temp; + } + + public Object visit(ASTtextureType node, Object data) { + return node.type; + } + + public Object visit(ASTtextureFilename node, Object data) { + return node.jjtGetChild(0).jjtAccept(this, data); + } + + public Object visit(ASTchannel node, Object data) { + return node.jjtGetChild(0).jjtAccept(this, data); + } + + public Object visit(ASTtextureArguments node, Object data) { + List args = new ArrayList(); + int n = node.jjtGetNumChildren(); + for (int i = 0; i < n; i++) + args.add(node.jjtGetChild(i).jjtAccept(this, data)); + return args; + } + void showCode() { for (Iterator iter = code.iterator(); iter.hasNext(); ) |
From: Gerardo H. <ma...@us...> - 2004-08-01 05:58:13
|
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25496 Modified Files: TestsVisitor.java Log Message: Simulated code generation works with some basic shaders! Index: TestsVisitor.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/TestsVisitor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestsVisitor.java 1 Aug 2004 04:50:40 -0000 1.2 --- TestsVisitor.java 1 Aug 2004 05:58:04 -0000 1.3 *************** *** 36,39 **** --- 36,41 ---- boolean waitingForFunctionName; + int tempCounter; + public Object visit(ASTidentifier node, Object data) { if (waitingForShaderName) { *************** *** 71,77 **** } public Object visit(ASTdefInit node, Object data) { inDeclaration = false; ! data = node.childrenAccept(this, data); inDeclaration = true; return data; --- 73,88 ---- } + public Object visit(ASTdefExpression node, Object data) { + if (node.jjtGetNumChildren() == 2) { + String var = (String) node.jjtGetChild(0).jjtAccept(this, data); + String val = (String) node.jjtGetChild(1).jjtAccept(this, data); + code.add(var + " <- " + val); + } + return data; + } + public Object visit(ASTdefInit node, Object data) { inDeclaration = false; ! data = node.jjtGetChild(0).jjtAccept(this, data); inDeclaration = true; return data; *************** *** 100,103 **** --- 111,212 ---- } + public Object visit(ASTassignexpression node, Object data) { + String var = (String) node.jjtGetChild(0).jjtAccept(this, data); + String op = (String) node.jjtGetChild(1).jjtAccept(this, data); + String val = (String) node.jjtGetChild(2).jjtAccept(this, data); + if (op.equals("=")) + code.add(var + " <- " + val); + else { + op = op.substring(0, 1); + code.add(var + " <- " + var + " " + op + " " + val); + } + return var; + } + + public Object visit(ASTasgnop node, Object data) { + return node.type; + } + + public Object visit(ASTconditionalExpression node, Object data) { + return node.jjtGetChild(0).jjtAccept(this, data); + } + + public Object visit(ASTprimary node, Object data) { + return node.jjtGetChild(0).jjtAccept(this, data); + } + + public Object visit(ASTsingle node, Object data) { + return node.jjtGetChild(0).jjtAccept(this, data); + } + + public Object visit(ASTadditiveExpression node, Object data) { + int n = node.jjtGetNumChildren(); + String var1 = (String) node.jjtGetChild(n - 2).jjtAccept(this, data); + String var2 = (String) node.jjtGetChild(n - 1).jjtAccept(this, data); + String temp = "T" + tempCounter++; + code.add(temp + " <- " + var1 + " " + node.ops.get(n - 2) + " " + var2); + for (int i = n - 3; i >= 0; i--) { + var1 = (String) node.jjtGetChild(i).jjtAccept(this, data); + String newTemp = "T" + tempCounter++; + code.add(newTemp + " <- " + var1 + " " + node.ops.get(i) + " " + temp); + temp = newTemp; + } + return temp; + } + + public Object visit(ASTmultiplicativeExpression node, Object data) { + int n = node.jjtGetNumChildren(); + String var1 = (String) node.jjtGetChild(n - 2).jjtAccept(this, data); + String var2 = (String) node.jjtGetChild(n - 1).jjtAccept(this, data); + String temp = "T" + tempCounter++; + code.add(temp + " <- " + var1 + " " + node.ops.get(n - 2) + " " + var2); + for (int i = n - 3; i >= 0; i--) { + var1 = (String) node.jjtGetChild(i).jjtAccept(this, data); + String newTemp = "T" + tempCounter++; + code.add(newTemp + " <- " + var1 + " " + node.ops.get(i) + " " + temp); + temp = newTemp; + } + return temp; + } + + public Object visit(ASToperatorUnaryExpression node, Object data) { + String var = (String) node.jjtGetChild(0).jjtAccept(this, data); + String temp = "T" + tempCounter++; + code.add(temp + " <- " + node.type + var); + return temp; + } + + public Object visit(ASTprocedurecall node, Object data) { + String proc = (String) node.jjtGetChild(0).jjtAccept(this, data); + List args; + if (node.jjtGetNumChildren() > 1) + args = (List) node.jjtGetChild(1).jjtAccept(this, data); + else + args = new ArrayList(); + String temp = "T" + tempCounter++; + StringBuffer sb = new StringBuffer(); + sb.append(temp).append(" <- ").append(proc).append('('); + for (int i = 0; i < args.size(); i++) { + sb.append(args.get(i)); + if (i < args.size() - 1) + sb.append(", "); + } + sb.append(')'); + code.add(sb.toString()); + return temp; + } + + public Object visit(ASTprocArguments node, Object data) { + List args = new ArrayList(); + int n = node.jjtGetNumChildren(); + for (int i = 0; i < n; i++) + args.add(node.jjtGetChild(i).jjtAccept(this, data)); + return args; + } + + public Object visit(ASTnumber node, Object data) { + return node.value; + } + void showCode() { for (Iterator iter = code.iterator(); iter.hasNext(); ) |
From: Gerardo H. <ma...@us...> - 2004-08-01 04:51:02
|
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18456 Modified Files: JavaCharStream.java ParseException.java SLCompiler.java SLCompiler.jj SLCompiler.jjt SLCompilerTokenManager.java TestsVisitor.java Token.java TokenMgrError.java Log Message: Preparing for test code generation. Index: SLCompilerTokenManager.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompilerTokenManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompilerTokenManager.java 31 Jul 2004 22:36:31 -0000 1.1 --- SLCompilerTokenManager.java 1 Aug 2004 04:50:40 -0000 1.2 *************** *** 1275,1279 **** 0x4c0L, 0x0L, }; ! protected JavaCharStream input_stream; private final int[] jjrounds = new int[48]; private final int[] jjstateSet = new int[96]; --- 1275,1279 ---- 0x4c0L, 0x0L, }; ! private JavaCharStream input_stream; private final int[] jjrounds = new int[48]; private final int[] jjstateSet = new int[96]; *************** *** 1320,1324 **** } ! protected Token jjFillToken() { Token t = Token.newToken(jjmatchedKind); --- 1320,1324 ---- } ! private final Token jjFillToken() { Token t = Token.newToken(jjmatchedKind); *************** *** 1340,1344 **** int jjmatchedKind; ! public Token getNextToken() { int kind; --- 1340,1344 ---- int jjmatchedKind; ! public final Token getNextToken() { int kind; *************** *** 1464,1468 **** } ! void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) --- 1464,1468 ---- } ! final void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) Index: TokenMgrError.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/TokenMgrError.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TokenMgrError.java 31 Jul 2004 22:36:31 -0000 1.1 --- TokenMgrError.java 1 Aug 2004 04:50:40 -0000 1.2 *************** *** 1,3 **** ! /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ public class TokenMgrError extends Error { --- 1,3 ---- ! /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 2.1 */ public class TokenMgrError extends Error { *************** *** 93,97 **** * Note: You can customize the lexical error message by modifying this method. */ ! protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + --- 93,97 ---- * Note: You can customize the lexical error message by modifying this method. */ ! private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + Index: Token.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/Token.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Token.java 31 Jul 2004 22:36:31 -0000 1.1 --- Token.java 1 Aug 2004 04:50:40 -0000 1.2 *************** *** 1,3 **** ! /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ /** * Describes the input token stream. --- 1,3 ---- ! /* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */ /** * Describes the input token stream. *************** *** 52,56 **** * Returns the image. */ ! public String toString() { return image; --- 52,56 ---- * Returns the image. */ ! public final String toString() { return image; Index: SLCompiler.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SLCompiler.java 1 Aug 2004 00:29:36 -0000 1.2 --- SLCompiler.java 1 Aug 2004 04:50:40 -0000 1.3 *************** *** 21,25 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! new TestsVisitor().visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); } --- 21,28 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! TestsVisitor visitor = new TestsVisitor(); ! ((ASTcompilationUnit) compiler.jjtree.rootNode()).dump(" "); [...2246 lines suppressed...] --- 3839,3844 ---- } boolean exists = false; ! for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) { ! int[] oldentry = (int[])(enum.nextElement()); if (oldentry.length == jj_expentry.length) { exists = true; *************** *** 3637,3641 **** } ! public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[82]; --- 3857,3861 ---- } ! final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[82]; Index: SLCompiler.jj =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.jj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SLCompiler.jj 1 Aug 2004 00:29:36 -0000 1.2 --- SLCompiler.jj 1 Aug 2004 04:50:40 -0000 1.3 *************** *** 51,55 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! new TestsVisitor().visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); } --- 51,58 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! TestsVisitor visitor = new TestsVisitor(); ! ((ASTcompilationUnit) compiler.jjtree.rootNode()).dump(" "); ! visitor.visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); ! visitor.showCode(); } *************** *** 757,770 **** /*@egen*/ number() ! | ! stringconstant() ! | ! texture() ! | ! LOOKAHEAD(2) procedurecall() ! | ! LOOKAHEAD(2) identifier() [LOOKAHEAD(2) arrayindex()] [asgnop() expression()] ! //assignExpression(), identifier() ! | single()/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { --- 760,768 ---- /*@egen*/ number() ! | stringconstant() ! | texture() ! | LOOKAHEAD(2) procedurecall() ! | LOOKAHEAD(2) identifier() [LOOKAHEAD(2) arrayindex()] [asgnop() expression()] ! | single()/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { *************** *** 787,790 **** --- 785,789 ---- } /*@egen*/ + //assignExpression(), identifier() } Index: JavaCharStream.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/JavaCharStream.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JavaCharStream.java 31 Jul 2004 22:36:31 -0000 1.1 --- JavaCharStream.java 1 Aug 2004 04:50:40 -0000 1.2 *************** *** 1,3 **** ! /* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 3.0 */ /** * An implementation of interface CharStream, where the stream is assumed to --- 1,3 ---- ! /* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 2.1 */ /** * An implementation of interface CharStream, where the stream is assumed to *************** *** 5,9 **** */ ! public class JavaCharStream { public static final boolean staticFlag = false; --- 5,9 ---- */ ! public final class JavaCharStream { public static final boolean staticFlag = false; *************** *** 59,80 **** int available; int tokenBegin; ! protected int bufline[]; ! protected int bufcolumn[]; ! protected int column = 0; ! protected int line = 1; ! protected boolean prevCharIsCR = false; ! protected boolean prevCharIsLF = false; ! protected java.io.Reader inputStream; ! protected char[] nextCharBuf; ! protected char[] buffer; ! protected int maxNextCharInd = 0; ! protected int nextCharInd = -1; ! protected int inBuf = 0; ! protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; --- 59,80 ---- int available; int tokenBegin; ! private int bufline[]; ! private int bufcolumn[]; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private char[] nextCharBuf; ! private char[] buffer; ! private int maxNextCharInd = 0; ! private int nextCharInd = -1; ! private int inBuf = 0; ! private final void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; *************** *** 124,128 **** } ! protected void FillBuff() throws java.io.IOException { int i; --- 124,128 ---- } ! private final void FillBuff() throws java.io.IOException { int i; *************** *** 156,160 **** } ! protected char ReadByte() throws java.io.IOException { if (++nextCharInd >= maxNextCharInd) --- 156,160 ---- } ! private final char ReadByte() throws java.io.IOException { if (++nextCharInd >= maxNextCharInd) *************** *** 164,168 **** } ! public char BeginToken() throws java.io.IOException { if (inBuf > 0) --- 164,168 ---- } ! public final char BeginToken() throws java.io.IOException { if (inBuf > 0) *************** *** 183,187 **** } ! protected void AdjustBuffSize() { if (available == bufsize) --- 183,187 ---- } ! private final void AdjustBuffSize() { if (available == bufsize) *************** *** 203,207 **** } ! protected void UpdateLineColumn(char c) { column++; --- 203,207 ---- } ! private final void UpdateLineColumn(char c) { column++; *************** *** 243,247 **** } ! public char readChar() throws java.io.IOException { if (inBuf > 0) --- 243,247 ---- } ! public final char readChar() throws java.io.IOException { if (inBuf > 0) *************** *** 340,344 **** */ ! public int getColumn() { return bufcolumn[bufpos]; } --- 340,344 ---- */ ! public final int getColumn() { return bufcolumn[bufpos]; } *************** *** 349,373 **** */ ! public int getLine() { return bufline[bufpos]; } ! public int getEndColumn() { return bufcolumn[bufpos]; } ! public int getEndLine() { return bufline[bufpos]; } ! public int getBeginColumn() { return bufcolumn[tokenBegin]; } ! public int getBeginLine() { return bufline[tokenBegin]; } ! public void backup(int amount) { inBuf += amount; --- 349,373 ---- */ ! public final int getLine() { return bufline[bufpos]; } ! public final int getEndColumn() { return bufcolumn[bufpos]; } ! public final int getEndLine() { return bufline[bufpos]; } ! public final int getBeginColumn() { return bufcolumn[tokenBegin]; } ! public final int getBeginLine() { return bufline[tokenBegin]; } ! public final void backup(int amount) { inBuf += amount; *************** *** 462,466 **** } ! public String GetImage() { if (bufpos >= tokenBegin) --- 462,466 ---- } ! public final String GetImage() { if (bufpos >= tokenBegin) *************** *** 471,475 **** } ! public char[] GetSuffix(int len) { char[] ret = new char[len]; --- 471,475 ---- } ! public final char[] GetSuffix(int len) { char[] ret = new char[len]; *************** *** 496,500 **** /** ! * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) --- 496,500 ---- /** ! * Method to adjust line and column numbers for the start of a token.<BR> */ public void adjustBeginLineColumn(int newLine, int newCol) Index: SLCompiler.jjt =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.jjt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SLCompiler.jjt 1 Aug 2004 00:29:36 -0000 1.2 --- SLCompiler.jjt 1 Aug 2004 04:50:40 -0000 1.3 *************** *** 49,53 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! new TestsVisitor().visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); } --- 49,56 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! TestsVisitor visitor = new TestsVisitor(); ! ((ASTcompilationUnit) compiler.jjtree.rootNode()).dump(" "); ! visitor.visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); ! visitor.showCode(); } *************** *** 375,388 **** { number() ! | ! stringconstant() ! | ! texture() ! | ! LOOKAHEAD(2) procedurecall() ! | ! LOOKAHEAD(2) identifier() [LOOKAHEAD(2) arrayindex()] [asgnop() expression()] ! //assignExpression(), identifier() ! | single() } --- 378,387 ---- { number() ! | stringconstant() ! | texture() ! | LOOKAHEAD(2) procedurecall() ! | LOOKAHEAD(2) identifier() [LOOKAHEAD(2) arrayindex()] [asgnop() expression()] ! | single() ! //assignExpression(), identifier() } Index: TestsVisitor.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/TestsVisitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestsVisitor.java 1 Aug 2004 00:29:36 -0000 1.1 --- TestsVisitor.java 1 Aug 2004 04:50:40 -0000 1.2 *************** *** 18,21 **** --- 18,23 ---- */ + import java.util.*; + public class TestsVisitor extends DefaultVisitor { *************** *** 28,31 **** --- 30,35 ---- SymbolTable st = new SymbolTable(); + List code = new ArrayList(); + boolean waitingForShaderName; *************** *** 46,50 **** } else if (st.get(node.name) == null) System.out.println("Undefined: " + node.name); ! return data; } --- 50,54 ---- } else if (st.get(node.name) == null) System.out.println("Undefined: " + node.name); ! return node.name; } *************** *** 96,98 **** --- 100,107 ---- } + void showCode() { + for (Iterator iter = code.iterator(); iter.hasNext(); ) + System.out.println(iter.next()); + } + } Index: ParseException.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/ParseException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParseException.java 31 Jul 2004 22:36:31 -0000 1.1 --- ParseException.java 1 Aug 2004 04:50:40 -0000 1.2 *************** *** 1,3 **** ! /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ /** * This exception is thrown when parse errors are encountered. --- 1,3 ---- ! /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 2.1 */ /** * This exception is thrown when parse errors are encountered. |
From: Gerardo H. <ma...@us...> - 2004-08-01 00:29:45
|
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21472 Modified Files: SLCompiler.java SLCompiler.jj SLCompiler.jjt Added Files: DefaultVisitor.java SymbolTable.java TestsVisitor.java TypeInfo.java Log Message: Type tests. Index: SLCompiler.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompiler.java 31 Jul 2004 22:36:31 -0000 1.1 --- SLCompiler.java 1 Aug 2004 00:29:36 -0000 1.2 *************** *** 21,25 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } --- 21,25 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! new TestsVisitor().visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); } Index: SLCompiler.jj =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.jj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompiler.jj 31 Jul 2004 22:36:31 -0000 1.1 --- SLCompiler.jj 1 Aug 2004 00:29:36 -0000 1.2 *************** *** 51,55 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } --- 51,55 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! new TestsVisitor().visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); } --- NEW FILE: TypeInfo.java --- public class TypeInfo { String type; String storage; String kind; TypeInfo(String kind, String type, String storage) { this.kind = kind; this.type = type; this.storage = storage; } public String toString() { return kind + " " + storage + " " + type; } } --- NEW FILE: DefaultVisitor.java --- /* DefaultVisitor.java Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ public class DefaultVisitor implements SLCompilerVisitor { public Object visit(SimpleNode node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTcompilationUnit node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTshaderDefinition node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTfunctionDefinition node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTidentifier node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTshaderType node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtype node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTformals node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTformalVariableDefinitions node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASToutputspec node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtypespec node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTdetail node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTdefExpressions node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTdefExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTdefInit node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTprimary node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTnumber node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTstringconstant node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtexture node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtextureType node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtextureFilename node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTchannel node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtextureArguments node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTarrayindex node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTprocedurecall node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTprocArguments node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTassignexpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTasgnop node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTsingle node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtriple node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTsixteentuple node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTtypecast node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTspacetype node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTconditionalExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTconditionalOrExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTconditionalAndExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTequalityExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTrelationalExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTadditiveExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTmultiplicativeExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASToperatorUnaryExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTcastExpression node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTreturnStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTloopModStmt node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTloopMod node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTifStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTwhileStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTforStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTsolarStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTilluminateStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTilluminanceStatement node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTexpressionList node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTvariableDefinitions node, Object data) { return node.childrenAccept(this, data); } public Object visit(ASTexternspec node, Object data) { return node.childrenAccept(this, data); } } --- NEW FILE: SymbolTable.java --- import java.util.*; public class SymbolTable { Map symbolsInfo = new HashMap(); SymbolTable() { symbolsInfo.put("faceforward", new TypeInfo("procedure", "varying", "vector")); symbolsInfo.put("normalize", new TypeInfo("procedure", "varying", "vector")); symbolsInfo.put("diffuse", new TypeInfo("procedure", "varying", "color")); symbolsInfo.put("specular", new TypeInfo("procedure", "varying", "color")); symbolsInfo.put("ambient", new TypeInfo("procedure", "uniform", "color")); symbolsInfo.put("N", new TypeInfo("variable", "varying", "normal")); symbolsInfo.put("I", new TypeInfo("variable", "varying", "vector")); symbolsInfo.put("Os", new TypeInfo("variable", "varying", "color")); symbolsInfo.put("Oi", new TypeInfo("variable", "varying", "color")); symbolsInfo.put("Cs", new TypeInfo("variable", "varying", "color")); symbolsInfo.put("Ci", new TypeInfo("variable", "varying", "color")); } TypeInfo get(String name) { return (TypeInfo) symbolsInfo.get(name); } void put(String name, TypeInfo typeInfo) { symbolsInfo.put(name, typeInfo); } public String toString() { StringBuffer sb = new StringBuffer(); for (Iterator iter = symbolsInfo.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); sb.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n'); } return sb.toString(); } } Index: SLCompiler.jjt =================================================================== RCS file: /cvsroot/jrman/drafts/slcompiler/SLCompiler.jjt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompiler.jjt 31 Jul 2004 22:36:31 -0000 1.1 --- SLCompiler.jjt 1 Aug 2004 00:29:36 -0000 1.2 *************** *** 49,53 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } --- 49,53 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! new TestsVisitor().visit((ASTcompilationUnit) compiler.jjtree.rootNode(), null); } --- NEW FILE: TestsVisitor.java --- /* TestsVisitor.java Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ public class TestsVisitor extends DefaultVisitor { String currentType; String currentDetail = "uniform"; boolean inDeclaration; SymbolTable st = new SymbolTable(); boolean waitingForShaderName; boolean waitingForFunctionName; public Object visit(ASTidentifier node, Object data) { if (waitingForShaderName) { st.put(node.name, new TypeInfo("shader", "none", currentType)); waitingForShaderName = false; } else if (waitingForFunctionName) { st.put(node.name, new TypeInfo("function", "none", currentType)); waitingForFunctionName = false; } else if (inDeclaration) { if (st.get(node.name) == null) st.put(node.name, new TypeInfo("variable", currentDetail, currentType)); else System.out.println("Already defined: " + node.name); } else if (st.get(node.name) == null) System.out.println("Undefined: " + node.name); return data; } public Object visit(ASTtype node, Object data) { currentType = node.type; return data; } public Object visit(ASTdetail node, Object data) { currentDetail = node.type; return data; } public Object visit(ASTformalVariableDefinitions node, Object data) { inDeclaration = true; data = node.childrenAccept(this, data); currentDetail = "uniform"; inDeclaration = false; return data; } public Object visit(ASTdefInit node, Object data) { inDeclaration = false; data = node.childrenAccept(this, data); inDeclaration = true; return data; } public Object visit(ASTcompilationUnit node, Object data) { data = node.childrenAccept(this, data); System.out.println(st); return data; } public Object visit(ASTshaderDefinition node, Object data) { waitingForShaderName = true; return node.childrenAccept(this, data); } public Object visit(ASTshaderType node, Object data) { currentType = node.type; return data; } public Object visit(ASTfunctionDefinition node, Object data) { waitingForFunctionName = true; currentType = "float"; return node.childrenAccept(this, data); } } |
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4294 Added Files: ASTadditiveExpression.java ASTarrayindex.java ASTasgnop.java ASTassignexpression.java ASTcastExpression.java ASTchannel.java ASTcompilationUnit.java ASTconditionalAndExpression.java ASTconditionalExpression.java ASTconditionalOrExpression.java ASTdefExpression.java ASTdefExpressions.java ASTdefInit.java ASTdetail.java ASTequalityExpression.java ASTexpressionList.java ASTexternspec.java ASTforStatement.java ASTformalVariableDefinitions.java ASTformals.java ASTfunctionDefinition.java ASTidentifier.java ASTifStatement.java ASTilluminanceStatement.java ASTilluminateStatement.java ASTloopMod.java ASTloopModStmt.java ASTmultiplicativeExpression.java ASTnumber.java ASToperatorUnaryExpression.java ASToutputspec.java ASTprimary.java ASTprocArguments.java ASTprocedurecall.java ASTrelationalExpression.java ASTreturnStatement.java ASTshaderDefinition.java ASTshaderType.java ASTsingle.java ASTsixteentuple.java ASTsolarStatement.java ASTspacetype.java ASTstringconstant.java ASTtexture.java ASTtextureArguments.java ASTtextureFilename.java ASTtextureType.java ASTtriple.java ASTtype.java ASTtypecast.java ASTtypespec.java ASTvariableDefinitions.java ASTwhileStatement.java JJTSLCompilerState.java JPP.java JavaCharStream.java Node.java ParseException.java SLCompiler.java SLCompiler.jj SLCompiler.jjt SLCompilerConstants.java SLCompilerTokenManager.java SLCompilerTreeConstants.java SLCompilerVisitor.java SimpleNode.java Token.java TokenMgrError.java bld Log Message: Visitor pattern. Grammar changes. --- NEW FILE: ASTprocArguments.java --- /* Generated By:JJTree: Do not edit this line. ASTprocArguments.java */ public class ASTprocArguments extends SimpleNode { public ASTprocArguments(int id) { super(id); } public ASTprocArguments(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: TokenMgrError.java --- /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * An attempt wass made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their espaced (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexicl error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn : column number when the error occured * errorAfter : prefix that was seen before this error occured * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ public TokenMgrError() { } public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } --- NEW FILE: SLCompiler.java --- /* Generated By:JJTree&JavaCC: Do not edit this line. SLCompiler.java */ import java.io.FileInputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class SLCompiler/*@bgen(jjtree)*/implements SLCompilerTreeConstants, SLCompilerConstants {/*@bgen(jjtree)*/ protected JJTSLCompilerState jjtree = new JJTSLCompilerState(); public static void main(String args[]) throws ParseException, IOException { InputStream in; if (args.length == 0) in = System.in; else in = new FileInputStream(args[0]); ByteArrayOutputStream out = new ByteArrayOutputStream(); JPP jpp = new JPP(in, out, new java.util.Vector(), new java.util.Hashtable()); jpp.preprocess(); [...3699 lines suppressed...] jj_rescan = false; } final private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { int gen; Token first; int arg; JJCalls next; } } --- NEW FILE: ASToperatorUnaryExpression.java --- /* Generated By:JJTree: Do not edit this line. ASToperatorUnaryExpression.java */ public class ASToperatorUnaryExpression extends SimpleNode { public ASToperatorUnaryExpression(int id) { super(id); } public ASToperatorUnaryExpression(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTtexture.java --- /* Generated By:JJTree: Do not edit this line. ASTtexture.java */ public class ASTtexture extends SimpleNode { public ASTtexture(int id) { super(id); } public ASTtexture(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTtypespec.java --- /* Generated By:JJTree: Do not edit this line. ASTtypespec.java */ public class ASTtypespec extends SimpleNode { public ASTtypespec(int id) { super(id); } public ASTtypespec(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: SLCompilerConstants.java --- /* Generated By:JJTree&JavaCC: Do not edit this line. SLCompilerConstants.java */ public interface SLCompilerConstants { int EOF = 0; int SINGLE_LINE_COMMENT = 8; int MULTI_LINE_COMMENT = 9; int LIGHT = 11; int SURFACE = 12; int VOLUME = 13; int DISPLACEMENT = 14; int IMAGER = 15; int FLOAT = 16; int STRING = 17; int COLOR = 18; int POINT = 19; int VECTOR = 20; int NORMAL = 21; int MATRIX = 22; int VOID = 23; int OUTPUT = 24; int VARYING = 25; int UNIFORM = 26; int TEXTURE = 27; int ENVIRONMENT = 28; int SHADOW = 29; int RETURN = 30; int EXTERN = 31; int BREAK = 32; int CONTINUE = 33; int IF = 34; int ELSE = 35; int WHILE = 36; int FOR = 37; int SOLAR = 38; int ILLUMINATE = 39; int ILLUMINANCE = 40; int INTEGER_LITERAL = 41; int DECIMAL_LITERAL = 42; int HEX_LITERAL = 43; int OCTAL_LITERAL = 44; int FLOATING_POINT_LITERAL = 45; int EXPONENT = 46; int CHARACTER_LITERAL = 47; int STRING_LITERAL = 48; int IDENTIFIER = 49; int LETTER = 50; int DIGIT = 51; int LPAREN = 52; int RPAREN = 53; int LBRACE = 54; int RBRACE = 55; int LBRACKET = 56; int RBRACKET = 57; int SEMICOLON = 58; int COMMA = 59; int PLUS = 60; int MINUS = 61; int STAR = 62; int SLASH = 63; int EXP = 64; int BANG = 65; int ASSIGN = 66; int HOOK = 67; int PLUSASSIGN = 68; int MINUSASSIGN = 69; int STARASSIGN = 70; int SLASHASSIGN = 71; int COLON = 72; int DOT = 73; int DEFAULT = 0; int IN_SINGLE_LINE_COMMENT = 1; int IN_MULTI_LINE_COMMENT = 2; String[] tokenImage = { "<EOF>", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", "\"\\f\"", "\"//\"", "\"/*\"", "<SINGLE_LINE_COMMENT>", "\"*/\"", "<token of kind 10>", "\"light\"", "\"surface\"", "\"volume\"", "\"displacement\"", "\"imager\"", "\"float\"", "\"string\"", "\"color\"", "\"point\"", "\"vector\"", "\"normal\"", "\"matrix\"", "\"void\"", "\"output\"", "\"varying\"", "\"uniform\"", "\"texture\"", "\"environment\"", "\"shadow\"", "\"return\"", "\"extern\"", "\"break\"", "\"continue\"", "\"if\"", "\"else\"", "\"while\"", "\"for\"", "\"solar\"", "\"illuminate\"", "\"illuminance\"", "<INTEGER_LITERAL>", "<DECIMAL_LITERAL>", "<HEX_LITERAL>", "<OCTAL_LITERAL>", "<FLOATING_POINT_LITERAL>", "<EXPONENT>", "<CHARACTER_LITERAL>", "<STRING_LITERAL>", "<IDENTIFIER>", "<LETTER>", "<DIGIT>", "\"(\"", "\")\"", "\"{\"", "\"}\"", "\"[\"", "\"]\"", "\";\"", "\",\"", "\"+\"", "\"-\"", "\"*\"", "\"/\"", "\"^\"", "\"!\"", "\"=\"", "\"?\"", "\"+=\"", "\"-=\"", "\"*=\"", "\"/=\"", "\":\"", "\".\"", "\"||\"", "\"&&\"", "\"==\"", "\"!=\"", "\"<\"", "\">\"", "\"<=\"", "\">=\"", }; } --- NEW FILE: ASTsolarStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTsolarStatement.java */ public class ASTsolarStatement extends SimpleNode { public ASTsolarStatement(int id) { super(id); } public ASTsolarStatement(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTvariableDefinitions.java --- /* Generated By:JJTree: Do not edit this line. ASTvariableDefinitions.java */ public class ASTvariableDefinitions extends SimpleNode { public ASTvariableDefinitions(int id) { super(id); } public ASTvariableDefinitions(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTformalVariableDefinitions.java --- /* Generated By:JJTree: Do not edit this line. ASTformalVariableDefinitions.java */ public class ASTformalVariableDefinitions extends SimpleNode { public ASTformalVariableDefinitions(int id) { super(id); } public ASTformalVariableDefinitions(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTcompilationUnit.java --- /* Generated By:JJTree: Do not edit this line. ASTcompilationUnit.java */ public class ASTcompilationUnit extends SimpleNode { public ASTcompilationUnit(int id) { super(id); } public ASTcompilationUnit(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: SLCompiler.jjt --- /* SLCompiler.jjt Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ options { STATIC = false; MULTI = true; LOOKAHEAD = 1; VISITOR = true; JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(SLCompiler) import java.io.FileInputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class SLCompiler { public static void main(String args[]) throws ParseException, IOException { InputStream in; if (args.length == 0) in = System.in; else in = new FileInputStream(args[0]); ByteArrayOutputStream out = new ByteArrayOutputStream(); JPP jpp = new JPP(in, out, new java.util.Vector(), new java.util.Hashtable()); jpp.preprocess(); SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } } PARSER_END(SLCompiler) /* WHITE SPACE */ SKIP : { " " | "\t" | "\n" | "\r" | "\f" } /* COMMENTS */ MORE : { "//" : IN_SINGLE_LINE_COMMENT | "/*" : IN_MULTI_LINE_COMMENT } <IN_SINGLE_LINE_COMMENT> SPECIAL_TOKEN : { <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT } <IN_MULTI_LINE_COMMENT> SPECIAL_TOKEN : { <MULTI_LINE_COMMENT: "*/" > : DEFAULT } <IN_SINGLE_LINE_COMMENT,IN_MULTI_LINE_COMMENT> MORE : { < ~[] > } /* RESERVED WORDS AND LITERALS */ TOKEN : { < LIGHT: "light" > | < SURFACE: "surface" > | < VOLUME: "volume" > | < DISPLACEMENT: "displacement" > | < IMAGER: "imager" > | < FLOAT: "float" > | < STRING: "string" > | < COLOR: "color" > | < POINT: "point" > | < VECTOR: "vector" > | < NORMAL: "normal" > | < MATRIX: "matrix" > | < VOID: "void" > | < OUTPUT: "output" > | < VARYING: "varying" > | < UNIFORM: "uniform" > | < TEXTURE: "texture" > | < ENVIRONMENT: "environment" > | < SHADOW: "shadow" > | < RETURN: "return" > | < EXTERN: "extern" > | < BREAK: "break" > | < CONTINUE: "continue" > | < IF: "if" > | < ELSE: "else" > | < WHILE: "while" > | < FOR: "for" > | < SOLAR: "solar" > | < ILLUMINATE: "illuminate" > | < ILLUMINANCE: "illuminance" > } /* LITERALS */ TOKEN : { < INTEGER_LITERAL: <DECIMAL_LITERAL> (["l","L"])? | <HEX_LITERAL> (["l","L"])? | <OCTAL_LITERAL> (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > | < FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])? | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])? | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])? | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"] > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < CHARACTER_LITERAL: "'" ( (~["'","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\""] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) ) "'" > | < STRING_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\""] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* "\"" > } /* IDENTIFIERS */ TOKEN : { < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* > | < #LETTER: [ "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "\u0030"-"\u0039", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > } /* SEPARATORS */ TOKEN : { < LPAREN: "(" > | < RPAREN: ")" > | < LBRACE: "{" > | < RBRACE: "}" > | < LBRACKET: "[" > | < RBRACKET: "]" > | < SEMICOLON: ";" > | < COMMA: "," > } /* OPERATORS */ TOKEN : { < PLUS: "+" > | < MINUS: "-" > | < STAR: "*" > | < SLASH: "/" > | < EXP: "^" > | < BANG: "!" > | < ASSIGN: "=" > | < HOOK: "?" > | < PLUSASSIGN: "+=" > | < MINUSASSIGN: "-=" > | < STARASSIGN: "*=" > | < SLASHASSIGN: "/=" > | < COLON: ":" > | < DOT: "." > } void compilationUnit(): {} { definitions() <EOF> } void definitions() #void : {} { (shaderDefinition() | functionDefinition())+ } void shaderDefinition(): {} { shaderType() identifier() "("[formals()]")" statements() } void functionDefinition(): {} { [type()] identifier() "("[formals()]")" statements() } void identifier(): { Token t; } { t = <IDENTIFIER> { jjtThis.name = t.image; } } void shaderType(): { Token t; } { t = <LIGHT> { jjtThis.type = t.image; } | t = <SURFACE> { jjtThis.type = t.image; } | t = <VOLUME> { jjtThis.type = t.image; } | t = <DISPLACEMENT> {jjtThis.type = t.image; } | t = <IMAGER> { jjtThis.type = t.image; } } void type(): { Token t; } { t = <FLOAT> { jjtThis.type = t.image; } | t = <STRING> { jjtThis.type = t.image; } | t = <COLOR> { jjtThis.type = t.image; } | t = <POINT> { jjtThis.type = t.image; } | t = <VECTOR> { jjtThis.type = t.image; } | t = <NORMAL> { jjtThis.type = t.image; } | t = <MATRIX> { jjtThis.type = t.image; } | t = <VOID> { jjtThis.type = t.image; } } void formals(): {} { formalVariableDefinitions() [";"] (LOOKAHEAD(2) formalVariableDefinitions() ";")* } void formalVariableDefinitions(): {} { [outputspec()] typespec() defExpressions() } void outputspec(): {} { <OUTPUT> } void typespec(): {} { [detail()] type() } void detail(): { Token t; } { t = <VARYING> { jjtThis.type = t.image; } | t = <UNIFORM> { jjtThis.type = t.image; } } void defExpressions(): {} { defExpression() ("," defExpression() )* } void defExpression(): {} { identifier() [defInit()] } void defInit(): {} { "=" expression() } void expression() #void : {} { conditionalExpression() } void primary(): {} { number() | stringconstant() | texture() | LOOKAHEAD(2) procedurecall() | LOOKAHEAD(2) identifier() [LOOKAHEAD(2) arrayindex()] [asgnop() expression()] //assignExpression(), identifier() | single() } void number(): { Token t; } { t = <INTEGER_LITERAL> { jjtThis.value = t.image; } | t = <FLOATING_POINT_LITERAL> { jjtThis.value = t.image; } } void stringconstant(): { Token t; } { t = <STRING_LITERAL> { jjtThis.value = t.image.substring(1, t.image.length() - 1); } } void texture(): {} { textureType() "(" textureFilename() [channel()] [textureArguments()] ")" } void textureType(): { Token t; } { t = <TEXTURE> { jjtThis.type = t.image; } | t = <ENVIRONMENT> { jjtThis.type = t.image; } | t = <SHADOW> { jjtThis.type = t.image; } } void textureFilename(): {} { expression() } void channel(): {} { "[" expression() "]" } void textureArguments(): {} { "," expression() ("," expression() )* } void arrayindex(): {} { "["expression()"]" } void procedurecall(): {} { identifier() "(" [procArguments()] ")" } void procArguments(): {} { expression() ("," expression() )* } void assignexpression(): {} { identifier() [arrayindex()] asgnop() expression() } void asgnop(): { Token t; } { t = <ASSIGN> { jjtThis.type = t.image; } | t = <PLUSASSIGN> { jjtThis.type = t.image; } | t = <MINUSASSIGN> { jjtThis.type = t.image; } | t = <STARASSIGN> { jjtThis.type = t.image; } | t = <SLASHASSIGN> { jjtThis.type = t.image; } } void single(): {} { "(" expression() [ triple() ] ")" } void triple(): {} { "," expression() ","expression() } void sixteentuple(): {} { "," expression() ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() } void typecast(): { Token t; } { t = <FLOAT> { jjtThis.type = t.image; } | t = <STRING> { jjtThis.type = t.image; } | t = <COLOR> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] | t = <POINT> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] | t = <VECTOR> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] | t = <NORMAL> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] | t = <MATRIX> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] } void spacetype(): {} { stringconstant() } void conditionalExpression() : {} { conditionalOrExpression() [LOOKAHEAD(2) "?" expression() ":" conditionalExpression() ] } void conditionalOrExpression() #void : {} { ( conditionalAndExpression() (LOOKAHEAD(2) "||" conditionalAndExpression() )* ) #conditionalOrExpression(>1) } void conditionalAndExpression() #void : {} { ( equalityExpression() (LOOKAHEAD(2) "&&" equalityExpression() )* ) #conditionalAndExpression(>1) } void equalityExpression() #void : { Token t; } { ( relationalExpression() (LOOKAHEAD(2) ( t = "==" | t = "!=" ) relationalExpression() { jjtThis.add(t.image); })* ) #equalityExpression(>1) } void relationalExpression() #void : { Token t; } { ( additiveExpression() (LOOKAHEAD(2) ( t = "<" | t = ">" | t = "<=" | t = ">=" ) additiveExpression() { jjtThis.add(t.image); })* ) #relationalExpression(>1) } void additiveExpression() #void : { Token t; } { ( multiplicativeExpression() (LOOKAHEAD(2) ( t = "+" | t = "-" ) multiplicativeExpression() { jjtThis.add(t.image); })* ) #additiveExpression(>1) } void multiplicativeExpression() #void : { Token t; } { ( unaryExpression() (LOOKAHEAD(2) ( t = "." | t = "*" | t = "/" | t = "^" ) unaryExpression() { jjtThis.add(t.image); })* ) #multiplicativeExpression(>1) } void unaryExpression() #void : {} { operatorUnaryExpression() | simpleUnaryExpression() } void operatorUnaryExpression() : { Token t; } { ( t = "!" | t = "-" ) simpleUnaryExpression() { jjtThis.type = t.image; } } void simpleUnaryExpression() #void : {} { castExpression() | primary() } void castExpression() : {} { typecast() unaryExpression() } void statement() #void : {} { statements() | LOOKAHEAD(2) assignexpression() ";" | variableDefinitions() ";" | procedurecall() ";" | returnStatement() ";" | loopModStmt() | ifStatement() | loopControl() } void returnStatement() : {} { <RETURN> expression() } void loopModStmt(): { Token t; } { loopMod() [t = <INTEGER_LITERAL> { jjtThis.number = t.image; }] } void loopMod(): { Token t; } { t = <BREAK> { jjtThis.type = t.image; } | t = <CONTINUE> { jjtThis.type = t.image; } } void ifStatement(): {} { <IF> "(" booleanExpression() ")" statement() [ LOOKAHEAD(2) <ELSE> statement() ] } void booleanExpression() #void : {} { expression() } void loopControl() #void : {} { whileStatement() | forStatement() | solarStatement() | illuminateStatement() | illuminanceStatement() } void whileStatement(): {} { <WHILE> "(" booleanExpression() ")" statement() } void forStatement(): {} { <FOR> "(" forInit() ";" booleanExpression() ";" forUpdate() ")" statement() } void forInit() #void : {} { expression() } void forUpdate() #void : {} { expression() } void solarStatement(): {} { <SOLAR> "(" [expressionList()] ")" statement() } void illuminateStatement(): {} { <ILLUMINATE> "(" [expressionList()] ")" statement() } void illuminanceStatement(): {} { <ILLUMINANCE> "(" [expressionList()] ")" statement() } void expressionList(): {} { expression() ("," expression())* } void variableDefinitions(): {} { [externspec()] typespec() defExpressions() } void externspec(): {} { <EXTERN> } void statements() #void : {} { "{" ( blockStatement() )* "}" } void blockStatement() #void : {} { LOOKAHEAD(3) formals() | statement() } --- NEW FILE: ASTtextureArguments.java --- /* Generated By:JJTree: Do not edit this line. ASTtextureArguments.java */ public class ASTtextureArguments extends SimpleNode { public ASTtextureArguments(int id) { super(id); } public ASTtextureArguments(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTmultiplicativeExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTmultiplicativeExpression.java */ public class ASTmultiplicativeExpression extends SimpleNode { public ASTmultiplicativeExpression(int id) { super(id); } public ASTmultiplicativeExpression(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTshaderDefinition.java --- /* Generated By:JJTree: Do not edit this line. ASTshaderDefinition.java */ public class ASTshaderDefinition extends SimpleNode { public ASTshaderDefinition(int id) { super(id); } public ASTshaderDefinition(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTnumber.java --- /* Generated By:JJTree: Do not edit this line. ASTnumber.java */ public class ASTnumber extends SimpleNode { public ASTnumber(int id) { super(id); } public ASTnumber(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTtextureFilename.java --- /* Generated By:JJTree: Do not edit this line. ASTtextureFilename.java */ public class ASTtextureFilename extends SimpleNode { public ASTtextureFilename(int id) { super(id); } public ASTtextureFilename(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTdefInit.java --- /* Generated By:JJTree: Do not edit this line. ASTdefInit.java */ public class ASTdefInit extends SimpleNode { public ASTdefInit(int id) { super(id); } public ASTdefInit(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTtypecast.java --- /* Generated By:JJTree: Do not edit this line. ASTtypecast.java */ public class ASTtypecast extends SimpleNode { public ASTtypecast(int id) { super(id); } public ASTtypecast(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTchannel.java --- /* Generated By:JJTree: Do not edit this line. ASTchannel.java */ public class ASTchannel extends SimpleNode { public ASTchannel(int id) { super(id); } public ASTchannel(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTtextureType.java --- /* Generated By:JJTree: Do not edit this line. ASTtextureType.java */ public class ASTtextureType extends SimpleNode { public ASTtextureType(int id) { super(id); } public ASTtextureType(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTdefExpressions.java --- /* Generated By:JJTree: Do not edit this line. ASTdefExpressions.java */ public class ASTdefExpressions extends SimpleNode { public ASTdefExpressions(int id) { super(id); } public ASTdefExpressions(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: SLCompiler.jj --- /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. SLCompiler.jj */ /*@egen*//* SLCompiler.jjt Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ [...2082 lines suppressed...] jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void statements() : {} { "{" ( blockStatement() )* "}" } void blockStatement() : {} { LOOKAHEAD(3) formals() | statement() } --- NEW FILE: ASTconditionalExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTconditionalExpression.java */ public class ASTconditionalExpression extends SimpleNode { public ASTconditionalExpression(int id) { super(id); } public ASTconditionalExpression(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: JavaCharStream.java --- /* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 3.0 */ /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (with java-like unicode escape processing). */ public class JavaCharStream { public static final boolean staticFlag = false; static final int hexval(char c) throws java.io.IOException { switch(c) { case '0' : return 0; case '1' : return 1; case '2' : return 2; case '3' : return 3; case '4' : return 4; case '5' : return 5; case '6' : return 6; case '7' : return 7; case '8' : return 8; case '9' : return 9; case 'a' : case 'A' : return 10; case 'b' : case 'B' : return 11; case 'c' : case 'C' : return 12; case 'd' : case 'D' : return 13; case 'e' : case 'E' : return 14; case 'f' : case 'F' : return 15; } throw new java.io.IOException(); // Should never come here } public int bufpos = -1; int bufsize; int available; int tokenBegin; protected int bufline[]; protected int bufcolumn[]; protected int column = 0; protected int line = 1; protected boolean prevCharIsCR = false; protected boolean prevCharIsLF = false; protected java.io.Reader inputStream; protected char[] nextCharBuf; protected char[] buffer; protected int maxNextCharInd = 0; protected int nextCharInd = -1; protected int inBuf = 0; protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; bufpos += (bufsize - tokenBegin); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; bufpos -= tokenBegin; } } catch (Throwable t) { throw new Error(t.getMessage()); } available = (bufsize += 2048); tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { int i; if (maxNextCharInd == 4096) maxNextCharInd = nextCharInd = 0; try { if ((i = inputStream.read(nextCharBuf, maxNextCharInd, 4096 - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { if (bufpos != 0) { --bufpos; backup(0); } else { bufline[bufpos] = line; bufcolumn[bufpos] = column; } throw e; } } protected char ReadByte() throws java.io.IOException { if (++nextCharInd >= maxNextCharInd) FillBuff(); return nextCharBuf[nextCharInd]; } public char BeginToken() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; tokenBegin = bufpos; return buffer[bufpos]; } tokenBegin = 0; bufpos = -1; return readChar(); } protected void AdjustBuffSize() { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = 0; available = tokenBegin; } else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (8 - (column & 07)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } char c; if (++bufpos == available) AdjustBuffSize(); if ((buffer[bufpos] = c = ReadByte()) == '\\') { UpdateLineColumn(c); int backSlashCnt = 1; for (;;) // Read all the backslashes { if (++bufpos == available) AdjustBuffSize(); try { if ((buffer[bufpos] = c = ReadByte()) != '\\') { UpdateLineColumn(c); // found a non-backslash char. if ((c == 'u') && ((backSlashCnt & 1) == 1)) { if (--bufpos < 0) bufpos = bufsize - 1; break; } backup(backSlashCnt); return '\\'; } } catch(java.io.IOException e) { if (backSlashCnt > 1) backup(backSlashCnt); return '\\'; } UpdateLineColumn(c); backSlashCnt++; } // Here, we have seen an odd number of backslash's followed by a 'u' try { while ((c = ReadByte()) == 'u') ++column; buffer[bufpos] = c = (char)(hexval(c) << 12 | hexval(ReadByte()) << 8 | hexval(ReadByte()) << 4 | hexval(ReadByte())); column += 4; } catch(java.io.IOException e) { throw new Error("Invalid escape character at line " + line + " column " + column + "."); } if (backSlashCnt == 1) return c; else { backup(backSlashCnt - 1); return '\\'; } } else { UpdateLineColumn(c); return (c); } } /** * @deprecated * @see #getEndColumn */ public int getColumn() { return bufcolumn[bufpos]; } /** * @deprecated * @see #getEndLine */ public int getLine() { return bufline[bufpos]; } public int getEndColumn() { return bufcolumn[bufpos]; } public int getEndLine() { return bufline[bufpos]; } public int getBeginColumn() { return bufcolumn[tokenBegin]; } public int getBeginLine() { return bufline[tokenBegin]; } public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public JavaCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; nextCharInd = bufpos = -1; } public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public JavaCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } public void Done() { nextCharBuf = null; buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } --- NEW FILE: ASTreturnStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTreturnStatement.java */ public class ASTreturnStatement extends SimpleNode { public ASTreturnStatement(int id) { super(id); } public ASTreturnStatement(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTdetail.java --- /* Generated By:JJTree: Do not edit this line. ASTdetail.java */ public class ASTdetail extends SimpleNode { public ASTdetail(int id) { super(id); } public ASTdetail(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTdefExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTdefExpression.java */ public class ASTdefExpression extends SimpleNode { public ASTdefExpression(int id) { super(id); } public ASTdefExpression(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: SimpleNode.java --- /* Generated By:JJTree: Do not edit this line. SimpleNode.java */ import java.util.*; public class SimpleNode implements Node { protected Node parent; protected Node[] children; protected int id; protected SLCompiler parser; String type; String name; String value; String number; List ops = new ArrayList(); public SimpleNode(int i) { id = i; } public SimpleNode(SLCompiler p, int i) { this(i); parser = p; } public void jjtOpen() { } public void jjtClose() { } public void jjtSetParent(Node n) { parent = n; } public Node jjtGetParent() { return parent; } public void jjtAddChild(Node n, int i) { if (children == null) { children = new Node[i + 1]; } else if (i >= children.length) { Node c[] = new Node[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } children[i] = n; } public Node jjtGetChild(int i) { return children[i]; } public int jjtGetNumChildren() { return (children == null) ? 0 : children.length; } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } /** Accept the visitor. **/ public Object childrenAccept(SLCompilerVisitor visitor, Object data) { if (children != null) { for (int i = 0; i < children.length; ++i) { children[i].jjtAccept(visitor, data); } } return data; } /* You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding toString() is probably all you need to do. */ public String toString() { return SLCompilerTreeConstants.jjtNodeName[id]; } public String toString(String prefix) { return prefix + toString(); } /* Override this method if you want to customize how the node dumps out its children. */ public void dump(String prefix) { System.out.println(toString(prefix)); if (children != null) { for (int i = 0; i < children.length; ++i) { SimpleNode n = (SimpleNode)children[i]; if (n != null) { n.dump(prefix + " "); } } } } void add(String op) { ops.add(op); } } --- NEW FILE: bld --- rm build/*.class jjtree SLCompiler.jjt javacc SLCompiler.jj javac -d build *.java --- NEW FILE: ASTasgnop.java --- /* Generated By:JJTree: Do not edit this line. ASTasgnop.java */ public class ASTasgnop extends SimpleNode { public ASTasgnop(int id) { super(id); } public ASTasgnop(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTifStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTifStatement.java */ public class ASTifStatement extends SimpleNode { public ASTifStatement(int id) { super(id); } public ASTifStatement(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: JJTSLCompilerState.java --- /* Generated By:JJTree: Do not edit this line. JJTSLCompilerState.java */ class JJTSLCompilerState { private java.util.Stack nodes; private java.util.Stack marks; private int sp; // number of nodes on stack private int mk; // current mark private boolean node_created; JJTSLCompilerState() { nodes = new java.util.Stack(); marks = new java.util.Stack(); sp = 0; mk = 0; } /* Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope. */ boolean nodeCreated() { return node_created; } /* Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. */ void reset() { nodes.removeAllElements(); marks.removeAllElements(); sp = 0; mk = 0; } /* Returns the root node of the AST. It only makes sense to call this after a successful parse. */ Node rootNode() { return (Node)nodes.elementAt(0); } /* Pushes a node on to the stack. */ void pushNode(Node n) { nodes.push(n); ++sp; } /* Returns the node on the top of the stack, and remove it from the stack. */ Node popNode() { if (--sp < mk) { mk = ((Integer)marks.pop()).intValue(); } return (Node)nodes.pop(); } /* Returns the node currently on the top of the stack. */ Node peekNode() { return (Node)nodes.peek(); } /* Returns the number of children on the stack in the current node scope. */ int nodeArity() { return sp - mk; } void clearNodeScope(Node n) { while (sp > mk) { popNode(); } mk = ((Integer)marks.pop()).intValue(); } void openNodeScope(Node n) { marks.push(new Integer(mk)); mk = sp; n.jjtOpen(); } /* A definite node is constructed from a specified number of children. That number of nodes are popped from the stack and made the children of the definite node. Then the definite node is pushed on to the stack. */ void closeNodeScope(Node n, int num) { mk = ((Integer)marks.pop()).intValue(); while (num-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, num); } n.jjtClose(); pushNode(n); node_created = true; } /* A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node was opened are made children of the the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack. */ void closeNodeScope(Node n, boolean condition) { if (condition) { int a = nodeArity(); mk = ((Integer)marks.pop()).intValue(); while (a-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, a); } n.jjtClose(); pushNode(n); node_created = true; } else { mk = ((Integer)marks.pop()).intValue(); node_created = false; } } } --- NEW FILE: ASTarrayindex.java --- /* Generated By:JJTree: Do not edit this line. ASTarrayindex.java */ public class ASTarrayindex extends SimpleNode { public ASTarrayindex(int id) { super(id); } public ASTarrayindex(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: SLCompilerTokenManager.java --- /* Generated By:JJTree&JavaCC: Do not edit this line. SLCompilerTokenManager.java */ import java.io.FileInputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class SLCompilerTokenManager implements SLCompilerConstants { public java.io.PrintStream debugStream = System.out; public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { switch (pos) { case 0: if ((active1 & 0x200L) != 0L) return 4; if ((active0 & 0x1fffffff800L) != 0L) [...1435 lines suppressed...] error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) { default : break; } } } --- NEW FILE: ASTsixteentuple.java --- /* Generated By:JJTree: Do not edit this line. ASTsixteentuple.java */ public class ASTsixteentuple extends SimpleNode { public ASTsixteentuple(int id) { super(id); } public ASTsixteentuple(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: SLCompilerTreeConstants.java --- /* Generated By:JJTree: Do not edit this line. SLCompilerTreeConstants.java */ public interface SLCompilerTreeConstants { public int JJTCOMPILATIONUNIT = 0; public int JJTVOID = 1; public int JJTSHADERDEFINITION = 2; public int JJTFUNCTIONDEFINITION = 3; public int JJTIDENTIFIER = 4; public int JJTSHADERTYPE = 5; public int JJTTYPE = 6; public int JJTFORMALS = 7; public int JJTFORMALVARIABLEDEFINITIONS = 8; public int JJTOUTPUTSPEC = 9; public int JJTTYPESPEC = 10; public int JJTDETAIL = 11; public int JJTDEFEXPRESSIONS = 12; public int JJTDEFEXPRESSION = 13; public int JJTDEFINIT = 14; public int JJTPRIMARY = 15; public int JJTNUMBER = 16; public int JJTSTRINGCONSTANT = 17; public int JJTTEXTURE = 18; public int JJTTEXTURETYPE = 19; public int JJTTEXTUREFILENAME = 20; public int JJTCHANNEL = 21; public int JJTTEXTUREARGUMENTS = 22; public int JJTARRAYINDEX = 23; public int JJTPROCEDURECALL = 24; public int JJTPROCARGUMENTS = 25; public int JJTASSIGNEXPRESSION = 26; public int JJTASGNOP = 27; public int JJTSINGLE = 28; public int JJTTRIPLE = 29; public int JJTSIXTEENTUPLE = 30; public int JJTTYPECAST = 31; public int JJTSPACETYPE = 32; public int JJTCONDITIONALEXPRESSION = 33; public int JJTCONDITIONALOREXPRESSION = 34; public int JJTCONDITIONALANDEXPRESSION = 35; public int JJTEQUALITYEXPRESSION = 36; public int JJTRELATIONALEXPRESSION = 37; public int JJTADDITIVEEXPRESSION = 38; public int JJTMULTIPLICATIVEEXPRESSION = 39; public int JJTOPERATORUNARYEXPRESSION = 40; public int JJTCASTEXPRESSION = 41; public int JJTRETURNSTATEMENT = 42; public int JJTLOOPMODSTMT = 43; public int JJTLOOPMOD = 44; public int JJTIFSTATEMENT = 45; public int JJTWHILESTATEMENT = 46; public int JJTFORSTATEMENT = 47; public int JJTSOLARSTATEMENT = 48; public int JJTILLUMINATESTATEMENT = 49; public int JJTILLUMINANCESTATEMENT = 50; public int JJTEXPRESSIONLIST = 51; public int JJTVARIABLEDEFINITIONS = 52; public int JJTEXTERNSPEC = 53; public String[] jjtNodeName = { "compilationUnit", "void", "shaderDefinition", "functionDefinition", "identifier", "shaderType", "type", "formals", "formalVariableDefinitions", "outputspec", "typespec", "detail", "defExpressions", "defExpression", "defInit", "primary", "number", "stringconstant", "texture", "textureType", "textureFilename", "channel", "textureArguments", "arrayindex", "procedurecall", "procArguments", "assignexpression", "asgnop", "single", "triple", "sixteentuple", "typecast", "spacetype", "conditionalExpression", "conditionalOrExpression", "conditionalAndExpression", "equalityExpression", "relationalExpression", "additiveExpression", "multiplicativeExpression", "operatorUnaryExpression", "castExpression", "returnStatement", "loopModStmt", "loopMod", "ifStatement", "whileStatement", "forStatement", "solarStatement", "illuminateStatement", "illuminanceStatement", "expressionList", "variableDefinitions", "externspec", }; } --- NEW FILE: ASTadditiveExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTadditiveExpression.java */ public class ASTadditiveExpression extends SimpleNode { public ASTadditiveExpression(int id) { super(id); } public ASTadditiveExpression(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTsingle.java --- /* Generated By:JJTree: Do not edit this line. ASTsingle.java */ public class ASTsingle extends SimpleNode { public ASTsingle(int id) { super(id); } public ASTsingle(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTilluminanceStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTilluminanceStatement.java */ public class ASTilluminanceStatement extends SimpleNode { public ASTilluminanceStatement(int id) { super(id); } public ASTilluminanceStatement(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTexpressionList.java --- /* Generated By:JJTree: Do not edit this line. ASTexpressionList.java */ public class ASTexpressionList extends SimpleNode { public ASTexpressionList(int id) { super(id); } public ASTexpressionList(SLCompiler p, int id) { super(p, id); } /** Accept the visitor. **/ public Object jjtAccept(SLCompilerVisitor visitor, Object data) { return visitor.visit(this, data); } } --- NEW FILE: ASTtriple.java --- /* Generated By:JJTree: Do not edit this line. ASTtriple.java */ public class ASTtriple extends SimpleNode... [truncated message content] |
From: Gerardo H. <ma...@us...> - 2004-07-31 22:36:39
|
Update of /cvsroot/jrman/drafts/slcompiler/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4294/shaders Added Files: constant.sl matte.sl metal.sl plastic.sl Log Message: Visitor pattern. Grammar changes. --- NEW FILE: metal.sl --- surface metal( float Ka = 1; float Kd = 1; float roughness = .1;) { normal Nf = faceforward(normalize(N), I); vector V = -normalize(I); Oi = Os; Ci = Os * Cs * (Ka * ambient() + Ks * specular(Nf, V, roughness)); } --- NEW FILE: constant.sl --- surface constant() { Oi = Os; Ci = Os * Cs; } --- NEW FILE: matte.sl --- surface matte( float Ka = 1; float Kd = 1;) { normal Nf = faceforward(normalize(N), I); Oi = Os; Ci = Os * Cs * (Ka * ambient() + Kd * diffuse(Nf)); } --- NEW FILE: plastic.sl --- surface plastic( float Ka = 1; float Kd = .5; float Ks = .5; float roughness = .1; color specularcolor = 1;) { normal Nf = faceforward(normalize(N), I); vector V = -normalize(I); Oi = Os; Ci = Os * (Cs * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness)); } |
From: Gerardo H. <ma...@us...> - 2004-07-31 19:19:17
|
Update of /cvsroot/jrman/drafts/slcompiler/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8874/shaders Log Message: Directory /cvsroot/jrman/drafts/slcompiler/shaders added to the repository |
From: Gerardo H. <ma...@us...> - 2004-07-31 19:18:10
|
Update of /cvsroot/jrman/drafts/slcompiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8624/slcompiler Log Message: Directory /cvsroot/jrman/drafts/slcompiler added to the repository |
Update of /cvsroot/jrman/drafts/slcomp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13066 Modified Files: ASTadditiveExpression.java ASTasgnop.java ASTdetail.java ASTequalityExpression.java ASTidentifier.java ASTloopMod.java ASTloopModStmt.java ASTmultiplicativeExpression.java ASTnumber.java ASTrelationalExpression.java ASTshaderType.java ASTstatement.java ASTstringconstant.java ASTtextureType.java ASTtype.java ASTtypecast.java ASTunaryExpression.java ASTunaryExpressionNotPlusMinus.java SLCompiler.java SLCompiler.jjt Added Files: bld Log Message: Added test shaders. Stored extra parse info in AST nodes. Index: SLCompiler.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/SLCompiler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SLCompiler.java 31 Jul 2004 05:43:36 -0000 1.2 --- SLCompiler.java 31 Jul 2004 16:08:28 -0000 1.3 *************** *** 246,252 **** ASTidentifier jjtn000 = new ASTidentifier(JJTIDENTIFIER); boolean jjtc000 = true; ! jjtree.openNodeScope(jjtn000); try { ! jj_consume_token(IDENTIFIER); } finally { if (jjtc000) { --- 246,255 ---- ASTidentifier jjtn000 = new ASTidentifier(JJTIDENTIFIER); boolean jjtc000 = true; [...2253 lines suppressed...] + if (jj_3R_38()) { + jj_scanpos = xsp; + if (jj_3R_39()) return true; + } + return false; + } + + final private boolean jj_3R_38() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(60)) { + jj_scanpos = xsp; + if (jj_scan_token(61)) return true; + } + if (jj_3R_27()) return true; + return false; + } + public SLCompilerTokenManager token_source; JavaCharStream jj_input_stream; Index: ASTstatement.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTstatement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTstatement.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTstatement.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTstatement extends SimpleNode { - public ASTstatement(int id) { - super(id); - } ! public ASTstatement(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,20 ---- public class ASTstatement extends SimpleNode { ! boolean isReturn; ! ! public ASTstatement(int id) { ! super(id); ! } ! ! public ASTstatement(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("statement: return = " + isReturn); ! super.compile(context); ! } } Index: ASTstringconstant.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTstringconstant.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTstringconstant.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTstringconstant.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTstringconstant extends SimpleNode { ! public ASTstringconstant(int id) { ! super(id); ! } ! public ASTstringconstant(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,18 ---- public class ASTstringconstant extends SimpleNode { ! String value; ! ! public ASTstringconstant(int id) { ! super(id); ! } ! ! public ASTstringconstant(SLCompiler p, int id) { ! super(p, id); ! } ! public void compile(CompilerContext context) { ! System.out.println("stringconstant: " + value); ! } } Index: ASTshaderType.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTshaderType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTshaderType.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTshaderType.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTshaderType extends SimpleNode { - public ASTshaderType(int id) { - super(id); - } ! public ASTshaderType(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTshaderType extends SimpleNode { ! String type; ! ! public ASTshaderType(int id) { ! super(id); ! } ! ! public ASTshaderType(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("shaderType: " + type); ! } } Index: ASTunaryExpression.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTunaryExpression.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTunaryExpression.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTunaryExpression.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTunaryExpression extends SimpleNode { - public ASTunaryExpression(int id) { - super(id); - } ! public ASTunaryExpression(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,20 ---- public class ASTunaryExpression extends SimpleNode { ! String type; ! ! public ASTunaryExpression(int id) { ! super(id); ! } ! ! public ASTunaryExpression(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("unaryexpression: " + type); ! super.compile(context); ! } } Index: ASTloopMod.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTloopMod.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTloopMod.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTloopMod.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTloopMod extends SimpleNode { - public ASTloopMod(int id) { - super(id); - } ! public ASTloopMod(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTloopMod extends SimpleNode { ! String type; ! ! public ASTloopMod(int id) { ! super(id); ! } ! ! public ASTloopMod(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("loopMod: " + type); ! } } Index: ASTrelationalExpression.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTrelationalExpression.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTrelationalExpression.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTrelationalExpression.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 1,12 **** /* Generated By:JJTree: Do not edit this line. ASTrelationalExpression.java */ public class ASTrelationalExpression extends SimpleNode { - public ASTrelationalExpression(int id) { - super(id); - } ! public ASTrelationalExpression(SLCompiler p, int id) { ! super(p, id); ! } } --- 1,29 ---- /* Generated By:JJTree: Do not edit this line. ASTrelationalExpression.java */ + import java.util.*; + public class ASTrelationalExpression extends SimpleNode { ! List ops = new ArrayList(); ! ! public ASTrelationalExpression(int id) { ! super(id); ! } ! ! public ASTrelationalExpression(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void add(String op) { ! ops.add(op); ! } ! ! public void compile(CompilerContext context) { ! System.out.print("relationalExpression:"); ! for (Iterator iter = ops.iterator(); iter.hasNext(); ) ! System.out.print(" " + iter.next()); ! System.out.println(); ! super.compile(context); ! } } Index: ASTmultiplicativeExpression.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTmultiplicativeExpression.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTmultiplicativeExpression.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTmultiplicativeExpression.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 1,12 **** /* Generated By:JJTree: Do not edit this line. ASTmultiplicativeExpression.java */ public class ASTmultiplicativeExpression extends SimpleNode { - public ASTmultiplicativeExpression(int id) { - super(id); - } ! public ASTmultiplicativeExpression(SLCompiler p, int id) { ! super(p, id); ! } } --- 1,29 ---- /* Generated By:JJTree: Do not edit this line. ASTmultiplicativeExpression.java */ + import java.util.*; + public class ASTmultiplicativeExpression extends SimpleNode { ! List ops = new ArrayList(); ! ! public ASTmultiplicativeExpression(int id) { ! super(id); ! } ! ! public ASTmultiplicativeExpression(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void add(String op) { ! ops.add(op); ! } ! ! public void compile(CompilerContext context) { ! System.out.print("multiplicativeExpression:"); ! for (Iterator iter = ops.iterator(); iter.hasNext(); ) ! System.out.print(" " + iter.next()); ! System.out.println(); ! super.compile(context); ! } } Index: ASTadditiveExpression.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTadditiveExpression.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTadditiveExpression.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTadditiveExpression.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 1,12 **** /* Generated By:JJTree: Do not edit this line. ASTadditiveExpression.java */ public class ASTadditiveExpression extends SimpleNode { - public ASTadditiveExpression(int id) { - super(id); - } ! public ASTadditiveExpression(SLCompiler p, int id) { ! super(p, id); ! } } --- 1,29 ---- /* Generated By:JJTree: Do not edit this line. ASTadditiveExpression.java */ + import java.util.*; + public class ASTadditiveExpression extends SimpleNode { ! List ops = new ArrayList(); ! ! public ASTadditiveExpression(int id) { ! super(id); ! } ! ! public ASTadditiveExpression(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void add(String op) { ! ops.add(op); ! } ! ! public void compile(CompilerContext context) { ! System.out.print("additiveExpression:"); ! for (Iterator iter = ops.iterator(); iter.hasNext(); ) ! System.out.print(" " + iter.next()); ! System.out.println(); ! super.compile(context); ! } } Index: SLCompiler.jjt =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/SLCompiler.jjt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SLCompiler.jjt 31 Jul 2004 05:43:36 -0000 1.2 --- SLCompiler.jjt 31 Jul 2004 16:08:28 -0000 1.3 *************** *** 287,305 **** void identifier(): ! {} { ! <IDENTIFIER> } void shaderType(): ! {} { ! <LIGHT> | <SURFACE> | <VOLUME> | <DISPLACEMENT> | <IMAGER> } void type(): ! {} { ! <FLOAT> | <STRING> | <COLOR> | <POINT> | <VECTOR> | <NORMAL> | <MATRIX> | <VOID> } --- 287,316 ---- void identifier(): ! { Token t; } { ! t = <IDENTIFIER> { jjtThis.name = t.image; } } void shaderType(): ! { Token t; } { ! t = <LIGHT> { jjtThis.type = t.image; } ! | t = <SURFACE> { jjtThis.type = t.image; } ! | t = <VOLUME> { jjtThis.type = t.image; } ! | t = <DISPLACEMENT> {jjtThis.type = t.image; } ! | t = <IMAGER> { jjtThis.type = t.image; } } void type(): ! { Token t; } { ! t = <FLOAT> { jjtThis.type = t.image; } ! | t = <STRING> { jjtThis.type = t.image; } ! | t = <COLOR> { jjtThis.type = t.image; } ! | t = <POINT> { jjtThis.type = t.image; } ! | t = <VECTOR> { jjtThis.type = t.image; } ! | t = <NORMAL> { jjtThis.type = t.image; } ! | t = <MATRIX> { jjtThis.type = t.image; } ! | t = <VOID> { jjtThis.type = t.image; } } *************** *** 329,335 **** void detail(): ! {} { ! <VARYING> | <UNIFORM> } --- 340,347 ---- void detail(): ! { Token t; } { ! t = <VARYING> { jjtThis.type = t.image; } ! | t = <UNIFORM> { jjtThis.type = t.image; } } *************** *** 380,394 **** void number(): ! {} { ! <INTEGER_LITERAL> ! | ! <FLOATING_POINT_LITERAL> } void stringconstant(): ! {} { ! <STRING_LITERAL> } --- 392,405 ---- void number(): ! { Token t; } { ! t = <INTEGER_LITERAL> { jjtThis.value = t.image; } ! | t = <FLOATING_POINT_LITERAL> { jjtThis.value = t.image; } } void stringconstant(): ! { Token t; } { ! t = <STRING_LITERAL> { jjtThis.value = t.image.substring(1, t.image.length() - 1); } } *************** *** 401,407 **** void textureType(): ! {} { ! <TEXTURE> | <ENVIRONMENT> | <SHADOW> } --- 412,420 ---- void textureType(): ! { Token t; } { ! t = <TEXTURE> { jjtThis.type = t.image; } ! | t = <ENVIRONMENT> { jjtThis.type = t.image; } ! | t = <SHADOW> { jjtThis.type = t.image; } } *************** *** 452,458 **** void asgnop(): ! {} { ! <ASSIGN> | <PLUSASSIGN> | <MINUSASSIGN> | <STARASSIGN> | <SLASHASSIGN> } --- 465,475 ---- void asgnop(): ! { Token t; } { ! t = <ASSIGN> { jjtThis.type = t.image; } ! | t = <PLUSASSIGN> { jjtThis.type = t.image; } ! | t = <MINUSASSIGN> { jjtThis.type = t.image; } ! | t = <STARASSIGN> { jjtThis.type = t.image; } ! | t = <SLASHASSIGN> { jjtThis.type = t.image; } } *************** *** 479,497 **** void typecast(): ! {} { ! <FLOAT> ! | ! <STRING> ! | ! <COLOR> [LOOKAHEAD(2) spacetype()] ! | ! <POINT> [LOOKAHEAD(2) spacetype()] ! | ! <VECTOR> [LOOKAHEAD(2) spacetype()] ! | ! <NORMAL> [LOOKAHEAD(2) spacetype()] ! | ! <MATRIX> [LOOKAHEAD(2) spacetype()] } --- 496,508 ---- void typecast(): ! { Token t; } { ! t = <FLOAT> { jjtThis.type = t.image; } ! | t = <STRING> { jjtThis.type = t.image; } ! | t = <COLOR> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] ! | t = <POINT> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] ! | t = <VECTOR> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] ! | t = <NORMAL> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] ! | t = <MATRIX> { jjtThis.type = t.image; } [LOOKAHEAD(2) spacetype()] } *************** *** 522,564 **** void equalityExpression() : ! {} { ! relationalExpression() (LOOKAHEAD(2) ( "==" | "!=" ) relationalExpression() )* } void relationalExpression() : ! {} { ! additiveExpression() (LOOKAHEAD(2) ( "<" | ">" | "<=" | ">=" ) additiveExpression() )* } void additiveExpression() : ! {} { ! multiplicativeExpression() (LOOKAHEAD(2) ( "+" | "-" ) multiplicativeExpression() )* } void multiplicativeExpression() : ! {} { ! unaryExpression() (LOOKAHEAD(2) ( "." | "*" | "/" | "^" ) unaryExpression() )* } void unaryExpression() : ! {} { ! ( "+" | "-" ) unaryExpression() ! | ! unaryExpressionNotPlusMinus() } void unaryExpressionNotPlusMinus() : ! {} { ! "!" unaryExpression() ! | ! castExpression() ! | ! primary() } --- 533,582 ---- void equalityExpression() : ! { Token t; } { ! relationalExpression() ! (LOOKAHEAD(2) ( t = "==" | t = "!=" ) relationalExpression() { jjtThis.add(t.image); })* } void relationalExpression() : ! { Token t; } { ! additiveExpression() ! (LOOKAHEAD(2) ( t = "<" ! | t = ">" ! | t = "<=" ! | t = ">=" ) additiveExpression() { jjtThis.add(t.image); })* } void additiveExpression() : ! { Token t; } { ! multiplicativeExpression() ! (LOOKAHEAD(2) ( t = "+" | t = "-" ) multiplicativeExpression() { jjtThis.add(t.image); })* } void multiplicativeExpression() : ! { Token t; } { ! unaryExpression() ! (LOOKAHEAD(2) ( t = "." ! | t = "*" ! | t = "/" ! | t = "^" ) unaryExpression() { jjtThis.add(t.image); })* } void unaryExpression() : ! { Token t; } { ! ( t = "+" | t = "-" ) unaryExpression() { jjtThis.type = t.image; } ! | unaryExpressionNotPlusMinus() } void unaryExpressionNotPlusMinus() : ! { Token t; } { ! t = "!" unaryExpression() { jjtThis.type = t.image; } ! | castExpression() ! | primary() } *************** *** 573,602 **** { block() ! | ! LOOKAHEAD(2) assignexpression() ";" ! | ! variableDefinitions() ";" ! | ! procedurecall() ";" ! | ! <RETURN> expression() ";" ! | ! loopModStmt() ! | ! ifStatement() ! | ! loopControl() } void loopModStmt(): ! {} { ! loopMod() [<INTEGER_LITERAL>] } void loopMod(): ! {} { ! <BREAK>|<CONTINUE> } --- 591,614 ---- { block() ! | LOOKAHEAD(2) assignexpression() ";" ! | variableDefinitions() ";" ! | procedurecall() ";" ! | <RETURN> expression() ";" { jjtThis.isReturn = true; } ! | loopModStmt() ! | ifStatement() ! | loopControl() } void loopModStmt(): ! { Token t; } { ! loopMod() [t = <INTEGER_LITERAL> { jjtThis.number = t.image; }] } void loopMod(): ! { Token t; } { ! t = <BREAK> { jjtThis.type = t.image; } ! | t = <CONTINUE> { jjtThis.type = t.image; } } *************** *** 617,628 **** { whileStatement() ! | ! forStatement() ! | ! solarStatement() ! | ! illuminateStatement() ! | ! illuminanceStatement() } --- 629,636 ---- { whileStatement() ! | forStatement() ! | solarStatement() ! | illuminateStatement() ! | illuminanceStatement() } *************** *** 697,703 **** {} { ! LOOKAHEAD(3) formals() ! | ! statement() } --- 705,710 ---- {} { ! LOOKAHEAD(3) formals() ! | statement() } Index: ASTnumber.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTnumber.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTnumber.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTnumber.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTnumber extends SimpleNode { - public ASTnumber(int id) { - super(id); - } ! public ASTnumber(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTnumber extends SimpleNode { ! String value; ! ! public ASTnumber(int id) { ! super(id); ! } ! ! public ASTnumber(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("number: " + value); ! } } Index: ASTtypecast.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTtypecast.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTtypecast.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTtypecast.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTtypecast extends SimpleNode { - public ASTtypecast(int id) { - super(id); - } ! public ASTtypecast(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTtypecast extends SimpleNode { ! String type; ! ! public ASTtypecast(int id) { ! super(id); ! } ! ! public ASTtypecast(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("typecast: " + type); ! } } Index: ASTtextureType.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTtextureType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTtextureType.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTtextureType.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTtextureType extends SimpleNode { - public ASTtextureType(int id) { - super(id); - } ! public ASTtextureType(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTtextureType extends SimpleNode { ! String type; ! ! public ASTtextureType(int id) { ! super(id); ! } ! ! public ASTtextureType(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("texturetype: " + type); ! } } Index: ASTidentifier.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTidentifier.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTidentifier.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTidentifier.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTidentifier extends SimpleNode { - public ASTidentifier(int id) { - super(id); - } ! public ASTidentifier(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTidentifier extends SimpleNode { ! String name; ! ! public ASTidentifier(int id) { ! super(id); ! } ! ! public ASTidentifier(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("identifier: " + name); ! } } Index: ASTtype.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTtype.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTtype.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTtype.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTtype extends SimpleNode { - public ASTtype(int id) { - super(id); - } ! public ASTtype(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTtype extends SimpleNode { ! String type; ! ! public ASTtype(int id) { ! super(id); ! } ! ! public ASTtype(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("type: " + type); ! } } Index: ASTunaryExpressionNotPlusMinus.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTunaryExpressionNotPlusMinus.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTunaryExpressionNotPlusMinus.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTunaryExpressionNotPlusMinus.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTunaryExpressionNotPlusMinus extends SimpleNode { - public ASTunaryExpressionNotPlusMinus(int id) { - super(id); - } ! public ASTunaryExpressionNotPlusMinus(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,20 ---- public class ASTunaryExpressionNotPlusMinus extends SimpleNode { ! String type; ! ! public ASTunaryExpressionNotPlusMinus(int id) { ! super(id); ! } ! ! public ASTunaryExpressionNotPlusMinus(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("unaryExpressionNotPlusMinus: " + type); ! super.compile(context); ! } } Index: ASTdetail.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTdetail.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTdetail.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTdetail.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTdetail extends SimpleNode { - public ASTdetail(int id) { - super(id); - } ! public ASTdetail(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTdetail extends SimpleNode { ! String type; ! ! public ASTdetail(int id) { ! super(id); ! } ! ! public ASTdetail(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("detail: " + type); ! } } --- NEW FILE: bld --- rm build/*.class jjtree SLCompiler.jjt javacc SLCompiler.jj javac -d build *.java Index: ASTasgnop.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTasgnop.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTasgnop.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTasgnop.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTasgnop extends SimpleNode { - public ASTasgnop(int id) { - super(id); - } ! public ASTasgnop(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,19 ---- public class ASTasgnop extends SimpleNode { ! String type; ! ! public ASTasgnop(int id) { ! super(id); ! } ! ! public ASTasgnop(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("asgnop: " + type); ! } } Index: ASTloopModStmt.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTloopModStmt.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTloopModStmt.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTloopModStmt.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 2,12 **** public class ASTloopModStmt extends SimpleNode { - public ASTloopModStmt(int id) { - super(id); - } ! public ASTloopModStmt(SLCompiler p, int id) { ! super(p, id); ! } } --- 2,20 ---- public class ASTloopModStmt extends SimpleNode { ! String number; ! ! public ASTloopModStmt(int id) { ! super(id); ! } ! ! public ASTloopModStmt(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void compile(CompilerContext context) { ! System.out.println("looModStmt: " + number); ! super.compile(context); ! } } Index: ASTequalityExpression.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/ASTequalityExpression.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTequalityExpression.java 31 Jul 2004 05:23:48 -0000 1.1 --- ASTequalityExpression.java 31 Jul 2004 16:08:28 -0000 1.2 *************** *** 1,12 **** /* Generated By:JJTree: Do not edit this line. ASTequalityExpression.java */ public class ASTequalityExpression extends SimpleNode { - public ASTequalityExpression(int id) { - super(id); - } ! public ASTequalityExpression(SLCompiler p, int id) { ! super(p, id); ! } } --- 1,29 ---- /* Generated By:JJTree: Do not edit this line. ASTequalityExpression.java */ + import java.util.*; + public class ASTequalityExpression extends SimpleNode { ! List ops = new ArrayList(); ! ! public ASTequalityExpression(int id) { ! super(id); ! } ! ! public ASTequalityExpression(SLCompiler p, int id) { ! super(p, id); ! } ! ! public void add(String op) { ! ops.add(op); ! } ! ! public void compile(CompilerContext context) { ! System.out.print("equalityExpression:"); ! for (Iterator iter = ops.iterator(); iter.hasNext(); ) ! System.out.print(" " + iter.next()); ! System.out.println(); ! super.compile(context); ! } } |
From: Gerardo H. <ma...@us...> - 2004-07-31 16:08:37
|
Update of /cvsroot/jrman/drafts/slcomp/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13066/shaders Added Files: constant.sl matte.sl metal.sl plastic.sl Log Message: Added test shaders. Stored extra parse info in AST nodes. --- NEW FILE: metal.sl --- surface metal( float Ka = 1; float Kd = 1; float roughness = .1;) { normal Nf = faceforward(normalize(N), I); vector V = -normalize(I); Oi = Os; Ci = Os * Cs * (Ka * ambient() + Ks * specular(Nf, V, roughness)); } --- NEW FILE: constant.sl --- surface constant() { Oi = Os; Ci = Os * Cs; } --- NEW FILE: matte.sl --- surface matte( float Ka = 1; float Kd = 1;) { normal Nf = faceforward(normalize(N), I); Oi = Os; Ci = Os * Cs * (Ka * ambient() + Kd * diffuse(Nf)); } --- NEW FILE: plastic.sl --- surface plastic( float Ka = 1; float Kd = .5; float Ks = .5; float roughness = .1; color specularcolor = 1;) { normal Nf = faceforward(normalize(N), I); vector V = -normalize(I); Oi = Os; Ci = Os * (Cs * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness)); } |
From: Gerardo H. <ma...@us...> - 2004-07-31 14:32:53
|
Update of /cvsroot/jrman/drafts/slcomp/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31523/shaders Log Message: Directory /cvsroot/jrman/drafts/slcomp/shaders added to the repository |
From: Gerardo H. <ma...@us...> - 2004-07-31 05:43:45
|
Update of /cvsroot/jrman/drafts/slcomp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28338 Modified Files: SLCompiler.java SLCompiler.jjt SimpleNode.java Added Files: CompilerContext.java Log Message: Prepared for compilation. Index: SLCompiler.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/SLCompiler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompiler.java 31 Jul 2004 05:23:48 -0000 1.1 --- SLCompiler.java 31 Jul 2004 05:43:36 -0000 1.2 *************** *** 21,25 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } --- 21,25 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).compile(new CompilerContext()); } Index: SimpleNode.java =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/SimpleNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SimpleNode.java 31 Jul 2004 05:23:48 -0000 1.1 --- SimpleNode.java 31 Jul 2004 05:43:36 -0000 1.2 *************** *** 67,70 **** --- 67,84 ---- } } + + public void compile(CompilerContext context) { + System.out.println("Start: " + toString()); + if (children != null) { + for (int i = 0; i < children.length; ++i) { + SimpleNode n = (SimpleNode)children[i]; + if (n != null) { + n.compile(context); + } + } + } + System.out.println("End: " + toString()); + } + } Index: SLCompiler.jjt =================================================================== RCS file: /cvsroot/jrman/drafts/slcomp/SLCompiler.jjt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLCompiler.jjt 31 Jul 2004 05:23:48 -0000 1.1 --- SLCompiler.jjt 31 Jul 2004 05:43:36 -0000 1.2 *************** *** 1,4 **** /* ! SLCompiler.jj Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez --- 1,4 ---- /* ! SLCompiler.jjt Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez *************** *** 48,52 **** SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } --- 48,52 ---- SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ! ((SimpleNode) compiler.jjtree.rootNode()).compile(new CompilerContext()); } --- NEW FILE: CompilerContext.java --- /* CompilerContext.java Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ public class CompilerContext { } |
Update of /cvsroot/jrman/drafts/slcomp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26625 Added Files: ASTadditiveExpression.java ASTarrayindex.java ASTasgnop.java ASTassignexpression.java ASTblock.java ASTblockStatement.java ASTbooleanExpression.java ASTcastExpression.java ASTchannel.java ASTcompilationUnit.java ASTconditionalAndExpression.java ASTconditionalExpression.java ASTconditionalOrExpression.java ASTdefExpression.java ASTdefExpressions.java ASTdefInit.java ASTdefinitions.java ASTdetail.java ASTequalityExpression.java ASTexpression.java ASTexpressionList.java ASTexternspec.java ASTforInit.java ASTforStatement.java ASTforUpdate.java ASTformalVariableDefinitions.java ASTformals.java ASTfunctionDefinition.java ASTidentifier.java ASTifStatement.java ASTilluminanceStatement.java ASTilluminateStatement.java ASTloopControl.java ASTloopMod.java ASTloopModStmt.java ASTmultiplicativeExpression.java ASTnumber.java ASToutputspec.java ASTprimary.java ASTprocArguments.java ASTprocedurecall.java ASTrelationalExpression.java ASTshaderDefinition.java ASTshaderType.java ASTsingle.java ASTsixteentuple.java ASTsolarStatement.java ASTspacetype.java ASTstatement.java ASTstringconstant.java ASTtexture.java ASTtextureArguments.java ASTtextureFilename.java ASTtextureType.java ASTtriple.java ASTtype.java ASTtypecast.java ASTtypespec.java ASTunaryExpression.java ASTunaryExpressionNotPlusMinus.java ASTvariableDefinitions.java ASTwhileStatement.java JJTSLCompilerState.java JPP.java JavaCharStream.java Node.java ParseException.java SLCompiler.java SLCompiler.jjt SLCompilerConstants.java SLCompilerTokenManager.java SLCompilerTreeConstants.java SimpleNode.java Token.java TokenMgrError.java Log Message: Started work on SL compiler. --- NEW FILE: ASTexpression.java --- /* Generated By:JJTree: Do not edit this line. ASTexpression.java */ public class ASTexpression extends SimpleNode { public ASTexpression(int id) { super(id); } public ASTexpression(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTprocArguments.java --- /* Generated By:JJTree: Do not edit this line. ASTprocArguments.java */ public class ASTprocArguments extends SimpleNode { public ASTprocArguments(int id) { super(id); } public ASTprocArguments(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: TokenMgrError.java --- /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * An attempt wass made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their espaced (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexicl error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn : column number when the error occured * errorAfter : prefix that was seen before this error occured * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ public TokenMgrError() { } public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } --- NEW FILE: SLCompiler.java --- /* Generated By:JJTree&JavaCC: Do not edit this line. SLCompiler.java */ import java.io.FileInputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class SLCompiler/*@bgen(jjtree)*/implements SLCompilerTreeConstants, SLCompilerConstants {/*@bgen(jjtree)*/ protected JJTSLCompilerState jjtree = new JJTSLCompilerState(); public static void main(String args[]) throws ParseException, IOException { InputStream in; if (args.length == 0) in = System.in; else in = new FileInputStream(args[0]); ByteArrayOutputStream out = new ByteArrayOutputStream(); JPP jpp = new JPP(in, out, new java.util.Vector(), new java.util.Hashtable()); jpp.preprocess(); [...3828 lines suppressed...] jj_rescan = false; } final private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { int gen; Token first; int arg; JJCalls next; } } --- NEW FILE: ASTtexture.java --- /* Generated By:JJTree: Do not edit this line. ASTtexture.java */ public class ASTtexture extends SimpleNode { public ASTtexture(int id) { super(id); } public ASTtexture(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTbooleanExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTbooleanExpression.java */ public class ASTbooleanExpression extends SimpleNode { public ASTbooleanExpression(int id) { super(id); } public ASTbooleanExpression(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTtypespec.java --- /* Generated By:JJTree: Do not edit this line. ASTtypespec.java */ public class ASTtypespec extends SimpleNode { public ASTtypespec(int id) { super(id); } public ASTtypespec(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTunaryExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTunaryExpression.java */ public class ASTunaryExpression extends SimpleNode { public ASTunaryExpression(int id) { super(id); } public ASTunaryExpression(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: SLCompilerConstants.java --- /* Generated By:JJTree&JavaCC: Do not edit this line. SLCompilerConstants.java */ public interface SLCompilerConstants { int EOF = 0; int SINGLE_LINE_COMMENT = 8; int MULTI_LINE_COMMENT = 9; int LIGHT = 11; int SURFACE = 12; int VOLUME = 13; int DISPLACEMENT = 14; int IMAGER = 15; int FLOAT = 16; int STRING = 17; int COLOR = 18; int POINT = 19; int VECTOR = 20; int NORMAL = 21; int MATRIX = 22; int VOID = 23; int OUTPUT = 24; int VARYING = 25; int UNIFORM = 26; int TEXTURE = 27; int ENVIRONMENT = 28; int SHADOW = 29; int RETURN = 30; int EXTERN = 31; int BREAK = 32; int CONTINUE = 33; int IF = 34; int ELSE = 35; int WHILE = 36; int FOR = 37; int SOLAR = 38; int ILLUMINATE = 39; int ILLUMINANCE = 40; int INTEGER_LITERAL = 41; int DECIMAL_LITERAL = 42; int HEX_LITERAL = 43; int OCTAL_LITERAL = 44; int FLOATING_POINT_LITERAL = 45; int EXPONENT = 46; int CHARACTER_LITERAL = 47; int STRING_LITERAL = 48; int IDENTIFIER = 49; int LETTER = 50; int DIGIT = 51; int LPAREN = 52; int RPAREN = 53; int LBRACE = 54; int RBRACE = 55; int LBRACKET = 56; int RBRACKET = 57; int SEMICOLON = 58; int COMMA = 59; int PLUS = 60; int MINUS = 61; int STAR = 62; int SLASH = 63; int EXP = 64; int BANG = 65; int ASSIGN = 66; int HOOK = 67; int PLUSASSIGN = 68; int MINUSASSIGN = 69; int STARASSIGN = 70; int SLASHASSIGN = 71; int COLON = 72; int DOT = 73; int DEFAULT = 0; int IN_SINGLE_LINE_COMMENT = 1; int IN_MULTI_LINE_COMMENT = 2; String[] tokenImage = { "<EOF>", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", "\"\\f\"", "\"//\"", "\"/*\"", "<SINGLE_LINE_COMMENT>", "\"*/\"", "<token of kind 10>", "\"light\"", "\"surface\"", "\"volume\"", "\"displacement\"", "\"imager\"", "\"float\"", "\"string\"", "\"color\"", "\"point\"", "\"vector\"", "\"normal\"", "\"matrix\"", "\"void\"", "\"output\"", "\"varying\"", "\"uniform\"", "\"texture\"", "\"environment\"", "\"shadow\"", "\"return\"", "\"extern\"", "\"break\"", "\"continue\"", "\"if\"", "\"else\"", "\"while\"", "\"for\"", "\"solar\"", "\"illuminate\"", "\"illuminance\"", "<INTEGER_LITERAL>", "<DECIMAL_LITERAL>", "<HEX_LITERAL>", "<OCTAL_LITERAL>", "<FLOATING_POINT_LITERAL>", "<EXPONENT>", "<CHARACTER_LITERAL>", "<STRING_LITERAL>", "<IDENTIFIER>", "<LETTER>", "<DIGIT>", "\"(\"", "\")\"", "\"{\"", "\"}\"", "\"[\"", "\"]\"", "\";\"", "\",\"", "\"+\"", "\"-\"", "\"*\"", "\"/\"", "\"^\"", "\"!\"", "\"=\"", "\"?\"", "\"+=\"", "\"-=\"", "\"*=\"", "\"/=\"", "\":\"", "\".\"", "\"||\"", "\"&&\"", "\"==\"", "\"!=\"", "\"<\"", "\">\"", "\"<=\"", "\">=\"", }; } --- NEW FILE: ASTsolarStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTsolarStatement.java */ public class ASTsolarStatement extends SimpleNode { public ASTsolarStatement(int id) { super(id); } public ASTsolarStatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTvariableDefinitions.java --- /* Generated By:JJTree: Do not edit this line. ASTvariableDefinitions.java */ public class ASTvariableDefinitions extends SimpleNode { public ASTvariableDefinitions(int id) { super(id); } public ASTvariableDefinitions(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTformalVariableDefinitions.java --- /* Generated By:JJTree: Do not edit this line. ASTformalVariableDefinitions.java */ public class ASTformalVariableDefinitions extends SimpleNode { public ASTformalVariableDefinitions(int id) { super(id); } public ASTformalVariableDefinitions(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTcompilationUnit.java --- /* Generated By:JJTree: Do not edit this line. ASTcompilationUnit.java */ public class ASTcompilationUnit extends SimpleNode { public ASTcompilationUnit(int id) { super(id); } public ASTcompilationUnit(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: SLCompiler.jjt --- /* SLCompiler.jj Copyright (C) 2004 Elmer Garduno Hernandez, Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ options { STATIC = false; MULTI = true; LOOKAHEAD = 1; JAVA_UNICODE_ESCAPE = true; } PARSER_BEGIN(SLCompiler) import java.io.FileInputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class SLCompiler { public static void main(String args[]) throws ParseException, IOException { InputStream in; if (args.length == 0) in = System.in; else in = new FileInputStream(args[0]); ByteArrayOutputStream out = new ByteArrayOutputStream(); JPP jpp = new JPP(in, out, new java.util.Vector(), new java.util.Hashtable()); jpp.preprocess(); SLCompiler compiler = new SLCompiler(new ByteArrayInputStream(out.toByteArray())); compiler.compilationUnit(); ((SimpleNode) compiler.jjtree.rootNode()).dump(" "); } } PARSER_END(SLCompiler) /* WHITE SPACE */ SKIP : { " " | "\t" | "\n" | "\r" | "\f" } /* COMMENTS */ MORE : { "//" : IN_SINGLE_LINE_COMMENT | "/*" : IN_MULTI_LINE_COMMENT } <IN_SINGLE_LINE_COMMENT> SPECIAL_TOKEN : { <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT } <IN_MULTI_LINE_COMMENT> SPECIAL_TOKEN : { <MULTI_LINE_COMMENT: "*/" > : DEFAULT } <IN_SINGLE_LINE_COMMENT,IN_MULTI_LINE_COMMENT> MORE : { < ~[] > } /* RESERVED WORDS AND LITERALS */ TOKEN : { < LIGHT: "light" > | < SURFACE: "surface" > | < VOLUME: "volume" > | < DISPLACEMENT: "displacement" > | < IMAGER: "imager" > | < FLOAT: "float" > | < STRING: "string" > | < COLOR: "color" > | < POINT: "point" > | < VECTOR: "vector" > | < NORMAL: "normal" > | < MATRIX: "matrix" > | < VOID: "void" > | < OUTPUT: "output" > | < VARYING: "varying" > | < UNIFORM: "uniform" > | < TEXTURE: "texture" > | < ENVIRONMENT: "environment" > | < SHADOW: "shadow" > | < RETURN: "return" > | < EXTERN: "extern" > | < BREAK: "break" > | < CONTINUE: "continue" > | < IF: "if" > | < ELSE: "else" > | < WHILE: "while" > | < FOR: "for" > | < SOLAR: "solar" > | < ILLUMINATE: "illuminate" > | < ILLUMINANCE: "illuminance" > } /* LITERALS */ TOKEN : { < INTEGER_LITERAL: <DECIMAL_LITERAL> (["l","L"])? | <HEX_LITERAL> (["l","L"])? | <OCTAL_LITERAL> (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > | < FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])? | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])? | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])? | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"] > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < CHARACTER_LITERAL: "'" ( (~["'","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\""] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) ) "'" > | < STRING_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | ("\\" ( ["n","t","b","r","f","\\","'","\""] | ["0"-"7"] ( ["0"-"7"] )? | ["0"-"3"] ["0"-"7"] ["0"-"7"] ) ) )* "\"" > } /* IDENTIFIERS */ TOKEN : { < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* > | < #LETTER: [ "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "\u0030"-"\u0039", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > } /* SEPARATORS */ TOKEN : { < LPAREN: "(" > | < RPAREN: ")" > | < LBRACE: "{" > | < RBRACE: "}" > | < LBRACKET: "[" > | < RBRACKET: "]" > | < SEMICOLON: ";" > | < COMMA: "," > } /* OPERATORS */ TOKEN : { < PLUS: "+" > | < MINUS: "-" > | < STAR: "*" > | < SLASH: "/" > | < EXP: "^" > | < BANG: "!" > | < ASSIGN: "=" > | < HOOK: "?" > | < PLUSASSIGN: "+=" > | < MINUSASSIGN: "-=" > | < STARASSIGN: "*=" > | < SLASHASSIGN: "/=" > | < COLON: ":" > | < DOT: "." > } void compilationUnit(): {} { definitions() <EOF> } void definitions(): {} { (shaderDefinition() | functionDefinition())+ } void shaderDefinition(): {} { shaderType() identifier() "("[formals()]")" block() } void functionDefinition(): {} { [type()] identifier() "("[formals()]")" block() } void identifier(): {} { <IDENTIFIER> } void shaderType(): {} { <LIGHT> | <SURFACE> | <VOLUME> | <DISPLACEMENT> | <IMAGER> } void type(): {} { <FLOAT> | <STRING> | <COLOR> | <POINT> | <VECTOR> | <NORMAL> | <MATRIX> | <VOID> } void formals(): {} { formalVariableDefinitions() [";"] (LOOKAHEAD(2) formalVariableDefinitions() ";")* } void formalVariableDefinitions(): {} { [outputspec()] typespec() defExpressions() } void outputspec(): {} { <OUTPUT> } void typespec(): {} { [detail()] type() } void detail(): {} { <VARYING> | <UNIFORM> } void defExpressions(): {} { defExpression() ("," defExpression() )* } void defExpression(): {} { identifier() [defInit()] } void defInit(): {} { "=" expression() } void expression(): {} { LOOKAHEAD(3) conditionalExpression() | primary() } void primary(): {} { number() | stringconstant() | texture() | LOOKAHEAD(2) procedurecall() | LOOKAHEAD(2) identifier() [LOOKAHEAD(2) arrayindex()] [asgnop() expression()] //assignExpression(), identifier() | single() //triple(), sixteentuple() } void number(): {} { <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> } void stringconstant(): {} { <STRING_LITERAL> } void texture(): {} { textureType() "(" textureFilename() [channel()] [textureArguments()] ")" } void textureType(): {} { <TEXTURE> | <ENVIRONMENT> | <SHADOW> } void textureFilename(): {} { expression() } void channel(): {} { "[" expression() "]" } void textureArguments(): {} { "," expression() ("," expression() )* } void arrayindex(): {} { "["expression()"]" } void procedurecall(): {} { identifier() "(" [procArguments()] ")" } void procArguments(): {} { expression() ("," expression() )* } void assignexpression(): {} { identifier() [arrayindex()] asgnop() expression() } void asgnop(): {} { <ASSIGN> | <PLUSASSIGN> | <MINUSASSIGN> | <STARASSIGN> | <SLASHASSIGN> } void single(): {} { "("expression() [triple()]")" } void triple(): {} { ","expression()","expression() [sixteentuple()] } void sixteentuple(): {} { ","expression() ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() } void typecast(): {} { <FLOAT> | <STRING> | <COLOR> [LOOKAHEAD(2) spacetype()] | <POINT> [LOOKAHEAD(2) spacetype()] | <VECTOR> [LOOKAHEAD(2) spacetype()] | <NORMAL> [LOOKAHEAD(2) spacetype()] | <MATRIX> [LOOKAHEAD(2) spacetype()] } void spacetype(): {} { stringconstant() } void conditionalExpression() : {} { conditionalOrExpression() [LOOKAHEAD(2) "?" expression() ":" conditionalExpression() ] } void conditionalOrExpression() : {} { conditionalAndExpression() (LOOKAHEAD(2) "||" conditionalAndExpression() )* } void conditionalAndExpression() : {} { equalityExpression() (LOOKAHEAD(2) "&&" equalityExpression() )* } void equalityExpression() : {} { relationalExpression() (LOOKAHEAD(2) ( "==" | "!=" ) relationalExpression() )* } void relationalExpression() : {} { additiveExpression() (LOOKAHEAD(2) ( "<" | ">" | "<=" | ">=" ) additiveExpression() )* } void additiveExpression() : {} { multiplicativeExpression() (LOOKAHEAD(2) ( "+" | "-" ) multiplicativeExpression() )* } void multiplicativeExpression() : {} { unaryExpression() (LOOKAHEAD(2) ( "." | "*" | "/" | "^" ) unaryExpression() )* } void unaryExpression() : {} { ( "+" | "-" ) unaryExpression() | unaryExpressionNotPlusMinus() } void unaryExpressionNotPlusMinus() : {} { "!" unaryExpression() | castExpression() | primary() } void castExpression() : {} { typecast() unaryExpression() } void statement(): {} { block() | LOOKAHEAD(2) assignexpression() ";" | variableDefinitions() ";" | procedurecall() ";" | <RETURN> expression() ";" | loopModStmt() | ifStatement() | loopControl() } void loopModStmt(): {} { loopMod() [<INTEGER_LITERAL>] } void loopMod(): {} { <BREAK>|<CONTINUE> } void ifStatement(): {} { <IF> "(" booleanExpression() ")" statement() [ LOOKAHEAD(2) <ELSE> statement() ] } void booleanExpression(): {} { expression() } void loopControl(): {} { whileStatement() | forStatement() | solarStatement() | illuminateStatement() | illuminanceStatement() } void whileStatement(): {} { <WHILE> "(" booleanExpression() ")" statement() } void forStatement(): {} { <FOR> "(" forInit() ";" booleanExpression() ";" forUpdate() ")" statement() } void forInit(): {} { expression() } void forUpdate(): {} { expression() } void solarStatement(): {} { <SOLAR> "(" [expressionList()] ")" statement() } void illuminateStatement(): {} { <ILLUMINATE> "(" [expressionList()] ")" statement() } void illuminanceStatement(): {} { <ILLUMINANCE> "(" [expressionList()] ")" statement() } void expressionList(): {} { expression() ("," expression())* } void variableDefinitions(): {} { [externspec()] typespec() defExpressions() } void externspec(): {} { <EXTERN> } void block() : {} { "{" ( blockStatement() )* "}" } void blockStatement() : {} { LOOKAHEAD(3) formals() | statement() } --- NEW FILE: ASTtextureArguments.java --- /* Generated By:JJTree: Do not edit this line. ASTtextureArguments.java */ public class ASTtextureArguments extends SimpleNode { public ASTtextureArguments(int id) { super(id); } public ASTtextureArguments(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTmultiplicativeExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTmultiplicativeExpression.java */ public class ASTmultiplicativeExpression extends SimpleNode { public ASTmultiplicativeExpression(int id) { super(id); } public ASTmultiplicativeExpression(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTshaderDefinition.java --- /* Generated By:JJTree: Do not edit this line. ASTshaderDefinition.java */ public class ASTshaderDefinition extends SimpleNode { public ASTshaderDefinition(int id) { super(id); } public ASTshaderDefinition(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTnumber.java --- /* Generated By:JJTree: Do not edit this line. ASTnumber.java */ public class ASTnumber extends SimpleNode { public ASTnumber(int id) { super(id); } public ASTnumber(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTtextureFilename.java --- /* Generated By:JJTree: Do not edit this line. ASTtextureFilename.java */ public class ASTtextureFilename extends SimpleNode { public ASTtextureFilename(int id) { super(id); } public ASTtextureFilename(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTdefInit.java --- /* Generated By:JJTree: Do not edit this line. ASTdefInit.java */ public class ASTdefInit extends SimpleNode { public ASTdefInit(int id) { super(id); } public ASTdefInit(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTtypecast.java --- /* Generated By:JJTree: Do not edit this line. ASTtypecast.java */ public class ASTtypecast extends SimpleNode { public ASTtypecast(int id) { super(id); } public ASTtypecast(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTchannel.java --- /* Generated By:JJTree: Do not edit this line. ASTchannel.java */ public class ASTchannel extends SimpleNode { public ASTchannel(int id) { super(id); } public ASTchannel(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTtextureType.java --- /* Generated By:JJTree: Do not edit this line. ASTtextureType.java */ public class ASTtextureType extends SimpleNode { public ASTtextureType(int id) { super(id); } public ASTtextureType(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTdefExpressions.java --- /* Generated By:JJTree: Do not edit this line. ASTdefExpressions.java */ public class ASTdefExpressions extends SimpleNode { public ASTdefExpressions(int id) { super(id); } public ASTdefExpressions(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTwhileStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTwhileStatement.java */ public class ASTwhileStatement extends SimpleNode { public ASTwhileStatement(int id) { super(id); } public ASTwhileStatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTstringconstant.java --- /* Generated By:JJTree: Do not edit this line. ASTstringconstant.java */ public class ASTstringconstant extends SimpleNode { public ASTstringconstant(int id) { super(id); } public ASTstringconstant(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: JavaCharStream.java --- /* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 3.0 */ /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (with java-like unicode escape processing). */ public class JavaCharStream { public static final boolean staticFlag = false; static final int hexval(char c) throws java.io.IOException { switch(c) { case '0' : return 0; case '1' : return 1; case '2' : return 2; case '3' : return 3; case '4' : return 4; case '5' : return 5; case '6' : return 6; case '7' : return 7; case '8' : return 8; case '9' : return 9; case 'a' : case 'A' : return 10; case 'b' : case 'B' : return 11; case 'c' : case 'C' : return 12; case 'd' : case 'D' : return 13; case 'e' : case 'E' : return 14; case 'f' : case 'F' : return 15; } throw new java.io.IOException(); // Should never come here } public int bufpos = -1; int bufsize; int available; int tokenBegin; protected int bufline[]; protected int bufcolumn[]; protected int column = 0; protected int line = 1; protected boolean prevCharIsCR = false; protected boolean prevCharIsLF = false; protected java.io.Reader inputStream; protected char[] nextCharBuf; protected char[] buffer; protected int maxNextCharInd = 0; protected int nextCharInd = -1; protected int inBuf = 0; protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; bufpos += (bufsize - tokenBegin); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; bufpos -= tokenBegin; } } catch (Throwable t) { throw new Error(t.getMessage()); } available = (bufsize += 2048); tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { int i; if (maxNextCharInd == 4096) maxNextCharInd = nextCharInd = 0; try { if ((i = inputStream.read(nextCharBuf, maxNextCharInd, 4096 - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { if (bufpos != 0) { --bufpos; backup(0); } else { bufline[bufpos] = line; bufcolumn[bufpos] = column; } throw e; } } protected char ReadByte() throws java.io.IOException { if (++nextCharInd >= maxNextCharInd) FillBuff(); return nextCharBuf[nextCharInd]; } public char BeginToken() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; tokenBegin = bufpos; return buffer[bufpos]; } tokenBegin = 0; bufpos = -1; return readChar(); } protected void AdjustBuffSize() { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = 0; available = tokenBegin; } else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (8 - (column & 07)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } char c; if (++bufpos == available) AdjustBuffSize(); if ((buffer[bufpos] = c = ReadByte()) == '\\') { UpdateLineColumn(c); int backSlashCnt = 1; for (;;) // Read all the backslashes { if (++bufpos == available) AdjustBuffSize(); try { if ((buffer[bufpos] = c = ReadByte()) != '\\') { UpdateLineColumn(c); // found a non-backslash char. if ((c == 'u') && ((backSlashCnt & 1) == 1)) { if (--bufpos < 0) bufpos = bufsize - 1; break; } backup(backSlashCnt); return '\\'; } } catch(java.io.IOException e) { if (backSlashCnt > 1) backup(backSlashCnt); return '\\'; } UpdateLineColumn(c); backSlashCnt++; } // Here, we have seen an odd number of backslash's followed by a 'u' try { while ((c = ReadByte()) == 'u') ++column; buffer[bufpos] = c = (char)(hexval(c) << 12 | hexval(ReadByte()) << 8 | hexval(ReadByte()) << 4 | hexval(ReadByte())); column += 4; } catch(java.io.IOException e) { throw new Error("Invalid escape character at line " + line + " column " + column + "."); } if (backSlashCnt == 1) return c; else { backup(backSlashCnt - 1); return '\\'; } } else { UpdateLineColumn(c); return (c); } } /** * @deprecated * @see #getEndColumn */ public int getColumn() { return bufcolumn[bufpos]; } /** * @deprecated * @see #getEndLine */ public int getLine() { return bufline[bufpos]; } public int getEndColumn() { return bufcolumn[bufpos]; } public int getEndLine() { return bufline[bufpos]; } public int getBeginColumn() { return bufcolumn[tokenBegin]; } public int getBeginLine() { return bufline[tokenBegin]; } public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public JavaCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; nextCharInd = bufpos = -1; } public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public JavaCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } public void Done() { nextCharBuf = null; buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } --- NEW FILE: ASTloopControl.java --- /* Generated By:JJTree: Do not edit this line. ASTloopControl.java */ public class ASTloopControl extends SimpleNode { public ASTloopControl(int id) { super(id); } public ASTloopControl(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTdetail.java --- /* Generated By:JJTree: Do not edit this line. ASTdetail.java */ public class ASTdetail extends SimpleNode { public ASTdetail(int id) { super(id); } public ASTdetail(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTdefExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTdefExpression.java */ public class ASTdefExpression extends SimpleNode { public ASTdefExpression(int id) { super(id); } public ASTdefExpression(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: SimpleNode.java --- /* Generated By:JJTree: Do not edit this line. SimpleNode.java */ public class SimpleNode implements Node { protected Node parent; protected Node[] children; protected int id; protected SLCompiler parser; public SimpleNode(int i) { id = i; } public SimpleNode(SLCompiler p, int i) { this(i); parser = p; } public void jjtOpen() { } public void jjtClose() { } public void jjtSetParent(Node n) { parent = n; } public Node jjtGetParent() { return parent; } public void jjtAddChild(Node n, int i) { if (children == null) { children = new Node[i + 1]; } else if (i >= children.length) { Node c[] = new Node[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } children[i] = n; } public Node jjtGetChild(int i) { return children[i]; } public int jjtGetNumChildren() { return (children == null) ? 0 : children.length; } /* You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding toString() is probably all you need to do. */ public String toString() { return SLCompilerTreeConstants.jjtNodeName[id]; } public String toString(String prefix) { return prefix + toString(); } /* Override this method if you want to customize how the node dumps out its children. */ public void dump(String prefix) { System.out.println(toString(prefix)); if (children != null) { for (int i = 0; i < children.length; ++i) { SimpleNode n = (SimpleNode)children[i]; if (n != null) { n.dump(prefix + " "); } } } } } --- NEW FILE: ASTasgnop.java --- /* Generated By:JJTree: Do not edit this line. ASTasgnop.java */ public class ASTasgnop extends SimpleNode { public ASTasgnop(int id) { super(id); } public ASTasgnop(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTblockStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTblockStatement.java */ public class ASTblockStatement extends SimpleNode { public ASTblockStatement(int id) { super(id); } public ASTblockStatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTifStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTifStatement.java */ public class ASTifStatement extends SimpleNode { public ASTifStatement(int id) { super(id); } public ASTifStatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: JJTSLCompilerState.java --- /* Generated By:JJTree: Do not edit this line. JJTSLCompilerState.java */ class JJTSLCompilerState { private java.util.Stack nodes; private java.util.Stack marks; private int sp; // number of nodes on stack private int mk; // current mark private boolean node_created; JJTSLCompilerState() { nodes = new java.util.Stack(); marks = new java.util.Stack(); sp = 0; mk = 0; } /* Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope. */ boolean nodeCreated() { return node_created; } /* Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. */ void reset() { nodes.removeAllElements(); marks.removeAllElements(); sp = 0; mk = 0; } /* Returns the root node of the AST. It only makes sense to call this after a successful parse. */ Node rootNode() { return (Node)nodes.elementAt(0); } /* Pushes a node on to the stack. */ void pushNode(Node n) { nodes.push(n); ++sp; } /* Returns the node on the top of the stack, and remove it from the stack. */ Node popNode() { if (--sp < mk) { mk = ((Integer)marks.pop()).intValue(); } return (Node)nodes.pop(); } /* Returns the node currently on the top of the stack. */ Node peekNode() { return (Node)nodes.peek(); } /* Returns the number of children on the stack in the current node scope. */ int nodeArity() { return sp - mk; } void clearNodeScope(Node n) { while (sp > mk) { popNode(); } mk = ((Integer)marks.pop()).intValue(); } void openNodeScope(Node n) { marks.push(new Integer(mk)); mk = sp; n.jjtOpen(); } /* A definite node is constructed from a specified number of children. That number of nodes are popped from the stack and made the children of the definite node. Then the definite node is pushed on to the stack. */ void closeNodeScope(Node n, int num) { mk = ((Integer)marks.pop()).intValue(); while (num-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, num); } n.jjtClose(); pushNode(n); node_created = true; } /* A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node was opened are made children of the the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack. */ void closeNodeScope(Node n, boolean condition) { if (condition) { int a = nodeArity(); mk = ((Integer)marks.pop()).intValue(); while (a-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, a); } n.jjtClose(); pushNode(n); node_created = true; } else { mk = ((Integer)marks.pop()).intValue(); node_created = false; } } } --- NEW FILE: ASTarrayindex.java --- /* Generated By:JJTree: Do not edit this line. ASTarrayindex.java */ public class ASTarrayindex extends SimpleNode { public ASTarrayindex(int id) { super(id); } public ASTarrayindex(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: SLCompilerTokenManager.java --- /* Generated By:JJTree&JavaCC: Do not edit this line. SLCompilerTokenManager.java */ import java.io.FileInputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class SLCompilerTokenManager implements SLCompilerConstants { public java.io.PrintStream debugStream = System.out; public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { switch (pos) { case 0: if ((active1 & 0x200L) != 0L) return 4; if ((active0 & 0x1fffffff800L) != 0L) [...1435 lines suppressed...] error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } void SkipLexicalActions(Token matchedToken) { switch(jjmatchedKind) { default : break; } } } --- NEW FILE: ASTsixteentuple.java --- /* Generated By:JJTree: Do not edit this line. ASTsixteentuple.java */ public class ASTsixteentuple extends SimpleNode { public ASTsixteentuple(int id) { super(id); } public ASTsixteentuple(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: SLCompilerTreeConstants.java --- /* Generated By:JJTree: Do not edit this line. SLCompilerTreeConstants.java */ public interface SLCompilerTreeConstants { public int JJTCOMPILATIONUNIT = 0; public int JJTDEFINITIONS = 1; public int JJTSHADERDEFINITION = 2; public int JJTFUNCTIONDEFINITION = 3; public int JJTIDENTIFIER = 4; public int JJTSHADERTYPE = 5; public int JJTTYPE = 6; public int JJTFORMALS = 7; public int JJTFORMALVARIABLEDEFINITIONS = 8; public int JJTOUTPUTSPEC = 9; public int JJTTYPESPEC = 10; public int JJTDETAIL = 11; public int JJTDEFEXPRESSIONS = 12; public int JJTDEFEXPRESSION = 13; public int JJTDEFINIT = 14; public int JJTEXPRESSION = 15; public int JJTPRIMARY = 16; public int JJTNUMBER = 17; public int JJTSTRINGCONSTANT = 18; public int JJTTEXTURE = 19; public int JJTTEXTURETYPE = 20; public int JJTTEXTUREFILENAME = 21; public int JJTCHANNEL = 22; public int JJTTEXTUREARGUMENTS = 23; public int JJTARRAYINDEX = 24; public int JJTPROCEDURECALL = 25; public int JJTPROCARGUMENTS = 26; public int JJTASSIGNEXPRESSION = 27; public int JJTASGNOP = 28; public int JJTSINGLE = 29; public int JJTTRIPLE = 30; public int JJTSIXTEENTUPLE = 31; public int JJTTYPECAST = 32; public int JJTSPACETYPE = 33; public int JJTCONDITIONALEXPRESSION = 34; public int JJTCONDITIONALOREXPRESSION = 35; public int JJTCONDITIONALANDEXPRESSION = 36; public int JJTEQUALITYEXPRESSION = 37; public int JJTRELATIONALEXPRESSION = 38; public int JJTADDITIVEEXPRESSION = 39; public int JJTMULTIPLICATIVEEXPRESSION = 40; public int JJTUNARYEXPRESSION = 41; public int JJTUNARYEXPRESSIONNOTPLUSMINUS = 42; public int JJTCASTEXPRESSION = 43; public int JJTSTATEMENT = 44; public int JJTLOOPMODSTMT = 45; public int JJTLOOPMOD = 46; public int JJTIFSTATEMENT = 47; public int JJTBOOLEANEXPRESSION = 48; public int JJTLOOPCONTROL = 49; public int JJTWHILESTATEMENT = 50; public int JJTFORSTATEMENT = 51; public int JJTFORINIT = 52; public int JJTFORUPDATE = 53; public int JJTSOLARSTATEMENT = 54; public int JJTILLUMINATESTATEMENT = 55; public int JJTILLUMINANCESTATEMENT = 56; public int JJTEXPRESSIONLIST = 57; public int JJTVARIABLEDEFINITIONS = 58; public int JJTEXTERNSPEC = 59; public int JJTBLOCK = 60; public int JJTBLOCKSTATEMENT = 61; public String[] jjtNodeName = { "compilationUnit", "definitions", "shaderDefinition", "functionDefinition", "identifier", "shaderType", "type", "formals", "formalVariableDefinitions", "outputspec", "typespec", "detail", "defExpressions", "defExpression", "defInit", "expression", "primary", "number", "stringconstant", "texture", "textureType", "textureFilename", "channel", "textureArguments", "arrayindex", "procedurecall", "procArguments", "assignexpression", "asgnop", "single", "triple", "sixteentuple", "typecast", "spacetype", "conditionalExpression", "conditionalOrExpression", "conditionalAndExpression", "equalityExpression", "relationalExpression", "additiveExpression", "multiplicativeExpression", "unaryExpression", "unaryExpressionNotPlusMinus", "castExpression", "statement", "loopModStmt", "loopMod", "ifStatement", "booleanExpression", "loopControl", "whileStatement", "forStatement", "forInit", "forUpdate", "solarStatement", "illuminateStatement", "illuminanceStatement", "expressionList", "variableDefinitions", "externspec", "block", "blockStatement", }; } --- NEW FILE: ASTstatement.java --- /* Generated By:JJTree: Do not edit this line. ASTstatement.java */ public class ASTstatement extends SimpleNode { public ASTstatement(int id) { super(id); } public ASTstatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTsingle.java --- /* Generated By:JJTree: Do not edit this line. ASTsingle.java */ public class ASTsingle extends SimpleNode { public ASTsingle(int id) { super(id); } public ASTsingle(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTilluminanceStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTilluminanceStatement.java */ public class ASTilluminanceStatement extends SimpleNode { public ASTilluminanceStatement(int id) { super(id); } public ASTilluminanceStatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTexpressionList.java --- /* Generated By:JJTree: Do not edit this line. ASTexpressionList.java */ public class ASTexpressionList extends SimpleNode { public ASTexpressionList(int id) { super(id); } public ASTexpressionList(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTtriple.java --- /* Generated By:JJTree: Do not edit this line. ASTtriple.java */ public class ASTtriple extends SimpleNode { public ASTtriple(int id) { super(id); } public ASTtriple(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTilluminateStatement.java --- /* Generated By:JJTree: Do not edit this line. ASTilluminateStatement.java */ public class ASTilluminateStatement extends SimpleNode { public ASTilluminateStatement(int id) { super(id); } public ASTilluminateStatement(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTconditionalOrExpression.java --- /* Generated By:JJTree: Do not edit this line. ASTconditionalOrExpression.java */ public class ASTconditionalOrExpression extends SimpleNode { public ASTconditionalOrExpression(int id) { super(id); } public ASTconditionalOrExpression(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTshaderType.java --- /* Generated By:JJTree: Do not edit this line. ASTshaderType.java */ public class ASTshaderType extends SimpleNode { public ASTshaderType(int id) { super(id); } public ASTshaderType(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ASTprimary.java --- /* Generated By:JJTree: Do not edit this line. ASTprimary.java */ public class ASTprimary extends SimpleNode { public ASTprimary(int id) { super(id); } public ASTprimary(SLCompiler p, int id) { super(p, id); } } --- NEW FILE: ParseException.java --- /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ public class ParseException extends Exception { /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean * flag "specialConstructor" is also set to true to indicate that * this constructor was used to create this object. * This constructor calls its super class with the empty string * to force the "toString" method of parent class "Throwable" to * print the error message in the form: * ParseException: <result of getMessage> */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { super(); specialConstructor = false; } public ParseException(String message) { super(message); specialConstructor = false; } /** * This variable determines which constructor was used to create * this object and thereby affects the semantics of the * "getMessage" method (see below). */ protected boolean specialConstructor; /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public String[] tokenImage; /** * This method has the standard behavior when this object has been * created using the standard constructors. Otherwise, it uses * "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser), then this method is called during the printing * of the final stack trace, and hence the correct error message * gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } String expected = ""; int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected += tokenImage[expectedTokenSequences[i][j]] + " "; } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected += "..."; } expected += eol + " "; } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += add_escapes(tok.image); tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected; return retval; } /** * The end of line string for this machine. ... [truncated message content] |
From: Gerardo H. <ma...@us...> - 2004-07-31 05:12:07
|
Update of /cvsroot/jrman/drafts/slcomp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25319/slcomp Log Message: Directory /cvsroot/jrman/drafts/slcomp added to the repository |
From: <ben...@id...> - 2004-05-22 12:22:55
|
Dear Open Source developer I am doing a research project on "Fun and Software Development" in which I kindly invite you to participate. You will find the online survey under http://fasd.ethz.ch/qsf/. The questionnaire consists of 53 questions and you will need about 15 minutes to complete it. With the FASD project (Fun and Software Development) we want to define the motivational significance of fun when software developers decide to engage in Open Source projects. What is special about our research project is that a similar survey is planned with software developers in commercial firms. This procedure allows the immediate comparison between the involved individuals and the conditions of production of these two development models. Thus we hope to obtain substantial new insights to the phenomenon of Open Source Development. With many thanks for your participation, Benno Luthiger PS: The results of the survey will be published under http://www.isu.unizh.ch/fuehrung/blprojects/FASD/. We have set up the mailing list fa...@we... for this study. Please see http://fasd.ethz.ch/qsf/mailinglist_en.html for registration to this mailing list. _______________________________________________________________________ Benno Luthiger Swiss Federal Institute of Technology Zurich 8092 Zurich Mail: benno.luthiger(at)id.ethz.ch _______________________________________________________________________ |
From: Gerardo H. <ma...@us...> - 2004-05-04 07:00:37
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13477/src/org/jrman/parser Modified Files: Parser.java Log Message: Small fix to NURBS Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** Parser.java 27 Apr 2004 06:28:57 -0000 1.92 --- Parser.java 4 May 2004 06:59:58 -0000 1.93 *************** *** 100,104 **** import java.util.Iterator; - public class Parser { --- 100,103 ---- *************** *** 146,150 **** private int lastFrame = -1; ! private static Point4f P = new Point4f(); --- 145,149 ---- private int lastFrame = -1; ! private static Point4f P = new Point4f(); *************** *** 1088,1102 **** } - private void print(float[] array) - { - System.out.print("("); - - for(int i = 0; i < array.length - 1; i ++) - System.out.print(array[i] + ", "); - - System.out.print(array[array.length - 1]); - System.out.println(")"); - } - public void addNuPatch( final int nu, --- 1087,1090 ---- *************** *** 1113,1178 **** if (inAreaLightSource) return; - float[] points = extractPoints(nu * nv, parameters); - float[] ualfa = insert(uknot, uorder, nu); float[] valfa = insert(vknot, vorder, nv); ! ! int mu = ualfa.length /nu; ! int mv = valfa.length /nv; ! ! print(points); ! float[] result = new float[mu * mv * 4]; ! float[] tmp = new float[mu * mv * 4]; ! for(int i = 0; i < nv; i++) ! { divideu(ualfa, points, nu, i, tmp, mu); } ! ! print(result); ! ! for(int i = 0; i < mu; i++) ! { ! dividev(valfa, tmp, nv, i, result, mv); } ! ! print(result); ! ! parameters.addParameter(new VaryingScalarHPoint ! (new Declaration("Pw", "vertex hpoint"), result)); ! ! addBicubicPatchMesh(mu, "nonperiodic", mv, "nonperiodic", parameters); } ! ! private float[] insert(float[] x, int order, int n) ! { List l = new ArrayList(); float prev = x[0]; ! for(int i = 0; i < x.length; i++) ! { ! if(x[i] != prev) ! { insert(l, prev, order); prev = x[i]; - } } insert(l, prev, order); - float[] y = new float[l.size()]; int c = 0; ! for(Iterator it = l.iterator(); it.hasNext(); c++) ! { y[c] = ((Float) it.next()).floatValue(); } - int m = y.length - order; - float[] result = new float[m * n]; ! ! for(int j = 0; j < m; j++) ! { ! for(int i = 0; i < n; i++) ! { float alfa = evaluate(x, y, i, j, order); result[(j * n) + i] = alfa; --- 1101,1144 ---- if (inAreaLightSource) return; float[] points = extractPoints(nu * nv, parameters); float[] ualfa = insert(uknot, uorder, nu); float[] valfa = insert(vknot, vorder, nv); ! int mu = ualfa.length / nu; ! int mv = valfa.length / nv; ! float[] tmp = new float[mu * nv * 4]; ! for (int i = 0; i < nv; i++) { divideu(ualfa, points, nu, i, tmp, mu); } ! float[] result = new float[mu * mv * 4]; ! for (int i = 0; i < mu; i++) { ! dividev(valfa, tmp, nv, i, result, mv, mu); } ! parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), result)); ! pushAttributes(); ! setBasis(Basis.BEZIER, 3, Basis.BEZIER, 3); ! addBicubicPatchMesh(mu, "nonperiodic", mv, "nonperiodic", parameters); ! popAttributes(); } ! ! private float[] insert(float[] x, int order, int n) { List l = new ArrayList(); float prev = x[0]; ! for (int i = 0; i < x.length; i++) { ! if (x[i] != prev) { insert(l, prev, order); prev = x[i]; } } insert(l, prev, order); float[] y = new float[l.size()]; int c = 0; ! for (Iterator it = l.iterator(); it.hasNext(); c++) { y[c] = ((Float) it.next()).floatValue(); } int m = y.length - order; float[] result = new float[m * n]; ! for (int j = 0; j < m; j++) { ! for (int i = 0; i < n; i++) { float alfa = evaluate(x, y, i, j, order); result[(j * n) + i] = alfa; *************** *** 1182,1261 **** } ! ! private void divideu(float[] alfa, float[] points, int n, int offset, ! float[] result, int m) ! { ! int noffset = n * offset * 4; ! int moffset = m * offset * 4; ! ! for(int j = 0; j < m; j++) ! { ! for(int i = 0; i < n; i++) ! { ! float a = alfa[(j * n) + i]; ! result[moffset + j * 4] += points[noffset + i * 4] * a; ! result[moffset + j * 4 + 1] += points[noffset + i * 4 + 1] * a; ! result[moffset + j * 4 + 2] += points[noffset + i * 4 + 2] * a; ! result[moffset + j * 4 + 3] += points[noffset + i * 4 + 3] * a; } } } ! private void dividev(float[] alfa, float[] points, int n, int offset, ! float[] result, int m) ! { ! int noffset = n * offset * 4; ! int moffset = m * offset * 4; ! ! for(int j = 0; j < m; j++) ! { ! for(int i = 0; i < n; i++) ! { ! float a = alfa[(i * m) + j]; ! result[moffset + j * 4] += points[noffset + i * 4] * a; ! result[moffset + j * 4 + 1] += points[noffset + i * 4 + 1] * a; ! result[moffset + j * 4 + 2] += points[noffset + i * 4 + 2] * a; ! result[moffset + j * 4 + 3] += points[noffset + i * 4 + 3] * a; } } } ! ! private float evaluate(float[] x, float[] y, int i, int j, int k) ! { ! if(k == 1) ! if(x[i] <= y[j] && y[j] < x[i+1]) return 1; else return 0; ! ! float a1 = evaluate(x, y, i, j, k - 1) ; float a2 = evaluate(x, y, i + 1, j, k - 1); ! ! return ( a1 != 0 ? ((y[j + k - 1] - x[i]) / (x[i + k - 1] - x[i])) : 0) + ! (a2 != 0 ? ((x[i + k] - y[j + k - 1]) / (x[i + k] - x[i + 1])) : 0); } ! ! private void insert(List l, float x, int order) ! { Float f = new Float(x); ! for(int c = 0; c < order ; c++) l.add(f); } ! private float[] extractPoints(int points, ParameterList parameters) { VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); ! ! if(param3f != null) ! { parameters.removeParameter("P"); ! parameters.addParameter(new VaryingScalarHPoint ! (new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); parameters.removeParameter("Pw"); - float[] controlPoints = new float[points * 4]; ! for(int i = 0; i < points; i ++) ! { paramHp.getValue(i, P); controlPoints[(4 * i)] = P.x; --- 1148,1219 ---- } ! private void divideu( ! float[] alfa, ! float[] points, ! int nu, ! int row, ! float[] result, ! int mu) { ! int srcOffset = nu * row * 4; ! int dstOffet = mu * row * 4; ! for (int j = 0; j < mu; j++) { ! for (int i = 0; i < nu; i++) { ! float a = alfa[(j * nu) + i]; ! result[dstOffet + j * 4] += points[srcOffset + i * 4] * a; ! result[dstOffet + j * 4 + 1] += points[srcOffset + i * 4 + 1] * a; ! result[dstOffet + j * 4 + 2] += points[srcOffset + i * 4 + 2] * a; ! result[dstOffet + j * 4 + 3] += points[srcOffset + i * 4 + 3] * a; } } } ! private void dividev( ! float[] alfa, ! float[] points, ! int nv, ! int column, ! float[] result, ! int mv, ! int mu) { ! for (int j = 0; j < mv; j++) { ! for (int i = 0; i < nv; i++) { ! float a = alfa[(j * nv) + i]; ! result[j * mu * 4 + column * 4] += points[i * mu * 4 + column * 4] * a; ! result[j * mu * 4 + column * 4 + 1] += points[i * mu * 4 + column * 4 + 1] * a; ! result[j * mu * 4 + column * 4 + 2] += points[i * mu * 4 + column * 4 + 2] * a; ! result[j * mu * 4 + column * 4 + 3] += points[i * mu * 4 + column * 4 + 3] * a; } } } ! ! private float evaluate(float[] x, float[] y, int i, int j, int k) { ! if (k == 1) ! if (x[i] <= y[j] && y[j] < x[i + 1]) return 1; else return 0; ! float a1 = evaluate(x, y, i, j, k - 1); float a2 = evaluate(x, y, i + 1, j, k - 1); ! return (a1 != 0 ? ((y[j + k - 1] - x[i]) / (x[i + k - 1] - x[i])) : 0) ! + (a2 != 0 ? ((x[i + k] - y[j + k - 1]) / (x[i + k] - x[i + 1])) : 0); } ! ! private void insert(List l, float x, int order) { Float f = new Float(x); ! for (int c = 0; c < order; c++) l.add(f); } ! private float[] extractPoints(int points, ParameterList parameters) { VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); ! if (param3f != null) { parameters.removeParameter("P"); ! parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); parameters.removeParameter("Pw"); float[] controlPoints = new float[points * 4]; ! for (int i = 0; i < points; i++) { paramHp.getValue(i, P); controlPoints[(4 * i)] = P.x; *************** *** 1267,1271 **** } - public void addPointsPolygons( final int[] nVertices, --- 1225,1228 ---- |
From: Gerardo H. <ma...@us...> - 2004-04-27 06:29:06
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15575/src/org/jrman/parser Modified Files: Parser.java Log Message: Trying to fix nurbs.... Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** Parser.java 27 Apr 2004 00:36:44 -0000 1.91 --- Parser.java 27 Apr 2004 06:28:57 -0000 1.92 *************** *** 1124,1131 **** print(points); float[] result = new float[mu * mv * 4]; ! for(int i = 0; i < nv; i++) { ! divide(ualfa, points, nu, i, result, mu); } --- 1124,1131 ---- print(points); float[] result = new float[mu * mv * 4]; ! float[] tmp = new float[mu * mv * 4]; for(int i = 0; i < nv; i++) { ! divideu(ualfa, points, nu, i, tmp, mu); } *************** *** 1134,1138 **** for(int i = 0; i < mu; i++) { ! divide(valfa, result, nv, i, result, mv); } --- 1134,1138 ---- for(int i = 0; i < mu; i++) { ! dividev(valfa, tmp, nv, i, result, mv); } *************** *** 1142,1146 **** (new Declaration("Pw", "vertex hpoint"), result)); ! addBicubicPatchMesh(mu, "periodic", mv, "nonperiodic", parameters); } --- 1142,1146 ---- (new Declaration("Pw", "vertex hpoint"), result)); ! addBicubicPatchMesh(mu, "nonperiodic", mv, "nonperiodic", parameters); } *************** *** 1175,1179 **** for(int i = 0; i < n; i++) { ! float alfa = evaluate(x, y, i, j, order, ""); result[(j * n) + i] = alfa; } --- 1175,1179 ---- for(int i = 0; i < n; i++) { ! float alfa = evaluate(x, y, i, j, order); result[(j * n) + i] = alfa; } *************** *** 1183,1187 **** ! private void divide(float[] alfa, float[] points, int n, int offset, float[] result, int m) { --- 1183,1187 ---- ! private void divideu(float[] alfa, float[] points, int n, int offset, float[] result, int m) { *************** *** 1196,1207 **** result[moffset + j * 4] += points[noffset + i * 4] * a; result[moffset + j * 4 + 1] += points[noffset + i * 4 + 1] * a; ! result[moffset + j * 4 + 2] += points[noffset + i * 4+ 2] * a; ! result[moffset + j * 4 + 3] += points[noffset + i * 4+ 3] * a; } } } ! private float evaluate(float[] x, float[] y, int i, int j, int k, String indent) { if(k == 1) --- 1196,1225 ---- result[moffset + j * 4] += points[noffset + i * 4] * a; result[moffset + j * 4 + 1] += points[noffset + i * 4 + 1] * a; ! result[moffset + j * 4 + 2] += points[noffset + i * 4 + 2] * a; ! result[moffset + j * 4 + 3] += points[noffset + i * 4 + 3] * a; } } } + private void dividev(float[] alfa, float[] points, int n, int offset, + float[] result, int m) + { + int noffset = n * offset * 4; + int moffset = m * offset * 4; + + for(int j = 0; j < m; j++) + { + for(int i = 0; i < n; i++) + { + float a = alfa[(i * m) + j]; + result[moffset + j * 4] += points[noffset + i * 4] * a; + result[moffset + j * 4 + 1] += points[noffset + i * 4 + 1] * a; + result[moffset + j * 4 + 2] += points[noffset + i * 4 + 2] * a; + result[moffset + j * 4 + 3] += points[noffset + i * 4 + 3] * a; + } + } + } ! private float evaluate(float[] x, float[] y, int i, int j, int k) { if(k == 1) *************** *** 1211,1216 **** return 0; ! float a1 = evaluate(x, y, i, j, k - 1, indent + " ") ; ! float a2 = evaluate(x, y, i + 1, j, k - 1, indent + " "); return ( a1 != 0 ? ((y[j + k - 1] - x[i]) / (x[i + k - 1] - x[i])) : 0) + --- 1229,1234 ---- return 0; ! float a1 = evaluate(x, y, i, j, k - 1) ; ! float a2 = evaluate(x, y, i + 1, j, k - 1); return ( a1 != 0 ? ((y[j + k - 1] - x[i]) / (x[i + k - 1] - x[i])) : 0) + |
From: Elmer G. <ega...@us...> - 2004-04-27 00:37:02
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27091/src/org/jrman/parser Modified Files: Parser.java Log Message: removed extra lines Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** Parser.java 18 Apr 2004 20:30:40 -0000 1.90 --- Parser.java 27 Apr 2004 00:36:44 -0000 1.91 *************** *** 1122,1125 **** --- 1122,1126 ---- int mv = valfa.length /nv; + print(points); float[] result = new float[mu * mv * 4]; *************** *** 1129,1146 **** } for(int i = 0; i < mu; i++) { divide(valfa, result, nv, i, result, mv); } ! ! for(int i = 0; i < result.length / 4; i++) ! { ! int pos = i * 4; ! result[pos] = result[pos]; ! result[pos + 1] = result[pos + 1]; ! result[pos + 2] = result[pos + 2]; ! result[pos + 3] = result[pos + 3]; ! } ! parameters.addParameter(new VaryingScalarHPoint (new Declaration("Pw", "vertex hpoint"), result)); --- 1130,1142 ---- } + print(result); + for(int i = 0; i < mu; i++) { divide(valfa, result, nv, i, result, mv); } ! ! print(result); ! parameters.addParameter(new VaryingScalarHPoint (new Declaration("Pw", "vertex hpoint"), result)); |
From: Elmer G. <ega...@us...> - 2004-04-18 20:31:01
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30260/src/org/jrman/parser Modified Files: Parser.java Log Message: Removed invalid reference Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** Parser.java 18 Apr 2004 20:04:49 -0000 1.89 --- Parser.java 18 Apr 2004 20:30:40 -0000 1.90 *************** *** 72,76 **** import org.jrman.parser.keywords.KeywordParser; import org.jrman.primitive.BicubicPatch; - import org.jrman.primitive.NuPatch; import org.jrman.primitive.BilinearPatch; import org.jrman.primitive.Cone; --- 72,75 ---- |
From: Elmer G. <ega...@us...> - 2004-04-18 20:06:18
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25332/sampleData Added Files: testVase.rib Log Message: An other NuPatch test. --- NEW FILE: testVase.rib --- Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 Format 400 300 1 PixelSamples 4 4 Exposure 1 2.2 Projection "perspective" "fov" [20] WorldBegin Translate 0 -5 60 Rotate 250 1 0 0 LightSource "ambientlight" 1 "intensity" [0.2] LightSource "distantlight" 2 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] ShadingRate .25 # Surface "paintedplastic" "texturename" "checkerboard.txr" ReadArchive "vase.rib" WorldEnd |
From: Elmer G. <ega...@us...> - 2004-04-18 20:04:58
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24756/src/org/jrman/primitive Modified Files: BicubicPatch.java Log Message: Added NuPatch support. Currently it works partially, I need to do more tests. Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** BicubicPatch.java 12 Apr 2004 04:37:24 -0000 1.12 --- BicubicPatch.java 18 Apr 2004 20:04:50 -0000 1.13 *************** *** 112,115 **** --- 112,116 ---- public BicubicPatch(ParameterList parameters, Attributes attributes) { super(parameters, attributes); + applyBasis(); } *************** *** 162,166 **** } ! public void applyBasis() { extractPoints(); Matrix4f hu = attributes.getUBasis().getToBezier(); --- 163,167 ---- } ! private void applyBasis() { extractPoints(); Matrix4f hu = attributes.getUBasis().getToBezier(); |