#!/bin/csh 

luca_lex $1 > /tmp/$$.lex
if ($3 == "lex") then
   cat /tmp/$$.lex
   /bin/rm /tmp/$$.*
   exit
endif

cat /tmp/$$.lex | luca_parse > /tmp/$$.parse
if ($3 == "parse") then
   cat /tmp/$$.parse
   /bin/rm /tmp/$$.*
   exit
endif

cat /tmp/$$.parse | luca_sem -agvm > /tmp/$$.sem
if ($3 == "sem") then
   cat /tmp/$$.sem
   /bin/rm /tmp/$$.*
   exit
endif

cat /tmp/$$.sem | luca_AST2tree -agvm > /tmp/$$.tree
if ($3 == "tree") then
   cat /tmp/$$.tree
   /bin/rm /tmp/$$.*
   exit
endif

cat /tmp/$$.tree | luca_tree2stack > /tmp/$$.stack
if ($3 == "stack") then
   cat /tmp/$$.stack
   /bin/rm /tmp/$$.*
   exit
endif

if ($3 == "quad") then
   cat /tmp/$$.tree | luca_tree2quad > /tmp/$$.quad
   cat /tmp/$$.quad
   /bin/rm /tmp/$$.*
   exit
endif

if ($3 == "triple") then
   cat /tmp/$$.tree | luca_tree2triple > /tmp/$$.triple
   cat /tmp/$$.triple
   /bin/rm /tmp/$$.*
   exit
endif

cat /tmp/$$.stack | luca_stack2vm 

/bin/rm /tmp/$$.*

