Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax errors for valid Fortran #5

Open
melven opened this issue Jun 18, 2016 · 1 comment
Open

Syntax errors for valid Fortran #5

melven opened this issue Jun 18, 2016 · 1 comment

Comments

@melven
Copy link
Contributor

melven commented Jun 18, 2016

The Fortran grammar specification has several issues:

  1. Kind-specifiers for constants are not supported, e.g. 1.0_8 or 1.0_myKindParameter
  2. kind is not only a keyword inside a declaration, but also an intrinsic function, e.g. i = kind(1.)
  3. Fortran explicitly allows reusing keywords of the language. Keywords are not reserved, you can for example name a variable value or kind. The compiler only fails if the usage is ambigious.

Here is a valid Fortran file:

module test
  implicit none
  public

  integer, parameter :: rk = kind(1.0)
  real(kind=rk), parameter :: eps = epsilon(1._rk)
  integer, parameter :: value = 10

end module test

And the respective errors I obtain:

> F2x -t @_bindc.f90.t -t @_ctypes.py.t test.f90
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home_local/zoel_ml/F2x/src/F2x/main.py", line 165, in main
    src.parse()
  File "/home_local/zoel_ml/F2x/src/F2x/source.py", line 180, in parse
    self.tree = grammar.parse(self.source)
  File "/home_local/zoel_ml/F2x/src/plyplus/plyplus.py", line 575, in parse
    return self._grammar.parse(text)
  File "/home_local/zoel_ml/F2x/src/plyplus/plyplus.py", line 716, in parse
    raise ParseError('\n'.join(self.errors))
plyplus.plyplus.ParseError: Syntax error in input at 'kind' (type T_KIND) line 5 col 30
Syntax error in input at '_' (type T_UNDERSCORE) line 6 col 47
Syntax error in input at 'value' (type T_VALUE) line 7 col 25
Could not create parse tree!
@melven
Copy link
Contributor Author

melven commented Jun 18, 2016

I already fixed some minor other problems in this example, see the pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant