File: parser.sml

package info (click to toggle)
mlton 20061107-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,828 kB
  • ctags: 61,118
  • sloc: ansic: 11,446; makefile: 1,339; sh: 1,160; lisp: 900; pascal: 256; asm: 97
file content (36 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(* parser.sml *)
(* driver for Pascal parser *)

structure Parser =
struct

structure PascalLrVals = PascalLrValsFun(structure Token = LrParser.Token)

structure PascalLex = PascalLexFun(structure Tokens = PascalLrVals.Tokens)

structure PascalParser = Join(structure Lex= PascalLex
                              structure LrParser = LrParser
                              structure ParserData = PascalLrVals.ParserData)

fun parse s =
    let val dev = TextIO.openIn s
        val stream = PascalParser.makeLexer(fn i => TextIO.inputN(dev,i))
        fun error (e,i:int,_) =
            TextIO.output(TextIO.stdOut,
               s ^ "," ^ " line " ^ (Int.toString i) ^ ", Error: " ^ e ^ "\n")
     in PascalLex.UserDeclarations.lineNum := 1;
        PascalParser.parse(30,stream,error,())
        before TextIO.closeIn dev
    end

fun keybd () =
    let val stream = 
            PascalParser.makeLexer (fn i => TextIO.inputLine TextIO.stdIn)
        fun error (e,i:int,_) =
            TextIO.output(TextIO.stdOut,
              "std_in," ^ " line " ^ (Int.toString i) ^ ", Error: " ^ e ^ "\n")
     in PascalLex.UserDeclarations.lineNum := 1;
        PascalParser.parse(0,stream,error,())
    end

end (* structure Parser *)