Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/ckit/src/parser/grammar/tokentable.sml
ViewVC logotype

Diff of /sml/trunk/ckit/src/parser/grammar/tokentable.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 808, Wed Apr 18 15:43:09 2001 UTC revision 809, Wed Apr 18 17:53:01 2001 UTC
# Line 23  Line 23 
23    exception LexError    exception LexError
24    val keywords : item AtomTable.hash_table = AtomTable.mkTable(64, Keyword)    val keywords : item AtomTable.hash_table = AtomTable.mkTable(64, Keyword)
25    
26    val _ = let    local
27      val insert = AtomTable.insert keywords      val insert = AtomTable.insert keywords
28      fun ins (s, item) = insert (Atom.atom s, item)      fun ins (s, item) = insert (Atom.atom s, item)
29    
30        fun idTok (s, pos, endPos) =
31            if TypeDefs.checkTdef(s) = true then
32                Tokens.TYPE_NAME(s,pos,endPos)
33            else Tokens.ID(s,pos,endPos)
34    
35      (* to enter GCC-style 'underscore'-versions of certain keywords *)      (* to enter GCC-style 'underscore'-versions of certain keywords *)
36      fun insaug (s, item) = let      fun insaug (s, item) = let
37          fun item' p = if ParseControl.underscoreKeywords then item p          fun item' (p as (pos, endPos)) =
38                        else (ParseControl.violation              case ParseControl.underscoreKeywords of
39                    NONE => idTok (s, pos, endPos)
40                  | SOME true => item p
41                  | SOME false =>
42                    (ParseControl.violation
43                              (concat ["gcc-style keywords '__", s, "' or '__",                              (concat ["gcc-style keywords '__", s, "' or '__",
44                                       s, "__' are not allowed"]);                                       s, "__' are not allowed"]);
45                              raise LexError)                              raise LexError)
# Line 88  Line 97 
97      val dtokens =      val dtokens =
98          [          [
99           ]           ]
100    in  
101        app ins normaltokens;      val _ =
102            (app ins normaltokens;
103        app ins augmentabletokens;        app ins augmentabletokens;
104        app insaug augmentabletokens;        app insaug augmentabletokens;
105        (* enter D keywords only when allowed...        (* enter D keywords only when allowed...
106         * (I think the ParseControl test is done at the wrong time here.         * (I think the ParseControl test is done at the wrong time here.
107         *  - Blume) *)         *  - Blume) *)
108        if ParseControl.Dkeywords then app ins dtokens else ()           if ParseControl.Dkeywords then app ins dtokens else ())
109    end    in
   
110    fun checkToken (s, pos) = let    fun checkToken (s, pos) = let
111      val endPos = pos + size s      val endPos = pos + size s
112      val name = Atom.atom s      val name = Atom.atom s
113    in    in
114      case (AtomTable.find keywords name)            case (AtomTable.find keywords name) of
115        of (SOME tokFn) => tokFn(pos, endPos)                SOME tokFn => tokFn(pos, endPos)
116         | NONE =>              | NONE => idTok (s, pos, endPos)
            (if TypeDefs.checkTdef(s) = true then  
               Tokens.TYPE_NAME(s,pos,endPos)  
             else Tokens.ID(s,pos,endPos))  
   (* end case *)  
117    end    end
118      end (* local *)
119  end  end

Legend:
Removed from v.808  
changed lines
  Added in v.809

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