Skip to content

Commit

Permalink
Fix remaining failures
Browse files Browse the repository at this point in the history
  • Loading branch information
decioferreira committed Sep 24, 2024
1 parent 524c06f commit 4d816a9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
4 changes: 2 additions & 2 deletions elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"dependencies": {
"andre-dietrich/parser-combinators": "4.1.0 <= v < 5.0.0",
"elm/core": "1.0.0 <= v < 2.0.0",
"pilatch/flip": "1.0.0 <= v < 2.0.0",
"rtfeldman/elm-hex": "1.0.0 <= v < 2.0.0"
"fredcy/elm-parseint": "2.0.1 <= v < 3.0.0",
"pilatch/flip": "1.0.0 <= v < 2.0.0"
},
"test-dependencies": {
"elm-explorations/test": "2.2.0 <= v < 3.0.0"
Expand Down
1 change: 1 addition & 0 deletions review/src/ReviewConfig.elm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ config =
{ document = onlyExposed
, from = exposedModules
}
|> Rule.ignoreErrorsForFiles [ "src/Language/GLSL/Syntax.elm" ]
, Docs.ReviewLinksAndSections.rule
, Docs.ReviewAtDocs.rule
, Docs.UpToDateReadmeLinks.rule
Expand Down
46 changes: 31 additions & 15 deletions src/Language/GLSL/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Haskell parser into the Elm ecosystem.
import Combine
import Combine.Char
import Flip exposing (flip)
import Hex
import Language.GLSL.Syntax
exposing
( CaseLabel(..)
Expand Down Expand Up @@ -49,6 +48,7 @@ import Language.GLSL.Syntax
, TypeSpecifierNoPrecision(..)
, TypeSpecifierNonArray(..)
)
import ParseInt


try : P a -> P a
Expand Down Expand Up @@ -388,13 +388,21 @@ This function attempts to parse a given GLSL shader and returns either the parse
as a `TranslationUnit` type or an error message if parsing fails.
-}
parse : String -> Result String TranslationUnit
parse =
Combine.parse
(Combine.skipMany blank
|> Combine.keep translationUnit
|> Combine.ignore Combine.end
)
parse : String -> Result { position : Int, messages : List String } TranslationUnit
parse str =
case Combine.parse program str of
Ok ( _, _, res ) ->
Ok res

Err ( _, { position }, ms ) ->
Err { position = position, messages = ms }


program : Combine.Parser S TranslationUnit
program =
Combine.skipMany blank
|> Combine.keep translationUnit
|> Combine.ignore Combine.end



Expand Down Expand Up @@ -584,12 +592,12 @@ hexadecimal =
Combine.maybe (Combine.Char.oneOf [ 'U', 'u' ])
|> Combine.andThen
(\_ ->
case Hex.fromString (String.fromList d) of
case ParseInt.parseIntHex (String.fromList d) of
Ok val ->
Combine.succeed (IntConstant Hexadecimal val)

Err err ->
Combine.fail err
Combine.fail (parseIntErrorToString err)
)
)
)
Expand All @@ -611,22 +619,30 @@ octal =
Combine.maybe (Combine.Char.oneOf [ 'U', 'u' ])
|> Combine.andThen
(\_ ->
case octFromString (String.fromList d) of
case ParseInt.parseIntOct (String.fromList d) of
Ok val ->
Combine.succeed (IntConstant Octal val)

Err err ->
Combine.fail err
Combine.fail (parseIntErrorToString err)
)
)
)
)
)


octFromString : String -> Result String Int
octFromString _ =
Debug.todo "octFromString"
parseIntErrorToString : ParseInt.Error -> String
parseIntErrorToString err =
case err of
ParseInt.InvalidChar char ->
"Invalid char: " ++ String.fromChar char

ParseInt.OutOfRange char ->
"Out of range: " ++ String.fromChar char

ParseInt.InvalidRadix int ->
"Invalid radix: " ++ String.fromInt int


badOctal : P ()
Expand Down

0 comments on commit 4d816a9

Please sign in to comment.