Skip to content
Snippets Groups Projects
Commit e03012cc authored by Katja Goltsova's avatar Katja Goltsova Committed by Viktor Kunčak
Browse files

Allow more characters in identifiers

parent bf419fad
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,7 @@ object Parser { ...@@ -153,6 +153,7 @@ object Parser {
// TODO: add positions ==> ranges to tokens // TODO: add positions ==> ranges to tokens
type Position = Unit type Position = Unit
private val allowedIdentifierCharacters = elem(_.isLetter) | elem(_.isDigit) | oneOf("_\\@#$%^&*><:|_+-=")
private val schematicSymbol = "'" private val schematicSymbol = "'"
private val lexer = Lexer( private val lexer = Lexer(
...@@ -174,11 +175,11 @@ object Parser { ...@@ -174,11 +175,11 @@ object Parser {
elem(';') |> SemicolonToken, elem(';') |> SemicolonToken,
elem('⊢') | word("|-") |> SequentToken, elem('⊢') | word("|-") |> SequentToken,
many1(whiteSpace) |> SpaceToken, many1(whiteSpace) |> SpaceToken,
word(schematicSymbol) ~ many1(elem(_.isLetter) | elem('_') | elem(_.isDigit) | elem('\'')) |> { cs => word(schematicSymbol) ~ many1(allowedIdentifierCharacters) |> { cs =>
// drop the ' // drop the '
SchematicToken(cs.drop(1).mkString) SchematicToken(cs.drop(1).mkString)
}, },
many1(elem(_.isLetter) | elem('_') | elem(_.isDigit)) |> { cs => ConstantToken(cs.mkString) } many1(allowedIdentifierCharacters) |> { cs => ConstantToken(cs.mkString) }
) onError { (cs, _) => ) onError { (cs, _) =>
throw ParserException(s"Unexpected input: ${cs.mkString}") throw ParserException(s"Unexpected input: ${cs.mkString}")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment