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

SCM Repository

[diderot] Diff of /branches/vis12-cl/src/compiler/parser/parser.sml
ViewVC logotype

Diff of /branches/vis12-cl/src/compiler/parser/parser.sml

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

revision 2682, Mon Aug 25 17:20:56 2014 UTC revision 2683, Mon Aug 25 18:56:17 2014 UTC
# Line 13  Line 13 
13    
14    end = struct    end = struct
15    
16        datatype add_or_delete = datatype AntlrRepair.add_or_delete
17    
18    (* glue together the lexer and parser *)    (* glue together the lexer and parser *)
19      structure DiderotParser = DiderotParseFn(DiderotLex)      structure DiderotParser = DiderotParseFn(DiderotLex)
20    
21    (* error function for lexers *)    (* error function for lexers *)
22      fun lexErr errStrm (pos, msg) = Error.errorAt(errStrm, (pos, pos), msg)      fun lexErr errStrm (pos, msg) = Error.errorAt(errStrm, (pos, pos), msg)
23    
24    (* map tokens to strings *)    (* map tokens to strings; when adding a token, we use a generic name where it makes sense *)
25      fun tokToString (DiderotTokens.ID x) = Atom.toString x      fun tokToString ADD (DiderotTokens.ID _) = "<identifier>"
26        | tokToString (DiderotTokens.STRING s) = concat["\"", String.toCString s, "\""]        | tokToString DEL (DiderotTokens.ID x) = Atom.toString x
27        | tokToString (DiderotTokens.FLOAT f) = FloatLit.toString f        | tokToString _ (DiderotTokens.STRING s) = concat["\"", String.toCString s, "\""]
28        | tokToString (DiderotTokens.INT i) = IntInf.toString i        | tokToString ADD (DiderotTokens.FLOAT f) = "<number>"
29        | tokToString tok = DiderotTokens.toString tok        | tokToString DEL (DiderotTokens.FLOAT f) = FloatLit.toString f
30          | tokToString ADD (DiderotTokens.INT i) = "<integer>"
31          | tokToString DEL (DiderotTokens.INT i) = IntInf.toString i
32          | tokToString ADD DiderotTokens.KW_vec4 = "<type>"
33          | tokToString ADD DiderotTokens.KW_vec3 = "<type>"
34          | tokToString ADD DiderotTokens.KW_vec2 = "<type>"
35          | tokToString ADD DiderotTokens.KW_real = "<type>"
36          | tokToString ADD DiderotTokens.KW_int = "<type>"
37          | tokToString ADD DiderotTokens.KW_bool = "<type>"
38          | tokToString _ tok = DiderotTokens.toString tok
39    
40    (* error function for parsers *)    (* error function for parsers *)
41      val parseErr = Error.parseError tokToString      val parseErr = Error.parseError tokToString

Legend:
Removed from v.2682  
changed lines
  Added in v.2683

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