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

SCM Repository

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

View of /trunk/src/compiler/parser/keywords.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3349 - (download) (annotate)
Tue Oct 27 15:16:36 2015 UTC (6 years, 1 month ago) by jhr
File size: 2540 byte(s)
making copyrights consistent for all code in the repository
(* keywords.sml
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 * Diderot keywords.

structure Keywords : sig

    val idToken : string -> DiderotTokens.token

  end = struct

    structure T = DiderotTokens

    val keywords = [
            ("bool",            T.KW_bool),
            ("die",             T.KW_die),
            ("else",            T.KW_else),
            ("false",           T.KW_false),
            ("field",           T.KW_field),
            ("function",        T.KW_function),
            ("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),
            ("nan",             T.FLOAT FloatLit.nan),
            ("new",             T.KW_new),
            ("output",          T.KW_output),
            ("print",           T.KW_print),
            ("real",            T.KW_real),
            ("return",          T.KW_return),
            ("stabilize",       T.KW_stabilize),
            ("strand",          T.KW_strand),
            ("string",          T.KW_string),
            ("tensor",          T.KW_tensor),
            ("true",            T.KW_true),
            ("update",          T.KW_update),
            ("vec2",            T.KW_vec2),
            ("vec3",            T.KW_vec3),
            ("vec4",            T.KW_vec4),
            ("zeros",           T.KW_zeros)

  (* create a keyword lookup table *)
      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
                    case find id
                     of NONE => T.ID id
                      | SOME kw => kw
                    (* end case *)
              List.app ins kws;
  (* return either a keyword token or an ID token *)
      val idToken = mkFind keywords


ViewVC Help
Powered by ViewVC 1.0.0