[Pixelle-commit] SF.net SVN: pixelle: [75] trunk/pixelle/etc/Pixelle.g
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-25 04:08:59
|
Revision: 75
http://pixelle.svn.sourceforge.net/pixelle/?rev=75&view=rev
Author: dbrosius
Date: 2008-06-24 21:09:03 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
add trinaries -- w/o (in)equalities at present
Modified Paths:
--------------
trunk/pixelle/etc/Pixelle.g
Modified: trunk/pixelle/etc/Pixelle.g
===================================================================
--- trunk/pixelle/etc/Pixelle.g 2008-06-25 03:12:54 UTC (rev 74)
+++ trunk/pixelle/etc/Pixelle.g 2008-06-25 04:09:03 UTC (rev 75)
@@ -21,6 +21,7 @@
@header {
package com.mebigfatguy.pixelle.antlr;
import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
}
@@ -62,8 +63,32 @@
expr :
cond_expr ;
-cond_expr :
- cond_or_expr ( '?' expr ':' expr )? ;
+cond_expr
+ @init
+ {
+ Label falseLabel = null;
+ Label continueLabel = null;
+ }
+ :
+ cond_or_expr
+ ( '?'
+ {
+ falseLabel = new Label();
+ mv.visitLdcInsn(Double.valueOf(0));
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFNE, falseLabel);
+ }
+ expr ':'
+ {
+ continueLabel = new Label();
+ mv.visitJumpInsn(Opcodes.GOTO, continueLabel);
+ mv.visitLabel(falseLabel);
+ }
+ expr
+ {
+ mv.visitLabel(continueLabel);
+ }
+ )? ;
cond_or_expr :
cond_and_expr ( '&&' cond_and_expr )* ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|