Skip to content

Commit

Permalink
Pull checkCode inside managler
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 authored and sgraf812 committed Sep 20, 2024
1 parent 52a2cb2 commit eb90467
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/frontend/src/Happy/Frontend/Mangler.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,23 @@ This bit is a real mess, mainly because of the error message support.
> | null errs = Right (gd, mAg, ps)
> | otherwise = Left errs
> where mAg = getAttributeGrammarExtras dirs
> ((gd, ps), errs) = runWriter (manglerM (checkCode mAg) file abssyn)
> ((gd, ps), errs) = runWriter (manglerM checkCode file abssyn)

If any attribute directives were used, we are in an attribute grammar, so
go do special processing. If not, pass on to the regular processing routine

> checkCode :: CodeChecker
> checkCode = case mAg of
> Nothing -> \lhs _ code ->
> doCheckCode (length lhs) code
> Just a -> \lhs nonterm_names code ->
> rewriteAttributeGrammar lhs nonterm_names code a

> -- | Function to check elimination rules
> type CodeChecker = [Name] -> [Name] -> String -> M (String,[Int])

> manglerM
> :: ([Name] -> [Name] -> String -> M (String,[Int]))
> -- ^ Function to check elimination rules
> :: CodeChecker
> -> FilePath
> -> AbsSyn
> -> M (Grammar, Pragmas)
Expand Down Expand Up @@ -280,14 +292,6 @@ So is this.

> checkRules [] _ nonterms = return (reverse nonterms)

-----------------------------------------------------------------------------
-- If any attribute directives were used, we are in an attribute grammar, so
-- go do special processing. If not, pass on to the regular processing routine

> checkCode :: Maybe AttributeGrammarExtras -> [Name] -> [Name] -> String -> M (String,[Int])
> checkCode Nothing lhs _ code = doCheckCode (length lhs) code
> checkCode (Just a) lhs nonterm_names code = rewriteAttributeGrammar lhs nonterm_names code a

-----------------------------------------------------------------------------
-- Check for every $i that i is <= the arity of the rule.
Expand Down

0 comments on commit eb90467

Please sign in to comment.