Skip to content

Commit 134b568

Browse files
authored
Merge pull request #166 from hsyl20/hsyl20/support_900
Add support for sized primitives
2 parents 069ce97 + 6e2ae91 commit 134b568

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

alex.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: >= 1.8
22
name: alex
3-
version: 3.2.6
3+
version: 3.2.7
44
-- don't forget updating changelog.md!
55
license: BSD3
66
license-file: LICENSE

stack.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
resolver: lts-9.6
1+
resolver: lts-16.14
22
packages:
33
- .
4+
- ./gen-alex-sdist/
45

templates/GenericTemplate.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define ALEX_IF_GHC_GT_500 #if __GLASGOW_HASKELL__ > 500
1313
#define ALEX_IF_GHC_LT_503 #if __GLASGOW_HASKELL__ < 503
1414
#define ALEX_IF_GHC_GT_706 #if __GLASGOW_HASKELL__ > 706
15+
#define ALEX_IF_GHC_GT_901 #if __GLASGOW_HASKELL__ > 901
1516
#define ALEX_ELIF_GHC_500 #elif __GLASGOW_HASKELL__ == 500
1617
#define ALEX_IF_BIGENDIAN #ifdef WORDS_BIGENDIAN
1718
#define ALEX_ELSE #else
@@ -163,13 +164,23 @@ alex_scan_tkn user__ orig_input len input__ s last_acc =
163164
#endif
164165
case fromIntegral c of { IBOX(ord_c) ->
165166
let
167+
ALEX_IF_GHC_GT_901
168+
base = int32ToInt# (alexIndexInt32OffAddr alex_base s)
169+
offset = PLUS(base,ord_c)
170+
check = int16ToInt# (alexIndexInt16OffAddr alex_check offset)
171+
172+
new_s = if GTE(offset,ILIT(0)) && EQ(check,ord_c)
173+
then int16ToInt# (alexIndexInt16OffAddr alex_table offset)
174+
else int16ToInt# (alexIndexInt16OffAddr alex_deflt s)
175+
ALEX_ELSE
166176
base = alexIndexInt32OffAddr alex_base s
167177
offset = PLUS(base,ord_c)
168178
check = alexIndexInt16OffAddr alex_check offset
169179

170180
new_s = if GTE(offset,ILIT(0)) && EQ(check,ord_c)
171181
then alexIndexInt16OffAddr alex_table offset
172182
else alexIndexInt16OffAddr alex_deflt s
183+
ALEX_ENDIF
173184
in
174185
case new_s of
175186
ILIT(-1) -> (new_acc, input__)

0 commit comments

Comments
 (0)