With the help of you guys, I can run the Calc sample from parsec in the Alice interpreter. That is I hit Ctrl-Alt-Ret on Calc.aml and then type
> main [("a", 0)];

Ultimately I want an application that will run from the command line and take a filename for the input and say send some parsed output to stdout.

So my first step was to create CalcStruct.aml which is a copy and paste of Calc.aml wrapped up in a structure. After loading this into the environment I can run it with:
> CalcStruct.main [("a", 0)];

Now to make a command line application.  I make a file called CalcMain.aml:

import structure CalcStruct from "CalcStruct"

structure CalcMain =
struct
    val _ = OS.Process.exit(CalcStruct.main [("a", 0)];
        OS.Process.success)
end

When I try to compile and run I get the error below which presumably means I have screwed up something. What puzzles me is that the error seems to imply some type checking problem between CalcStruct and CharParser which seem fine when I run CalcStruct.main in the interpreter.

[EMAIL PROTECTED] samples]$ alicec CalcMain.aml
[EMAIL PROTECTED] samples]$ alicerun CalcMain
alicerun: failure type-checking file:/home/pms/src/alice-parsec-0.21/CharParser
as requested by file:/home/pms/src/alice-parsec-0.21/samples/CalcStruct
Reason:
   structure CharParser
does not match, because
   structure P
does not match, because
   structure Token
does not match, because
   type position = Token.position
does not match specification
   type position = Token.position
Backtrace:
...

The source I am using can be found under
http://www.metrak.com/src/alice-parsec/samples

I also notice CharParser.aml has a parseFile function - I haven't got to that yet.

cheers

_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to