|
Scala example source code file (WordExp.scala)
The Scala WordExp.scala source code/* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ package scala.util.regexp /** <p> * The class <code>WordExp provides regular word expressions. * Users have to instantiate type member <code>_regexpT <: RegExp * (from class <code>Base) and a type member * <code>_labelT <: Label. Here is a short example: * </p>* <b>import scala.util.regexp._ * <b>import scala.util.automata._ * <b>object MyLang extends WordExp { * <b>type _regexpT = RegExp * <b>type _labelT = MyChar * * <b>case class MyChar(c:Char) extends Label * } * <b>import MyLang._ * // (a* | b)* * <b>val rex = Star(Alt(Star(Letter(MyChar('a'))),Letter(MyChar('b')))) * <b>object MyBerriSethi extends WordBerrySethi { * <b>override val lang = MyLang * } * <b>val nfa = MyBerriSethi.automatonFrom(Sequ(rex), 1) * </pre> * * @author Burak Emir * @version 1.0 */ abstract class WordExp extends Base { abstract class Label type _regexpT <: RegExp type _labelT <: Label case class Letter(a: _labelT) extends RegExp { final lazy val isNullable = false var pos = -1 } case class Wildcard() extends RegExp { final lazy val isNullable = false var pos = -1 } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.