Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/ml-yacc/examples/pascal/join.sml
ViewVC logotype

View of /sml/trunk/src/ml-yacc/examples/pascal/join.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (download) (annotate)
Sat Oct 4 23:33:09 1997 UTC (22 years, 10 months ago) by monnier
File size: 1456 byte(s)
Initial revision
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)

val parse = fn s =>
  let val dev = open_in s
      val stream = PascalParser.makeLexer(fn i => input(dev,i))
      val _ = PascalLex.UserDeclarations.lineNum := 1
      val error = fn (e,i:int,_) => output(std_out,s ^ "," ^
		  " line " ^ (makestring i) ^ ", Error: " ^ e ^ "\n")
  in PascalParser.parse(30,stream,error,()) before close_in dev
  end

val keybd = fn () =>
  let val dev = std_in

  (* note: some implementations of ML, such as SML of NJ,
     have more efficient versions of input_line in their built-in
     environment
   *)

      val input_line = fn f =>
         let fun loop result =
              let val c = input (f,1)
	          val result = c :: result
               in if String.size c = 0 orelse c = "\n" then
		      String.implode (rev result)
	          else loop result
	       end
         in loop nil
         end
      val stream = PascalParser.makeLexer (fn i => input_line dev)
      val _ = PascalLex.UserDeclarations.lineNum := 1
      val error = fn (e,i:int,_) => output(std_out,"std_in," ^
		  " line " ^ (makestring i) ^ ", Error: " ^ e ^ "\n")
  in PascalParser.parse(0,stream,error,())
  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0