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

SCM Repository

[diderot] View of /trunk/src/compiler/gen/opt/rules.lex
ViewVC logotype

View of /trunk/src/compiler/gen/opt/rules.lex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1484 - (download) (annotate)
Sun Sep 4 14:35:20 2011 UTC (9 years ago) by jhr
File size: 1342 byte(s)
  Created a compiler/gen directory to hold code for the generation tools.  Moved
  compiler/IL/gen to compiler/gen/il and created compiler/gen/opt for Charisee's tool.
(* rules.lex
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

%name RulesLex;

%arg (lexErr);

%let digit = [0-9];
%let int = {digit}+;
%let alpha=[A-Za-z];
%let id={alpha}({alpha} |{digit}|"-")*;
%let ws=[ \t |\n];
%let eol="\n";  (*Just added for comments section*)

%states INITIAL STRING COM1 COM2;

%defs(
  structure T = RulesTokens
  type lex_result = T.token
  fun mkOP s = T.OPER(Atom.atom s);
  fun eof() = T.EOF
);

{id}        => (Keywords.idToken yytext);
{ws}+       => (skip());
"("         => (T.LP);
")"         => (T.RP);
"<"         => (T.LANGLE);
">"         => (T.RANGLE);
","         => (T.COMMA);
";"         => (T.SEMI);
"=>"        => (T.ARROW);


(*
Not sure if I need this section 

<STRING>{esc}		=> (addStr(valOf(String.fromString yytext)); continue());
<STRING>{sgood}+	=> (addStr yytext; continue());
<STRING> "\""		=> (YYBEGIN INITIAL; mkString());

<STRING> .		=> (lexErr(yypos, [
				"bad character `", String.toString yytext,
				"' in string literal"
			      ]);
			    continue());
*)

(*Comments*)

<INITIAL> "//"  => (YYBEGIN COM1; skip());
<COM1> {eol}    => (YYBEGIN INITIAL; skip());
<COM1> .        =>( skip());

<INITIAL> "/*"  => (YYBEGIN COM2; skip());
<COM2>    "*/"  => (YYBEGIN INITIAL; skip());
<COM2>     .    => (skip());

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