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 (7 years, 11 months 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 = [
            "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 hastable*)
          val tbl = AtomTable.mkTable (17, Fail "keywords")
          fun ins (id) =let
	      val id=Atom.atom id
			       in
	      AtomTable.insert tbl(id,T.OPER id)
	      (*inserts into the table the operators and 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; (*renames keywords to kws*)
            idToken
          end

    val idToken = mkFind keywords

  end

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