Skip to content

FORTRAN-Compiler v2.0

Latest

Choose a tag to compare

@AHM-ID AHM-ID released this 17 Jan 09:04

FORTRAN Compiler v2.0 Release

I'm excited to announce the FORTRAN Compiler v2.0, a significant update to our tool for compiling a subset of the FORTRAN language using Flex and Bison. This release introduces new features, improved error handling, and expanded language support.

Highlights

  • Lexical Analysis: Enhanced lexer for tokenizing FORTRAN keywords, identifiers, constants, and operators.
  • Syntax Analysis: Improved parser with support for more complex FORTRAN constructs.
  • New Features:
    • Support for CHARACTER and LOGICAL data types.
    • PRINT statements for output.
    • Logical and relational operators (.AND., .OR., .NOT., >, <, >=, <=, ==, !=).
    • Arithmetic expressions with +, -, *, /.
    • String handling with CHARACTER and STRING.
    • Logical constants (.TRUE., .FALSE.).
    • Enhanced DO loops with step support.
    • Improved IF statements with ELSE and nested conditions.
  • Error Handling: More informative error messages for syntax issues, such as unmatched parentheses, incorrect statement formats, or mismatched program names.

Installation

For setup instructions, refer to the Installation section in the README.

Usage

For usage details, follow the instructions in the Usage section of the README.

Known Issues

  • Limited support for advanced FORTRAN constructs (e.g., arrays, derived types).
  • Error handling for edge cases can be further improved.

Roadmap

Future versions will focus on:

  • Expanding support for advanced FORTRAN features (e.g., arrays, derived types, modules).
  • Enhancing error handling and performance.
  • Adding support for file I/O operations.

What's New in v2.0?

  • Support for CHARACTER and LOGICAL Data Types:

    • Declare and use CHARACTER variables with optional length specifications.
    • Use LOGICAL variables and constants (.TRUE., .FALSE.).
  • PRINT Statements:

    • Output strings and expressions using PRINT * syntax.
  • Logical and Relational Operators:

    • Support for .AND., .OR., .NOT., >, <, >=, <=, ==, and !=.
  • Enhanced DO Loops:

    • Added support for step values in DO loops.
  • Improved Error Handling:

    • More detailed error messages for syntax issues.

Example Code

Here’s an example of FORTRAN code that can now be compiled with v2.0:

PROGRAM Example
  REAL :: x, y
  INTEGER :: i
  CHARACTER(LEN=10) :: name
  LOGICAL :: flag

  x = 10.5
  y = 20.3
  name = "FORTRAN"
  flag = .TRUE.

  PRINT *, "Hello, ", name

  IF (x > y .AND. flag) THEN
    PRINT *, "x is greater than y"
  ELSE
    PRINT *, "y is greater than or equal to x"
  ENDIF

  DO i = 1, 10, 2
    PRINT *, "i = ", i
  ENDDO
END PROGRAM Example

How to Upgrade

If you’re upgrading from v1.0, follow these steps:

  1. Pull the latest changes from the repository:

    git pull origin main
  2. Rebuild the compiler:

     ./scripts/build.sh
  3. Test the new features with your FORTRAN code.


Feedback and Contributions

We welcome your feedback and contributions! If you encounter any issues or have suggestions for new features, please open an issue or submit a pull request on GitHub.

Thank you for using the FORTRAN Compiler v2.0! We hope this release makes your FORTRAN programming experience even better. 🚀