Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] Annotation of /trunk/sml3d/src/loaders/md5/md5mesh.lex
ViewVC logotype

Annotation of /trunk/sml3d/src/loaders/md5/md5mesh.lex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 525 - (view) (download)

1 : jhr 518 (* md5mesh.lex
2 :     *
3 :     * COPYRIGHT (c) 2009 John Reppy (http://cs.uchicago.edu/~jhr)
4 :     * All rights reserved.
5 :     *
6 :     * An ml-ulex specification for the MD5 Mesh file format.
7 :     *)
8 :    
9 :     %name MD5MeshLex;
10 :    
11 :     %defs (
12 : jhr 525 structure T = MD5MeshTokens;
13 : jhr 518
14 :     (* eof : unit -> lex_result *)
15 :     (* ml-ulex requires this as well *)
16 :     fun eof () = T.EOF
17 :    
18 :     (* list of string fragments to concatenate *)
19 :     val buf : string list ref = ref []
20 :    
21 :     (* add a string to the buffer *)
22 :     fun addStr s = (buf := s :: !buf)
23 :    
24 :     (* make a string from buf *)
25 :     fun mkString () = let
26 :     val s = String.concat(List.rev(!buf))
27 :     in
28 :     buf := [];
29 :     T.STR s
30 :     end
31 :     );
32 :    
33 :    
34 :     %states INITIAL STRING COMMENT;
35 :    
36 :     %let num = [0-9]+;
37 :     %let sgood = [\032-\126]&[^\"\\]; (* sgood means "characters good inside strings" *)
38 :     %let ws = " "|[\t\n\v\f\r];
39 :     %let eol = "\n"|"\r\n";
40 :    
41 :     <INITIAL> {ws} => (skip());
42 :    
43 :     <INITIAL> "(" => (T.LP);
44 :     <INITIAL> ")" => (T.RP);
45 :     <INITIAL> "{" => (T.LP);
46 :     <INITIAL> "}" => (T.RP);
47 :    
48 :     <INITIAL> "MD5Version" => (T.KW_MD5Version);
49 :     <INITIAL> "commandline" => (T.KW_commandline);
50 :     <INITIAL> "numJoints" => (T.KW_numJoints);
51 :     <INITIAL> "numMeshes" => (T.KW_numMeshes);
52 :     <INITIAL> "joints" => (T.KW_joints);
53 :     <INITIAL> "mesh" => (T.KW_mesh);
54 :     <INITIAL> "tri" => (T.KW_tri);
55 :     <INITIAL> "weight" => (T.KW_weight);
56 :     <INITIAL> "numtris" => (T.KW_numtris);
57 :     <INITIAL> "numverts" => (T.KW_numverts);
58 :     <INITIAL> "vert" => (T.KW_vert);
59 :     <INITIAL> "numweights" => (T.KW_numweights);
60 :     <INITIAL> "shader" => (T.KW_shader);
61 :    
62 :     <INITIAL> "-"?{num}"."{num}([eE][+~]?{num})?
63 :     => (mkFloat yysubstr);
64 :    
65 :     <INITIAL> "-"?{num} => (mkInt yysubstr);
66 :    
67 :     <INITIAL> "//" => (YYBEGIN COMMENT; skip());
68 :     <COMMENT> {eol} => (YYBEGIN INITIAL; skip());
69 :     <COMMENT> . => (skip());
70 :    
71 :     <INITIAL> "\"" => (YYBEGIN STRING; continue());
72 :     <STRING> "\"" => (YYBEGIN INITIAL; mkString());
73 :     <STRING> {sgood}+ => (addStr yytext; continue());
74 :     <STRING> . => (continue());
75 :    
76 :     <INITIAL> . => (skip());

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