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
- Alphabetic
- By Inheritance
- Lexer
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Lexer(rd: Reader)
- rd
the reader from which characters are read.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Lexer, B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
MalformedInputif the current tokentokenis not a delimiter, or consists of a character different fromc.
-
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
MalformedInputif the two tokens do not match.
-
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
MalformedInputif character does not match
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
var
ch: Char
The last-read character
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def ensuring(cond: (Lexer) ⇒ Boolean, msg: ⇒ Any): Lexer
- def ensuring(cond: (Lexer) ⇒ Boolean): Lexer
- def ensuring(cond: Boolean, msg: ⇒ Any): Lexer
- def ensuring(cond: Boolean): Lexer
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
error(msg: String): Nothing
Always throws a
MalformedInputexception with given error message.Always throws a
MalformedInputexception with given error message.- msg
the error message
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getNumber(): Unit
Reads a numeric literal, and forms an
IntLitorFloatLittoken from it.Reads a numeric literal, and forms an
IntLitorFloatLittoken from it. Last-read input characterchmust be either-or a digit.- Exceptions thrown
MalformedInputif lexeme not recognized as a numeric literal.
-
def
getString(): Unit
Reads a string literal, and forms a
StringLittoken from it.Reads a string literal, and forms a
StringLittoken from it. Last-read input characterchmust be opening"-quote.- Exceptions thrown
MalformedInputif lexeme not recognized as a string literal.
-
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
-
def
nextChar(): Unit
Reads next character into
ch -
def
nextToken(): Unit
Skips whitespace and reads next lexeme into
tokenSkips whitespace and reads next lexeme into
token- Exceptions thrown
MalformedInputif lexeme not recognized as a valid token
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
var
pos: Long
The number of characters read so far
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
var
token: Token
The last-read token
-
var
tokenPos: Long
The number of characters read before the start of the last-read token
-
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
- @throws( ... ) @native()
- def →[B](y: B): (Lexer, B)
Deprecated Value Members
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Lexer to StringFormat[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 ofvalue.formatted(formatString), or use thef""string interpolator. In Java 15 and later,formattedresolves to the new method in String which has reversed parameters.
The Scala compiler and reflection APIs.