Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /trunk/src/compiler/parser/keywords.sml
ViewVC logotype

View of /trunk/src/compiler/parser/keywords.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (download) (annotate)
Thu Feb 11 00:37:51 2010 UTC (9 years, 10 months ago) by jhr
Original Path: trunk/src/parser/keywords.sml
File size: 1302 byte(s)
  New directory
(* keywords.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *
 * Diderot keywords.
 *)

structure Keywords : sig

    val idToken : string -> DiderotTokens.token

  end = struct

    structure T = DiderotTokens

    val keywords = [
	    ("actor",		T.KW_actor),
	    ("bool",		T.KW_bool),
	    ("die",		T.KW_die),
	    ("else",		T.KW_else),
	    ("field",		T.KW_field),
	    ("if",		T.KW_if),
	    ("image",		T.KW_image),
	    ("input",		T.KW_input),
	    ("int",		T.KW_int),
	    ("kernel",		T.KW_kernel),
	    ("new",		T.KW_new),
	    ("real",		T.KW_real),
	    ("stabilize",	T.KW_stabilize),
	    ("string",		T.KW_string),
	    ("tensor",		T.KW_tensor),
	    ("vec",		T.KW_vec)
	  ]

  (* create a keyword lookup table *)
    local
      fun mkFind kws = let
	    val tbl = AtomTable.mkTable (17, Fail "keywords")
	    fun ins (id, tok) = AtomTable.insert tbl (Atom.atom id, tok)
	    val find = AtomTable.find tbl
	    fun idToken id = let
		  val id = Atom.atom id
		  in
		    case find id
		     of NONE => T.ID id
		      | SOME kw => kw
		    (* end case *)
		  end
	    in
	      List.app ins kws;
	      idToken
	    end
    in
  (* return either a keyword token or an ID token *)
      val idToken = mkFind keywords
    end

  end

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