Domains example
[hcoop/domtool2.git] / src / domtool.lex
index 765a6ab..6bf3475 100644 (file)
@@ -54,7 +54,7 @@ val strStart = ref 0
 %%
 %header (functor DomtoolLexFn(structure Tokens : Domtool_TOKENS));
 %full
-%s COMMENT STRING;
+%s COMMENT STRING DOC;
 
 id = [a-z_][A-Za-z0-9_]*;
 cid = [A-Z][A-Za-z0-9_]*;
@@ -92,6 +92,14 @@ lineComment = #[^\n]*\n;
                          str := #"\n" :: !str; continue());
 <STRING> .            => (str := String.sub (yytext, 0) :: !str; continue());
 
+<INITIAL> "{{"        => (YYBEGIN DOC; strStart := yypos; str := []; continue());
+<DOC> "}}"            => (YYBEGIN INITIAL;
+                         Tokens.DOC (String.implode (List.rev (!str)), !strStart, yypos + 1));
+<DOC> "\n"            => (lineNum := !lineNum + 1;
+                         linePos := yypos :: ! linePos;
+                         str := #"\n" :: !str; continue());
+<DOC> .               => (str := String.sub (yytext, 0) :: !str; continue());
+
 <INITIAL> "("         => (Tokens.LPAREN (yypos, yypos + size yytext));
 <INITIAL> ")"         => (Tokens.RPAREN (yypos, yypos + size yytext));
 
@@ -103,6 +111,7 @@ lineComment = #[^\n]*\n;
 
 <INITIAL> "->"        => (Tokens.ARROW (yypos, yypos + size yytext));
 <INITIAL> "=>"        => (Tokens.DARROW (yypos, yypos + size yytext));
+<INITIAL> "<-"        => (Tokens.LARROW (yypos, yypos + size yytext));
 
 <INITIAL> "="         => (Tokens.EQ (yypos, yypos + size yytext));
 <INITIAL> ","         => (Tokens.COMMA (yypos, yypos + size yytext));
@@ -116,6 +125,12 @@ lineComment = #[^\n]*\n;
 <INITIAL> "let"       => (Tokens.LET (yypos, yypos + size yytext));
 <INITIAL> "in"        => (Tokens.IN (yypos, yypos + size yytext));
 <INITIAL> "end"       => (Tokens.END (yypos, yypos + size yytext));
+<INITIAL> "with"      => (Tokens.WITH (yypos, yypos + size yytext));
+<INITIAL> "where"     => (Tokens.WHERE (yypos, yypos + size yytext));
+
+<INITIAL> "extern"    => (Tokens.EXTERN (yypos, yypos + size yytext));
+<INITIAL> "type"      => (Tokens.TYPE (yypos, yypos + size yytext));
+<INITIAL> "val"       => (Tokens.VAL (yypos, yypos + size yytext));
 
 <INITIAL> "Root"      => (Tokens.ROOT (yypos, yypos + size yytext));