Skip to content

Commit 3c73b4f

Browse files
authored
Merge pull request #309 from camfort/fix300
Fixes issue #300 with parsing imports for Fortran 2003 when their are no attributes
2 parents 1748718 + 5dc27ea commit 3c73b4f

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

fortran-src.cabal

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.35.2.
3+
-- This file has been generated from package.yaml by hpack version 0.36.0.
44
--
55
-- see: https://github.com/sol/hpack
66

@@ -15,7 +15,7 @@ author: Mistral Contrastin,
1515
Matthew Danish,
1616
Dominic Orchard,
1717
Andrew Rice
18-
maintainer: Dominic Orchard <[email protected]>
18+
maintainer: Dominic Orchard
1919
license: Apache-2.0
2020
license-file: LICENSE
2121
build-type: Simple
@@ -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.6
204-
, singletons-th >=3.0 && <3.6
203+
, singletons-base >=3.0 && <3.4
204+
, singletons-th >=3.0 && <3.4
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.6
268-
, singletons-th >=3.0 && <3.6
267+
, singletons-base >=3.0 && <3.4
268+
, singletons-th >=3.0 && <3.4
269269
, temporary >=1.2 && <1.4
270270
, text >=1.2 && <2.2
271271
, uniplate >=1.6 && <2

package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tested-with: GHC >= 9.0
1212
github: camfort/fortran-src
1313
bug-reports: https://github.com/camfort/fortran-src/issues
1414
author: [Mistral Contrastin, Matthew Danish, Dominic Orchard, Andrew Rice]
15-
maintainer: [[email protected], Ben Orchard]
15+
maintainer: [Dominic Orchard]
1616
category: Language
1717
license: Apache-2.0
1818
license-file: LICENSE

src/Language/Fortran/Parser/Free/Fortran2003.y

+10-2
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ NONEXECUTABLE_STATEMENT :: { Statement A0 }
583583
| save { StSave () (getSpan $1) Nothing }
584584

585585
-- according to IBM F2003 docs, dcolon is always required
586-
| procedure '(' MAYBE_PROC_INTERFACE ')' ATTRIBUTE_LIST '::' PROC_DECLS
586+
| procedure '(' MAYBE_PROC_INTERFACE ')' MAYBE_ATTRIBUTE_LIST '::' PROC_DECLS
587587
{ let declAList = fromReverseList $7
588-
in StProcedure () (getTransSpan $1 $7) $3 (Just (fromReverseList $5)) declAList }
588+
in StProcedure () (getTransSpan $1 $7) $3 $5 declAList }
589589

590590
| dimension MAYBE_DCOLON INITIALIZED_DECLARATOR_LIST
591591
{ let declAList = fromReverseList $3
@@ -1038,6 +1038,14 @@ DECLARATION_STATEMENT :: { Statement A0 }
10381038
{ let { declAList = fromReverseList $2 }
10391039
in StDeclaration () (getTransSpan $1 declAList) $1 Nothing declAList }
10401040

1041+
MAYBE_ATTRIBUTE_LIST :: { Maybe (AList Attribute A0) }
1042+
: ',' NE_ATTRIBUTE_LIST { Just $ fromReverseList $2 }
1043+
| {- EMPTY -} { Nothing }
1044+
1045+
NE_ATTRIBUTE_LIST :: { [ Attribute A0 ] }
1046+
: NE_ATTRIBUTE_LIST ',' ATTRIBUTE_SPEC { $3 : $1 }
1047+
| ATTRIBUTE_SPEC { [ $1 ] }
1048+
10411049
ATTRIBUTE_LIST :: { [ Attribute A0 ] }
10421050
: ATTRIBUTE_LIST ',' ATTRIBUTE_SPEC { $3 : $1 }
10431051
| {- EMPTY -} { [ ] }

test/Language/Fortran/Parser/Free/Fortran2003Spec.hs

+7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ spec =
5656
st = StUse () u (varGen "mod") Nothing Permissive (Just renames)
5757
sParser "use :: mod, sprod => prod, a => b" `shouldBe'` st
5858

59+
it "parses simple procedure with no args" $ do
60+
let st = StProcedure () u (Just (ProcInterfaceName () u (varGen "name")))
61+
Nothing
62+
(AList () u [ProcDecl () u (varGen "other_name") Nothing] )
63+
sParser "procedure(name) :: other_name" `shouldBe'` st
64+
65+
5966
it "parses procedure (interface-name, attribute, proc-decl)" $ do
6067
let call = ExpFunctionCall () u (varGen "c") (aEmpty () u)
6168
st = StProcedure () u (Just (ProcInterfaceName () u (varGen "a")))

0 commit comments

Comments
 (0)