Skip to content

Commit 95b5d1e

Browse files
committed
Add lexing for #unspecified literal (from Z3 4.8.10)
1 parent 5b9503e commit 95b5d1e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/main/scala/smtlib/lexer/Lexer.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@ class Lexer(reader: java.io.Reader) {
123123
case 'b' => BinaryLit(readBinary())
124124
case 'x' => HexadecimalLit(readHexadecimal())
125125
case c => {
126-
throw new UnexpectedCharException(c,
127-
Position(_currentLine, _currentCol),
128-
"'#' should be followed by a radix 'b' or 'x'")
126+
val s = readSymbol(c)
127+
if (s == "unspecified")
128+
SymbolLit("#unspecified")
129+
else
130+
throw new UnexpectedCharException(c,
131+
Position(_currentLine, _currentCol),
132+
"'#' should be followed by a radix 'b' or 'x', or by 'unspecified'")
129133
}
130134
}
131135
}

src/main/scala/smtlib/lexer/Tokens.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ object Tokens {
3636
case class HexadecimalLit(content: Hexadecimal) extends Token(HexadecimalLitKind) {
3737
override def toString = content.toString
3838
}
39-
4039
sealed trait TokenKind
4140

4241
case object OParen extends TokenKind /* ( */

src/main/scala/smtlib/parser/ParserCommon.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ trait ParserCommon {
7474
check(token, expected)
7575
token
7676
}
77+
7778
/*
7879
* Make sure the next token is exactly ``expected`` (usually a symbol lit)
7980
*/
@@ -342,8 +343,8 @@ trait ParserCommon {
342343
case Tokens.StringLitKind => parseString
343344
case Tokens.KeywordKind => parseKeyword
344345
case Tokens.OParen => parseSList
345-
case kind =>
346-
expected(peekToken,
346+
case kind =>
347+
expected(peekToken,
347348
Tokens.SymbolLitKind, Tokens.NumeralLitKind, Tokens.BinaryLitKind,
348349
Tokens.HexadecimalLitKind, Tokens.DecimalLitKind, Tokens.StringLitKind,
349350
Tokens.KeywordKind, Tokens.OParen)

0 commit comments

Comments
 (0)