Skip to content

Commit

Permalink
Rename FastInt to Happy_Int to avoid name clashes with user code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kariiem committed Jun 22, 2024
1 parent 3d5a060 commit 6c3719d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
20 changes: 10 additions & 10 deletions packages/backend-lalr/data/HappyTemplate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#define TIMES(n,m) (n Happy_GHC_Exts.*# m)
#define NEGATE(n) (Happy_GHC_Exts.negateInt# (n))

type FastInt = Happy_GHC_Exts.Int#
data Happy_IntList = HappyCons FastInt Happy_IntList
type Happy_Int = Happy_GHC_Exts.Int#
data Happy_IntList = HappyCons Happy_Int Happy_IntList

#define ERROR_TOK 0#

Expand Down Expand Up @@ -74,20 +74,20 @@ happyDoAction i tk st
happyFail (happyExpListPerState ((Happy_GHC_Exts.I# st) :: Prelude.Int)) i tk st
-1# -> DEBUG_TRACE("accept.\n")
happyAccept i tk st
n | LT(n,(0# :: FastInt)) -> DEBUG_TRACE("reduce (rule " ++ show rule
n | LT(n,(0# :: Happy_Int)) -> DEBUG_TRACE("reduce (rule " ++ show rule
++ ")")
(happyReduceArr Happy_Data_Array.! rule) i tk st
where
rule = Happy_GHC_Exts.I# (NEGATE(PLUS(n,(1# :: FastInt))))
rule = Happy_GHC_Exts.I# (NEGATE(PLUS(n,(1# :: Happy_Int))))

n -> DEBUG_TRACE("shift, enter state "
++ show (Happy_GHC_Exts.I# new_state)
++ "\n")
happyShift new_state i tk st
where new_state = MINUS(n,(1# :: FastInt))
where new_state = MINUS(n,(1# :: Happy_Int))
where off = happyAdjustOffset (indexShortOffAddr happyActOffsets st)
off_i = PLUS(off, i)
check = if GTE(off_i,(0# :: FastInt))
check = if GTE(off_i,(0# :: Happy_Int))
then EQ(indexShortOffAddr happyCheck off_i, i)
else Prelude.False
action
Expand Down Expand Up @@ -155,7 +155,7 @@ happySpecReduce_3 nt fn j tk _
happyReduce k i fn ERROR_TOK tk st sts stk
= happyFail [] ERROR_TOK tk st sts stk
happyReduce k nt fn j tk st sts stk
= case happyDrop MINUS(k,(1# :: FastInt)) sts of
= case happyDrop MINUS(k,(1# :: Happy_Int)) sts of
sts1@(HappyCons st1 _) ->
let r = fn stk in -- it doesn't hurt to always seq here...
happyDoSeq r (happyGoto nt j tk st1 sts1 r)
Expand Down Expand Up @@ -183,10 +183,10 @@ happyMonad2Reduce k nt fn j tk st sts stk =
(\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk))

happyDrop 0# l = l
happyDrop n (HappyCons _ t) = happyDrop MINUS(n,(1# :: FastInt)) t
happyDrop n (HappyCons _ t) = happyDrop MINUS(n,(1# :: Happy_Int)) t

happyDropStk 0# l = l
happyDropStk n (x `HappyStk` xs) = happyDropStk MINUS(n,(1#::FastInt)) xs
happyDropStk n (x `HappyStk` xs) = happyDropStk MINUS(n,(1#::Happy_Int)) xs

-----------------------------------------------------------------------------
-- Moving to a new state after a reduction
Expand Down Expand Up @@ -232,7 +232,7 @@ notHappyAtAll = Prelude.error "Internal Happy error\n"
-----------------------------------------------------------------------------
-- Hack to get the typechecker to accept our action functions

happyTcHack :: FastInt -> a -> a
happyTcHack :: Happy_Int -> a -> a
happyTcHack x y = y
{-# INLINE happyTcHack #-}

Expand Down
8 changes: 1 addition & 7 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,12 @@ TEST_HAPPY_OPTS = --strict
%.n.hs : %.ly
$(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@

%.c.hs : %.ly
$(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@

%.n.hs : %.y
$(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@

%.c.hs : %.y
$(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@

CLEAN_FILES += *.n.hs *.c.hs *.info *.hi *.bin *.exe *.o *.run.stdout *.run.stderr

ALL_TEST_HS = $(shell echo $(TESTS) | sed -e 's/\([^\. ]*\)\.\(l\)\{0,1\}y/\1.n.hs \1.c.hs/g')
ALL_TEST_HS = $(shell echo $(TESTS) | sed -e 's/\([^\. ]*\)\.\(l\)\{0,1\}y/\1.n.hs /g')

ALL_TESTS = $(patsubst %.hs, %.run, $(ALL_TEST_HS))

Expand Down

0 comments on commit 6c3719d

Please sign in to comment.