Skip to content

Commit 1748718

Browse files
authored
Merge pull request #304 from smoothdeveloper/minor-tweaks-1
minor tweaks:
2 parents b8a490f + 15a83c0 commit 1748718

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ We support the latest recommended version of Cabal (as of 2021-09-17, Cabal 3.4)
143143
cabal build
144144
```
145145

146+
You can leverage cabal to initialize a ghci session, and call the main function like such:
147+
148+
```shell
149+
cabal repl
150+
151+
:load app/Main.hs
152+
153+
:main --version
154+
```
155+
146156
### Testing
147157
Unit tests are stored in `test`. Run with `stack test` or `cabal test`.
148158

fortran-src.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ library
200200
, pretty >=1.1 && <2
201201
, process >=1.2.0.0
202202
, singletons ==3.0.*
203-
, singletons-base >=3.0 && <3.4
204-
, singletons-th >=3.0 && <3.4
203+
, singletons-base >=3.0 && <3.6
204+
, singletons-th >=3.0 && <3.6
205205
, temporary >=1.2 && <1.4
206206
, text >=1.2 && <2.2
207207
, uniplate >=1.6 && <2
@@ -264,8 +264,8 @@ executable fortran-src
264264
, pretty >=1.1 && <2
265265
, process >=1.2.0.0
266266
, singletons ==3.0.*
267-
, singletons-base >=3.0 && <3.4
268-
, singletons-th >=3.0 && <3.4
267+
, singletons-base >=3.0 && <3.6
268+
, singletons-th >=3.0 && <3.6
269269
, temporary >=1.2 && <1.4
270270
, text >=1.2 && <2.2
271271
, uniplate >=1.6 && <2

src/Language/Fortran/Parser/Fixed/Lexer.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Language.Fortran.Parser.Monad
3030
import Language.Fortran.Version
3131
import Language.Fortran.Util.FirstParameter
3232
import Language.Fortran.Util.Position
33-
import Language.Fortran.Parser.LexerUtils ( readIntOrBoz )
33+
import Language.Fortran.Parser.LexerUtils ( readIntOrBoz, unescapeSpecialChars )
3434
import Language.Fortran.AST.Literal.Boz
3535

3636
}
@@ -1128,7 +1128,7 @@ lexer' = do
11281128
AlexEOF -> return $ TEOF $ SrcSpan (getPos alexInput) (getPos alexInput)
11291129
AlexError _ -> do
11301130
parseState <- get
1131-
fail $ psFilename parseState ++ " - lexing failed: " ++ show (psAlexInput parseState)
1131+
fail $ psFilename parseState ++ " - lexing failed: " ++ (unescapeSpecialChars $ show (psAlexInput parseState))
11321132
AlexSkip newAlex _ -> putAlex newAlex >> lexer'
11331133
AlexToken newAlex _ action -> do
11341134
putAlex newAlex

src/Language/Fortran/Parser/LexerUtils.hs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-| Utils for both lexers. -}
2-
module Language.Fortran.Parser.LexerUtils ( readIntOrBoz ) where
2+
module Language.Fortran.Parser.LexerUtils ( readIntOrBoz, unescapeSpecialChars) where
33

44
import Language.Fortran.AST.Literal.Boz
55
import Numeric
@@ -16,3 +16,17 @@ readIntOrBoz s = do
1616
readSToMaybe :: [(a, b)] -> Maybe a
1717
readSToMaybe = \case (x, _):_ -> Just x
1818
_ -> Nothing
19+
20+
21+
-- | Pretty prints exception message that contains things like carriage return, indents, etc.
22+
unescapeSpecialChars :: String -> String
23+
unescapeSpecialChars [] = []
24+
unescapeSpecialChars ('\\' : c : rest) =
25+
case c of
26+
'n' -> '\n' : unescapeSpecialChars rest
27+
't' -> '\t' : unescapeSpecialChars rest
28+
'r' -> '\r' : unescapeSpecialChars rest
29+
'\\' -> '\\' : unescapeSpecialChars rest
30+
_ -> '\\' : c : unescapeSpecialChars rest
31+
unescapeSpecialChars (c : rest) =
32+
c : unescapeSpecialChars rest

0 commit comments

Comments
 (0)