alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (WordExp.scala)

This example Scala source code file (WordExp.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

base, base, label, label, letter, regexp, regexp, wildcard, wordexp, wordexp

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
  }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala WordExp.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.