Scala Compiler2.13.17 < Back


# Packages

-  package root

  The Scala compiler and reflection APIs.

  The Scala compiler and reflection APIs.

  Definition Classes
    root
-  package scala
  Definition Classes
    root
-  package tools
  Definition Classes
    scala
-  package nsc
  Definition Classes
    tools
-  package interactive
  Definition Classes
    nsc
-  package tests
  Definition Classes
    interactive
- CancelException
- CommentPreservingTypers
- CompilerControl
- CondPickler
- ContextTrees
- FreshRunReq
- Global
- InteractiveAnalyzer
- InteractiveReporter
- Lexer
- LogReplay
- Logger
- Main
- MissingResponse
- NoSuchUnitError
- NullLogger
- Pickler
- Picklers
- PresentationCompilerThread
- PrettyWriter
- Problem
- REPL
- RangePositions
- Replayer
- Response
- RichCompilationUnits
- ShutdownReq

c

scala.tools.nsc.interactive

# Lexer

###
Companion object Lexer

#### class Lexer extends AnyRef

A simple lexer for tokens as they are used in JSON, plus parens `(`, `)` Tokens understood are:

`(`, `)`, `[`, `]`, `{`, `}`, `:`, `,`, `true`, `false`, `null`, strings (syntax as in JSON), integer numbers (syntax as in JSON: -?(0|\d+) floating point numbers (syntax as in JSON: -?(0|\d+)(\.\d+)?((e|E)(+|-)?\d+)?) The end of input is represented as its own token, EOF. Lexers can keep one token lookahead

Source
  Lexer.scala

Linear Supertypes
AnyRef, Any
Type Hierarchy

Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. Lexer
2. AnyRef
3. Any

Implicitly

1. by any2stringadd
2. by StringFormat
3. by Ensuring
4. by ArrowAssoc

1. Hide All
2. Show All

Visibility

1. Public
2. Protected

### Instance Constructors

1.  new Lexer(rd: Reader)

   rd

     the reader from which characters are read.

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##: Int
   Definition Classes
     AnyRef → Any
3.  def +(other: String): String
   Implicit
     This member is added by an implicit conversion from Lexer toany2stringadd[Lexer] performed by method any2stringadd in scala.Predef.
   Definition Classes
     any2stringadd
4.  def ->[B](y: B): (Lexer, B)
   Implicit
     This member is added by an implicit conversion from Lexer toArrowAssoc[Lexer] performed by method ArrowAssoc in scala.Predef.
   Definition Classes
     ArrowAssoc
   Annotations
     @inline()
5.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
6.  def accept(ch: Char): Unit

   The current token is a delimiter consisting of given character, reads next token, otherwise raises an error.

   The current token is a delimiter consisting of given character, reads next token, otherwise raises an error.

   ch

     the given delimiter character to compare current token with

   Exceptions thrown

     `Lexer.MalformedInput` if the current token `token` is not a delimiter, or consists of a character different from `c`.

7.  def accept(t: Token): Unit

   If current token equals given token, reads next token, otherwise raises an error.

   If current token equals given token, reads next token, otherwise raises an error.

   t

     the given token to compare current token with

   Exceptions thrown

     `Lexer.MalformedInput` if the two tokens do not match.

8.  def acceptChar(c: Char): Unit

   If last-read character equals given character, reads next character, otherwise raises an error

   If last-read character equals given character, reads next character, otherwise raises an error

   c

     the given character to compare with last-read character

   Exceptions thrown

     `Lexer.MalformedInput` if character does not match

9.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
10.  var ch: Char

    The last-read character

11.  def clone(): AnyRef
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.CloneNotSupportedException]) @native()
12.  def ensuring(cond: (Lexer) => Boolean, msg: => Any): Lexer
    Implicit
      This member is added by an implicit conversion from Lexer toEnsuring[Lexer] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
13.  def ensuring(cond: (Lexer) => Boolean): Lexer
    Implicit
      This member is added by an implicit conversion from Lexer toEnsuring[Lexer] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
14.  def ensuring(cond: Boolean, msg: => Any): Lexer
    Implicit
      This member is added by an implicit conversion from Lexer toEnsuring[Lexer] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
15.  def ensuring(cond: Boolean): Lexer
    Implicit
      This member is added by an implicit conversion from Lexer toEnsuring[Lexer] performed by method Ensuring in scala.Predef.
    Definition Classes
      Ensuring
16.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
17.  def equals(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef → Any
18.  def error(msg: String): Nothing

    Always throws a Lexer.MalformedInput exception with given error message.

    Always throws a Lexer.MalformedInput exception with given error message.

    msg

      the error message

19.  def finalize(): Unit
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.Throwable])
20.  final def getClass(): Class[_ <: AnyRef]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
21.  def getNumber(): Unit

    Reads a numeric literal, and forms an `IntLit` or `FloatLit` token from it.

    Reads a numeric literal, and forms an `IntLit` or `FloatLit` token from it. Last-read input character `ch` must be either `-` or a digit.

    Exceptions thrown

      `Lexer.MalformedInput` if lexeme not recognized as a numeric literal.

22.  def getString(): Unit

    Reads a string literal, and forms a `StringLit` token from it.

    Reads a string literal, and forms a `StringLit` token from it. Last-read input character `ch` must be opening `"`-quote.

    Exceptions thrown

      `Lexer.MalformedInput` if lexeme not recognized as a string literal.

23.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
24.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
25.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
26.  def nextChar(): Unit

    Reads next character into `ch`

27.  def nextToken(): Unit

    Skips whitespace and reads next lexeme into `token`

    Skips whitespace and reads next lexeme into `token`

    Exceptions thrown

      `Lexer.MalformedInput` if lexeme not recognized as a valid token

28.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
29.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
30.  var pos: Long

    The number of characters read so far

31.  final def synchronized[T0](arg0: => T0): T0
    Definition Classes
      AnyRef
32.  def toString(): String
    Definition Classes
      AnyRef → Any
33.  var token: Token

    The last-read token

34.  var tokenPos: Long

    The number of characters read before the start of the last-read token

35.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
36.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
37.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException]) @native()

### Deprecated Value Members

1.  def formatted(fmtstr: String): String
   Implicit
     This member is added by an implicit conversion from Lexer toStringFormat[Lexer] performed by method StringFormat in scala.Predef.
   Definition Classes
     StringFormat
   Annotations
     @deprecated @inline()
   Deprecated

     (Since version 2.12.16) Use `formatString.format(value)` instead of `value.formatted(formatString)`, or use the `f""` string interpolator. In Java 15 and later, `formatted` resolves to the new method in String which has reversed parameters.

2.  def →[B](y: B): (Lexer, B)
   Implicit
     This member is added by an implicit conversion from Lexer toArrowAssoc[Lexer] performed by method ArrowAssoc in scala.Predef.
   Definition Classes
     ArrowAssoc
   Annotations
     @deprecated
   Deprecated

     (Since version 2.13.0) Use `->` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

### Inherited from AnyRef

### Inherited from Any

### Inherited by implicit conversion any2stringadd fromLexer to any2stringadd[Lexer]

### Inherited by implicit conversion StringFormat fromLexer to StringFormat[Lexer]

### Inherited by implicit conversion Ensuring fromLexer to Ensuring[Lexer]

### Inherited by implicit conversion ArrowAssoc fromLexer to ArrowAssoc[Lexer]

### Ungrouped