Skip to content

improvement: allow values without quotes #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2023
Merged

improvement: allow values without quotes #46

merged 3 commits into from
Apr 25, 2023

Conversation

tgodzik
Copy link
Member

@tgodzik tgodzik commented Apr 12, 2023

Previously, string values would always require quotes since that coresponded to actual scala syntax. Now, we no longer allow using directives in normal Scala code, so we can allow values without quotes. Whenever there is a more complex value like one that requires a space, we would still require them.

Related to VirtusLab/scala-cli#1954

Additionally the values are not treated literally and can contain any special characters since we are not limited by Scala syntax.

I also changed to only allow single line, which simplified tests a bit as they were taking into account newlines in a lot of places.

@tgodzik tgodzik requested a review from szymon-rd April 12, 2023 16:27
Previously, string values would always require quotes since that coresponded to actual scala syntax. Now, we no longer allow using directives in normal Scala code, so we can allow values without quotes. Whenever there is a more complex value like one that requires a space, we would still require them.
@tgodzik tgodzik force-pushed the quoteless branch 4 times, most recently from ca532f8 to 16d5528 Compare April 13, 2023 14:59
"Expected primitive value: string, numeric or boolean but found %s. %s",
in.td.toTokenInfoString(), solution));
} else if (in.td.token == Tokens.IDENTIFIER) {
if (in.td.name.startsWith("-") && in.td.name.chars().allMatch(Character::isDigit)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure I understand. -42 begins with -, but - Is not a digit so this check will not pass?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right, it doesn't work. I wonder though should we care about numbers. I changed it for now, but it's a bit hacky to make it work. Should we maybe drop numeric values? It can be parsed later on if needed.

@tgodzik tgodzik force-pushed the quoteless branch 2 times, most recently from 362b430 to ae8c84d Compare April 24, 2023 18:18
Numeric values do not need to be treated differently than string ones and especially since it's not needed to use quotes it makes it problematic to check what is a number.

I also removed any kind of braces, parens etc. since I would need to fix the tests and they no longer make sense with this version of directives.
@tgodzik tgodzik merged commit 1fdb193 into main Apr 25, 2023
@tgodzik tgodzik deleted the quoteless branch April 25, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants