Create a Fortran 77 parser from yacc grammar with Happy (Haskell)

I came across the following yacc F77 grammar: http://yaxx.cvs.sourceforge.net/viewvc/yaxx/yaxx/fortran/fortran.y?revision=1.3&view=markup .

How can I make a parser from Fortran 77 from this file using Happy ?

Why is there C? / C ++? the code in this .y file?

UPDATE: Thanks for your answers!

I played with two new approaches for a while:

  • extracting and modifying the parser from the source package bundled with a document called Parametric Fortran ,
  • write grammar from scratch using BNFC .

I have both to parse a simple code excerpt already. I will keep people informed if anything useful arises in this century. ^ Hehe.

P / S: I want to see if I can gather enough momentum myself to initiate a project for the automatic differentiation mechanism, to replace only the binary code that we currently depend on. For fun in the early stages: I'm watching Love Shuffle ! This is a very nice J-Drama! Highly recommended ...

+3
source share
4 answers

BNFC ! BNFC , , .

+1

C - . C, Bison/Yacc, C.

Happy, BNF Happy definition Haskell.

- .

, (: , , , , - )

+2

, , - , Yacc, , , . , , yyerror yylval .

, yyerror/yylval, / . , . , , .

+2

You will need an AST for the assembly, which can be constructed equivalently to the C fragments in the Yacc file.

+1
source

Source: https://habr.com/ru/post/1711073/


All Articles