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 1484 - (download) (annotate)
Sun Sep 4 14:35:20 2011 UTC (9 years ago) by jhr
File size: 1674 byte(s)
  Created a compiler/gen directory to hold code for the generation tools.  Moved
  compiler/IL/gen to compiler/gen/il and created compiler/gen/opt for Charisee's tool.
(* 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 hastable*)
          val tbl = AtomTable.mkTable (17, Fail "keywords")
          fun ins (id) =let
	      val id=Atom.atom id
	      AtomTable.insert tbl(id,T.OPER id)
	      (*inserts into the table the operators and 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; (*renames keywords to kws*)

    val idToken = mkFind keywords


ViewVC Help
Powered by ViewVC 1.0.0