aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-11-05 20:34:44 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-11-05 20:47:24 -0500
commitbbd23dc8051e3de7e97bc36fe76098572383e1fb (patch)
tree17f731f39b0bfba4fdb46f3e6c6e458739a0c7a3 /src
parent723f0863d62a2ee9fcf6da65aef3b0b4d679eedd (diff)
Fix token index for the newline after a comment (and crash when there was none)
Diffstat (limited to 'src')
-rw-r--r--src/c.bqn3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/c.bqn b/src/c.bqn
index 3e6718f3..518d172b 100644
--- a/src/c.bqn
+++ b/src/c.bqn
@@ -51,7 +51,8 @@ Tokenize←{
str←1↓¨𝕩⊔˜1-˜(+`si←a>»qe)×≠`dm∧ab # Strings (indices /si)
# Extract words: identifiers and numbers
- is←/1»f⋄ie←/f⋄Fs←{is/˜↩𝕨⋄𝕨/𝕩} # Token start and end
+ ie←/f⋄is←ie≠⊸↑/1»f⋄Fs←{is/˜↩𝕨⋄𝕨/𝕩} # Token start and end
+ is-↩is(-×⊏⟜c)ie # Comment → ending newline only
t←CharCode ie⊏𝕩
w←»⊸<l←t M bD(⊣≍-˜)○⊑bW⋄us←t=¯1++´bA # Word chars l, start w
wk←na⌊∘÷˜(⊑bA)-˜w/t # Kind of word from first char