diff options
| author | aarne <unknown> | 2004-09-28 19:44:02 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-09-28 19:44:02 +0000 |
| commit | 01f872bf5db46863565c44c7f40b337217d35e8e (patch) | |
| tree | 6ea7ddb450efdd4e8da5aec6631da7b22b5911a9 /examples/gfcc/compiler | |
| parent | 422b626a361c08b911471c04159931756887335c (diff) | |
gfcc report
Diffstat (limited to 'examples/gfcc/compiler')
| -rw-r--r-- | examples/gfcc/compiler/FILES | 6 | ||||
| -rw-r--r-- | examples/gfcc/compiler/factorial.c | 19 | ||||
| -rw-r--r-- | examples/gfcc/compiler/gfcc | 4 | ||||
| -rw-r--r-- | examples/gfcc/compiler/makefile | 4 |
4 files changed, 25 insertions, 8 deletions
diff --git a/examples/gfcc/compiler/FILES b/examples/gfcc/compiler/FILES index b33a27a1c..a52e74c9e 100644 --- a/examples/gfcc/compiler/FILES +++ b/examples/gfcc/compiler/FILES @@ -28,12 +28,12 @@ jvm.tmp -- pseudo-JVM produced by GF linearization Required programs to use the compiler: ------------------------------------- -gf+ -- Grammatical Framework version 2.0+, >= 23/9/2004 -jasmin -- JVM assembler (to compile Foo.j to Foo.class) +gf+ -- Grammatical Framework version 2.1beta, >= 23/9/2004 +jasmin -- JVM assembler (to compile Foo.j to Foo.class) Required programs to build the compiler: --------------------------------------- -bnfc -- BNF Converter version 2.1+, >= 23/9/2004 +bnfc -- BNF Converter version 2.2beta, >= 23/9/2004 happy -- parser generator for Haskell, >= 1.13 alex -- lexer generator for Haskell, >= 2.0 Profile.hs -- BNFC source file (formats/profile), must be on your path diff --git a/examples/gfcc/compiler/factorial.c b/examples/gfcc/compiler/factorial.c index 2a1c3f5f3..76fee32d0 100644 --- a/examples/gfcc/compiler/factorial.c +++ b/examples/gfcc/compiler/factorial.c @@ -10,11 +10,28 @@ int fact (int n) { return f ; } ; +int factr (int n) { + int f ; + { + if (n < 2) { + f = 1 ; + } + else { + f = n * factr (n-1) ; + } + } + return f ; +} ; + int main () { int n ; n = 1 ; { - while (n < 11) printf("%d",fact(n)) ; n = n+1 ; + while (n < 11) { + printf("%d",fact(n)) ; + printf("%d",factr(n)) ; + n = n+1 ; + } } return ; } ; diff --git a/examples/gfcc/compiler/gfcc b/examples/gfcc/compiler/gfcc index c36e42404..9750b8133 100644 --- a/examples/gfcc/compiler/gfcc +++ b/examples/gfcc/compiler/gfcc @@ -1,4 +1,4 @@ ./TestImperC $1 | tail -1 >gft.tmp -echo "es -file=typecheck.gfs" | gf+ -s Imper.gfcm +echo "es -file=typecheck.gfs" | gf -s Imper.gfcm runhugs CleanJVM jvm.tmp $1 -#rm *.tmp +rm *.tmp diff --git a/examples/gfcc/compiler/makefile b/examples/gfcc/compiler/makefile index 802d024cc..cc175731b 100644 --- a/examples/gfcc/compiler/makefile +++ b/examples/gfcc/compiler/makefile @@ -1,10 +1,10 @@ -GF=gf+ +GF=gf SRC=../ all: compiler compiler: - echo "pm | wf Imper.gfcm ;; pg -lang=ImperC -printer=lbnf | wf ImperC.tmp" | $(GF) $(SRC)ImperC.gf $(SRC)ImperJVM.gf + echo "pm | wf Imper.gfcm ;; pg -lang=ImperC -printer=plbnf | wf ImperC.tmp" | $(GF) $(SRC)ImperC.gf $(SRC)ImperJVM.gf echo "entrypoints Program, Stm, Exp ;" >entry.tmp cat entry.tmp ImperC.tmp >ImperC.cf bnfc -m -prof ImperC.cf |
