updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Wed, 21 Oct 2020 16:09:44 +0100
changeset 787 4b2496bc79b2
parent 786 da2488db453e
child 788 3b1136fb6bee
updated
progs/lexer/lex.sc
--- a/progs/lexer/lex.sc	Wed Oct 21 14:55:20 2020 +0100
+++ b/progs/lexer/lex.sc	Wed Oct 21 16:09:44 2020 +0100
@@ -11,7 +11,7 @@
 case class SEQ(r1: Rexp, r2: Rexp) extends Rexp 
 case class STAR(r: Rexp) extends Rexp 
 case class RECD(x: String, r: Rexp) extends Rexp  
-                // records for extracting strings or tokens
+          // records for extracting strings or tokens
   
 // values  
 abstract class Val
@@ -33,6 +33,8 @@
 implicit def string2rexp(s : String) : Rexp = 
   charlist2rexp(s.toList)
 
+val HELLO : Rexp = "hello"
+
 implicit def RexpOps(r: Rexp) = new {
   def | (s: Rexp) = ALT(r, s)
   def % = STAR(r)
@@ -48,6 +50,8 @@
   def $ (r: Rexp) = RECD(s, r)
 }
 
+val TEST = ("ab" | "ba").%
+
 def nullable(r: Rexp) : Boolean = r match {
   case ZERO => false
   case ONE => true
@@ -149,8 +153,8 @@
 val SEMI: Rexp = ";"
 val OP: Rexp = ":=" | "=" | "-" | "+" | "*" | "!=" | "<" | ">"
 val WHITESPACE = PLUS(" " | "\n" | "\t")
-val RPAREN: Rexp = "{"
-val LPAREN: Rexp = "}"
+val RPAREN: Rexp = "}"
+val LPAREN: Rexp = "{"
 val STRING: Rexp = "\"" ~ SYM.% ~ "\""