object ExprImplicits
Implicit conversions for Expr
Creates a DSL-like system, with Strings automatically converted to org.benknoble.ebnf.Terminals and Symbols converted to org.benknoble.ebnf.Nonterminal:
scala> import org.benknoble.ebnf._ import org.benknoble.ebnf._ scala> import ExprImplicits._ import ExprImplicits._ scala> val p = 'A ::= ("abc" || 'B.?) ~ 'C.* p: org.benknoble.ebnf.Production = Production(Nonterminal('A), Sequence(Alternation(Terminal(abc),Option(Nonterminal('B))),Repetition(Nonterminal('C)))) scala> val f = p.format f: String = <A> ::= ('abc'|[<B>]){<C>}
Do note that val r: Expr = "abc".*
will not work, due to ambiguity:
scala> val r: Expr = "abc".* <console>:17: error: type mismatch; found : String("abc") required: ?{def *: ?} Note that implicit conversions are not applicable because they are ambiguous: both method augmentString in object Predef of type (x: String)scala.collection.immutable.StringOps and method charToTerminal in object ExprImplicits of type (s: String)org.benknoble.ebnf.Terminal are possible conversion functions from String("abc") to ?{def *: ?} val r: Expr = "abc".* ^ <console>:17: error: value * is not a member of String val r: Expr = "abc".* ^
- Alphabetic
- By Inheritance
- ExprImplicits
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- implicit def charToTerminal(s: String): Terminal
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- implicit def symbolToNonterminal(s: Symbol): Nonterminal
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )