de.uni_luebeck.isp.compacom.SimpleTokens

SimpleTokenizer

Related Doc: package SimpleTokens

abstract class SimpleTokenizer extends AbstractTokenizer

Implement a tokenizer by simply providing a list of keywords, symbols and comment delimiters.

Anything that matches an item in one of the lists is tokenized accordingly. Any sequence of alphanumeric characters starting with a letter or underscore is tokenized as an identifier if it is not a keyword. A sequence of digits is tokenized as an integer. A sequence of characters starting with a quote and ending with a quote is tokenized as a string. Anything else is an invalid token.

This is the easiest, but least flexible way to define a tokenizer. However it should be sufficient for many cases.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. SimpleTokenizer
  2. AbstractTokenizer
  3. Tokenizer
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SimpleTokenizer(s: Source)

Abstract Value Members

  1. abstract val comments: List[(String, String)]

    A list of start-end pairs.

    A list of start-end pairs. Anything between the start string and the end string will be ignored. Comments are not recursive. Comments are automatically closed at the end of file.

    As comments are checked before anything else, the starting string of a comment must not be the prefix of any other valid token (or else that token will never be matched).

    Example:

    val comments = List("//" -> "\n", "/*" -> "*/")
  2. abstract val keywords: List[SimpleTokens.Token]

    A list of tokens that fit the rules for being identifiers, but should be tokenized as - * something else instead

  3. abstract val symbols: List[SimpleTokens.Token]

    A list of tokens that aren't integers, strings, comments, spaces or identifiers and don't overlap with either.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def consume(): Option[Char]

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  7. def consume(n: Int): Unit

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  8. def consumeString(str: String): Boolean

    If the next characters in the input stream are equal to the given string, consume them and return true.

    If the next characters in the input stream are equal to the given string, consume them and return true. Otherwise return false.

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  9. def consumeWhile(p: (Char) ⇒ Boolean): String

    Same as de.uni_luebeck.isp.compacom.Tokens.AbstractTokenizer.peekWhile, but consume the characters.

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  10. def current: SimpleTokens.Token

    Definition Classes
    AbstractTokenizerTokenizer
  11. var currentCol: Int

    Definition Classes
    AbstractTokenizer
  12. var currentLine: Int

    Definition Classes
    AbstractTokenizer
  13. var currentLocation: Location

    The location of the current token

    The location of the current token

    Definition Classes
    AbstractTokenizerTokenizer
  14. var currentToken: SimpleTokens.Token

    Definition Classes
    AbstractTokenizer
  15. var currentTokenParser: () ⇒ SimpleTokens.Token

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  16. def currentWithLocation: WithLocation[SimpleTokens.Token]

    The location and value of the current token

    The location and value of the current token

    Definition Classes
    Tokenizer
  17. def defaultTokenParser(): SimpleTokens.Token

    Definition Classes
    SimpleTokenizerAbstractTokenizer
  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  22. def hasNext: Boolean

    Definition Classes
    AbstractTokenizer
  23. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  24. var idx: Int

    Definition Classes
    AbstractTokenizer
  25. def index: Int

    The index of the current token (a.k.a.

    The index of the current token (a.k.a. the number of tokens previously read). This is used to determine whether a parser rule consumed more than one token, which is necessary when determining whether to ask the second rule for completions when evaluating alternatives (see definition of Parsers.|).

    Definition Classes
    AbstractTokenizerTokenizer
  26. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  27. val lookaheadBuffer: Queue[Option[Char]]

    Definition Classes
    AbstractTokenizer
  28. def moveNext(includeIgnored: Boolean = false): Unit

    Definition Classes
    AbstractTokenizerTokenizer
  29. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  32. def oneOf(tokens: Iterable[SimpleTokens.Token]): Option[SimpleTokens.Token]

    Return a Some containing the first of the given token that matches the current input or None if none do.

    Return a Some containing the first of the given token that matches the current input or None if none do.

    If a match is found, the tokenizer is advanced to after the match. Otherwise the tokenizer does not move.

    This method can be used to easily match all symbolic tokens in one swoop. It can not be used to match alphanumeric keywords as you wouldn't want to match "def" when the input is "definitely".

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  33. def peek(n: Int = 0): Option[Char]

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  34. def peekStream: Stream[Char]

    A stream containing the characters returned by peek(0) onwards.

    A stream containing the characters returned by peek(0) onwards.

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  35. def peekString(length: Int): String

    Return a string containing the next length characters without consuming any.

    Return a string containing the next length characters without consuming any.

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  36. def peekWhile(p: (Char) ⇒ Boolean): String

    Return a string containing all the characters in the input until the first that does not meet the predicate without consuming any.

    Return a string containing all the characters in the input until the first that does not meet the predicate without consuming any.

    Attributes
    protected
    Definition Classes
    AbstractTokenizer
  37. var previousPosition: Position

    The end position of the previous token, that is the position that the input stream was at before the current token was matched.

    The end position of the previous token, that is the position that the input stream was at before the current token was matched. The area from this position to the starting position of the current location should contain exactly the characters that were discarded between the previous token and the current one.

    Definition Classes
    AbstractTokenizerTokenizer
  38. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  39. def toString(): String

    Definition Classes
    AnyRef → Any
  40. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from SimpleTokens.Tokenizer

Inherited from AnyRef

Inherited from Any

Ungrouped