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

SCM Repository

[diderot] Annotation of /branches/charisee/src/compiler/gen/opt/rules.lex
ViewVC logotype

Annotation of /branches/charisee/src/compiler/gen/opt/rules.lex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2377 - (view) (download)

1 : jhr 1484 (* rules.lex
2 :     *
3 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     %name RulesLex;
8 :    
9 :     %arg (lexErr);
10 :    
11 :     %let digit = [0-9];
12 :     %let int = {digit}+;
13 :     %let alpha=[A-Za-z];
14 :     %let id={alpha}({alpha} |{digit}|"-")*;
15 :     %let ws=[ \t |\n];
16 :     %let eol="\n"; (*Just added for comments section*)
17 :    
18 :     %states INITIAL STRING COM1 COM2;
19 :    
20 :     %defs(
21 :     structure T = RulesTokens
22 :     type lex_result = T.token
23 :     fun mkOP s = T.OPER(Atom.atom s);
24 :     fun eof() = T.EOF
25 :     );
26 :    
27 :     {id} => (Keywords.idToken yytext);
28 :     {ws}+ => (skip());
29 :     "(" => (T.LP);
30 :     ")" => (T.RP);
31 :     "<" => (T.LANGLE);
32 :     ">" => (T.RANGLE);
33 :     "," => (T.COMMA);
34 :     ";" => (T.SEMI);
35 :     "=>" => (T.ARROW);
36 :    
37 :    
38 :     (*
39 :     Not sure if I need this section
40 :    
41 :     <STRING>{esc} => (addStr(valOf(String.fromString yytext)); continue());
42 :     <STRING>{sgood}+ => (addStr yytext; continue());
43 :     <STRING> "\"" => (YYBEGIN INITIAL; mkString());
44 :    
45 :     <STRING> . => (lexErr(yypos, [
46 :     "bad character `", String.toString yytext,
47 :     "' in string literal"
48 :     ]);
49 :     continue());
50 :     *)
51 :    
52 :     (*Comments*)
53 :    
54 :     <INITIAL> "//" => (YYBEGIN COM1; skip());
55 :     <COM1> {eol} => (YYBEGIN INITIAL; skip());
56 :     <COM1> . =>( skip());
57 :    
58 :     <INITIAL> "/*" => (YYBEGIN COM2; skip());
59 :     <COM2> "*/" => (YYBEGIN INITIAL; skip());
60 :     <COM2> . => (skip());

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