• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1            Mini-Mini tutorial
2            ------------------
3
4Mini is a very simple (semi-functional) language that I wrote to test
5the generic package of BCEL.
6
7    http://commons.apache.org/bcel/
8
9Mini uses the JavaCC parser generator which comes precompiled from
10
11    http://www.webgain.com/products/java_cc/
12
13After  setting the  CLASSPATH to  the  directory  just above the  Mini
14directory, e.g.
15
16    % cd Mini
17    % setenv CLASSPATH $CLASSPATH:.:..
18
19try the following:
20
21    % java Mini.MiniC max.mini
22
23This produces a Java class file (max.class) which you can execute with
24
25    % java max
26
27Enter a number (4, eg.)  and you will be asked to enter 4 numbers. The
28program will then tell you the biggest of them.
29
30Alternatively you can  produce a  Java  file (max.java) which  will be
31translated automatically to a .class file.
32
33    % java Mini.MiniC -java max.mini
34
35There are three    examples programs  (max.mini,  fac.mini,  fib.mini)
36provided  which  demonstrate the language  syntax  and should be quite
37easy to understand.
38
39
40The compiler is not  that well documented, I'm  afraid, but  if you've
41ever seen a compiler before, you should be able to understand what I'm
42doing. The  part that  produces  the  byte code   is contained  in the
43byte_code() method  that  all AST   nodes implement.  Take  a  look at
44MiniC.java at line 85 and follow the recursive byte_code() calls.
45
46It's also useful to use  the listclass program provided with BCEL
47to examine the generated class. For example
48
49    % java listclass max.class
50
51
52Send bug reports and suggestions to
53
54    m.dahm@gmx.de (Markus Dahm)
55