Skip to content

Commit

Permalink
Merge pull request #1773 from arturo-lang/sanitize-question-marks-in-…
Browse files Browse the repository at this point in the history
…words

Sanitize `?`s in words/labels
  • Loading branch information
drkameleon authored Oct 18, 2024
2 parents 1602bd3 + 98427ab commit 32024ce
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/vm/parse.nim
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const
Backslash = '\\'
Dash = '-'

QuestionMark = '?'

CR = '\c'
LF = '\L'
EOF = '\0'
Expand All @@ -77,7 +79,7 @@ const
Letters = {'a'..'z', 'A'..'Z'}
PermittedIdentifiers_Start = Letters + {'_'}
PermittedColorChars = Letters + Numbers
PermittedIdentifiers_In = PermittedIdentifiers_Start + Numbers + {'?'}
PermittedIdentifiers_In = PermittedIdentifiers_Start + Numbers
PermittedQuantityChars = Letters + Numbers + {'.', '/'}

SemVerExtra = Letters + PermittedNumbers_Start + {'+', '-', '.'}
Expand Down Expand Up @@ -506,6 +508,9 @@ template parseIdentifier(p: var Parser, alsoAddCurrent: bool) =
while p.buf[pos] in PermittedIdentifiers_In:
add(p.value, p.buf[pos])
inc(pos)
if p.buf[pos] == QuestionMark:
add(p.value, QuestionMark)
inc(pos)
p.bufpos = pos

template parseNumber(p: var Parser) =
Expand Down
3 changes: 3 additions & 0 deletions tests/unittests/parser.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inspect [something?anotherone????]
inspect [something?: something]
inspect ['some?thing??]
15 changes: 15 additions & 0 deletions tests/unittests/parser.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[ :block
something? :word
anotherone? :word
?? :symbol
? :symbol
]
[ :block
something? :label
something :word
]
[ :block
some? :literal
thing? :word
? :symbol
]
2 changes: 1 addition & 1 deletion version/build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3268
3271

0 comments on commit 32024ce

Please sign in to comment.