We're at the finished line! I promise, we're almost done. This is the last blog post for Haskell and BNFC for Windows. You'll find that it also includes Happy and Alex installations as well.
Install BNFC
Open a web browser to the BNF Converter (BNFC) home page. https://bnfc.digitalgrammars.com/
On the BNF Converter home page., click on the Download (linux, mac, windows) button in the Download field.
The BNFC Download page appears.
Scroll down on the BNFC Download page until you see the bnfc.exe file hyperlink.
Click on the bnfc.exe link.
The "Opening bnfc.exe" dialog will appear.
The bnfc.exe is the Windows binary executable for the BNF Converter; it is not an installation program. You just need to copy the executable to a suitable location and ensure that it is in your Path.
Here's an example. I created a new directory, C:\HaskellTools and place the BNFC.EXE executable program there.
You'll need to place the bnfc.exe executable program in your Path.
In the Windows 10 search box in the lower left corner of the screen, type system.
Click on Control Panel.
The Control Panel window appears.
Click on the System icon.
The Windows 10 System Control Panel Item dialog window appears.
Click on the Advanced system settings option at the left hand side of the window.
The System Properties dialog appears.
Press the Environment Variables ... button near the bottom of the Window.
(For security reasons, the values for my system are blurred-out.)
Ensure that within the System variable section, the Path environment variable is highlighted.
Click the Edit button.
The Edit environment variable dialog window appears.
Click the New button.
Enter the path to the bnfc.exe program, in this example it's C:\HaskellTools.
Press the OK button.
The BNFC.EXE program is now in your path.
Install Stack
Stack is a cross-platform program for developing Haskell projects. To install it, first direct your browser to the Stack homepage: https://docs.haskellstack.org
On the Haskell Tool Stack homepage, click on the Windows 64-bit Installer link (it's visible on the screen capture above near the bottom center).
The Opening stack-...-windows-x86_64-installer.exe Save File dialog window appears.
Click the Save File button.
After you've saved the file, navigate to the location where you saved it and double click on the stack-...-windows-x86_64-installer.exe installation program.
Keep the default installation pathname value in the Destination Folder textbox, Browser to a desired location or enter the location where you want stack installed. Press the Next button.
The Haskell Stack Setup Choose Components dialog is displayed.
You should retain the default components to install. Press the Install button.
The Installing dialog appears.
After a few seconds, the Installation Complete dialog is displayed.
Press the close button.
Open a new Git Bash shell by clicking on the Windows Start button, opening the Git Folder, and selecting Git Bash.
When the Git Bash shell appears, type in which stack.
The which command should return the location of the stack command.
Next, you'll use stack to install several additional tools you'll need to work with BNFC.
Install Alex Using Stack
Alex is a tool for generating lexical analyzers in Haskell, given a description of the tokens to be recognized in the form of regular expressions. It is similar to the tool lex or flex for C/C++.
For more information on Alex, please see https://www.haskell.org/alex/.
To install Alex, open a Git Bash shell by clicking on the Windows start button, selecting the Git folder, then choosing Git Bash.
When the Git Bash command line shell window appears, type in the following command at the command prompt to install alex.
stack install alex
The download is quite large and may take a while.
The following will be displayed when Alex has been installed:
Alex is now installed.
Install Happy Using Stack
Happy is a parser generator system for Haskell, similar to the tool `yacc' for C. Like `yacc', it takes a file containing an annotated BNF specification of a grammar and produces a Haskell module containing a parser for the grammar. For more information on Happy, please see https://www.haskell.org/happy/.
In the same Git Bash command line shell that you used to install Alex, execute the following command to install Happy:
stack install happy
The installation of Happy proceeds more quickly than that for Alex. When complete, something similar to the following will be displayed.
A few warnings may be emitted. You now have Happy installed.
This concludes our Haskell and BNFC for Windows series of blog posts. As a Mac user who is unfamiliar with Windows but needed to use a Windows machine, I found Git Bash helpful throughout my time in the Computer Languages course. Although the process of installation is long, I hope the tutorial was helpful and prevents any roadblocks you come across.
References
Homepage: Install Stack
Homepage: Install Alex
Comments