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

SCM Repository

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

View of /branches/lamont/src/compiler/parser/keywords.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2298 - (download) (annotate)
Fri Mar 15 22:18:22 2013 UTC (6 years, 7 months ago) by jhr
File size: 3388 byte(s)
  Merging in changes from vis12 branch.
(* keywords.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Diderot keywords.
 *)

structure Keywords : sig

    val idToken : string -> DiderotTokens.token

  end = struct

    structure T = DiderotTokens

    val keywords = [
            ("active",          T.KW_active),
            ("all",             T.KW_all),      (* FIXME: should be variable *)
            ("bool",            T.KW_bool),
            ("dead",            T.KW_dead),
            ("die",             T.KW_die),
            ("else",            T.KW_else),
            ("exists",          T.KW_exists),   (* FIXME: should be variable *)
            ("false",           T.KW_false),
            ("field",           T.KW_field),
            ("foreach",         T.KW_foreach),
            ("global",          T.KW_global),
            ("identity",        T.KW_identity),
            ("if",              T.KW_if),
            ("image",           T.KW_image),
            ("in",              T.KW_in),
            ("inf",             T.FLOAT FloatLit.posInf),
            ("initially",       T.KW_initially),
            ("input",           T.KW_input),
            ("int",             T.KW_int),
            ("kernel",          T.KW_kernel),
            ("load",            T.KW_load),
            ("maxr",            T.KW_max),      (* FIXME: should be variable *)
            ("mean",            T.KW_mean),     (* FIXME: should be variable *)
            ("minr",            T.KW_min),      (* FIXME: should be variable *)
            ("nan",             T.FLOAT FloatLit.nan),
            ("new",             T.KW_new),
            ("output",          T.KW_output),
            ("print",           T.KW_print),
            ("product",         T.KW_product),  (* FIXME: should be variable *)
            ("real",            T.KW_real),
            ("return",          T.KW_return),
            ("stabilize",       T.KW_stabilize),
            ("stable",          T.KW_stable),
            ("strand",          T.KW_strand),
            ("string",          T.KW_string),
            ("sum",             T.KW_sum),      (* FIXME: should be variable *)
            ("tensor",          T.KW_tensor),
            ("true",            T.KW_true),
            ("update",          T.KW_update),
            ("variance",        T.KW_variance), (* FIXME: should be variable *)
            ("vec2",            T.KW_vec2),
            ("vec3",            T.KW_vec3),
            ("vec4",            T.KW_vec4),
            ("xor",             T.KW_xor),      (* FIXME: should be variable *)
            ("zeros",           T.KW_zeros)
          ]

  (* 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