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 (7 years, 10 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 = [
            "Dot",
            "Add",
            "Sub",
            "Mul",
            "Div",
            "Neg",
            "Scale",	     
            "Kernel",
            "LoadImage",
            "Field",
            "SubField",
            "ScaleField",
            "NegField",
            "ProbeField",
            "Inside",
            "DiffField",
            "AddField",
            "DotField"
          ]

  (* 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
                in
                  AtomTable.insert tbl (id, T.OPER id)
                end
          val find = AtomTable.find tbl
          fun idToken id = let
                val id = Atom.atom id
                in 
                  case find id
                   of NONE => T.ID id (* does not find the kw *)
                    | SOME kw => kw (* finds the keywords*)
                  (* end case *)
                end
          in
            List.app ins kws; (* seed hash table with keywords *)
            idToken
          end

    val idToken = mkFind keywords

  end

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