diff tools/nclex.mll @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/nclex.mll	Thu Oct 05 08:04:15 2017 +0100
@@ -0,0 +1,27 @@
+(* nclex.mll *)
+(* Copyright (c) 2017 J. M. Spivey *)
+
+{
+open Ncparse 
+open String 
+open Lexing
+
+let line_no = ref 1
+}
+
+rule token =
+  parse
+      "<"(['A'-'Z''a'-'z']+|'('[^')']+')' as s)  { OPEN s }
+    | [^'<''>''('')'',''@'' ''\n']+ as s  { WORD s }
+    | "(*"[^'\n']*"*)" as s     { WORD s }
+    | "->" as s                 { WORD s }
+    | " "                       { SPACE }
+    | ">"                       { CLOSE }
+    | "("                       { LPAREN }
+    | ")"                       { RPAREN }
+    | ","                       { COMMA }
+    | "@"                       { ATSIGN }
+    | "\n"                      { incr line_no; CHAR '\n' }
+    | _ as c                    { CHAR c }
+    | eof                       { EOF }
+