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

SCM Repository

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

View of /trunk/src/compiler/gen/opt/keywords.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1485 - (download) (annotate)
Sun Sep 4 14:37:21 2011 UTC (9 years, 9 months ago) by jhr
File size: 1650 byte(s)
  Minor syntax editing
(* keywords.sml
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

structure Keywords : sig

    val idToken : string -> RulesTokens.token

  end = struct

    structure T = RulesTokens

  (* these are a subset of the operators; eventually, these will be either generated
   * by the IL generator tool or become part of the specification.
    val keywords = [

  (* create a keyword lookup table *)
    fun mkFind kws = let
	(* creates empty hashtable *)
          val tbl = AtomTable.mkTable (17, Fail "keywords")
          fun ins id =let
                val id=Atom.atom id
                  AtomTable.insert tbl (id, T.OPER id)
          val find = AtomTable.find tbl
          fun idToken id = let
                val id = Atom.atom id
                  case find id
                   of NONE => T.ID id (* does not find the kw *)
                    | SOME kw => kw (* finds the keywords*)
                  (* end case *)
            List.app ins kws; (* seed hash table with keywords *)

    val idToken = mkFind keywords


ViewVC Help
Powered by ViewVC 1.0.0