Bassil is a custom programming language project that includes a lexical analyzer and various utility functions. This project is designed to tokenize and analyze Bassil language code, providing a foundation for further language processing steps.
- Project Structure
- Features
- Dependencies
- Building the Project
- Usage
- File Descriptions
- Key Components
- Error Handling
- Utility Functions
- Windows-Specific Features
- Contributing
- License
The project is organized into several key components:
main.cpp
: Entry point of the applicationlexer.h
andlexer.cpp
: Lexical analyzer implementationerror_report.h
anderror_report.cpp
: Error reporting functionalityutils.h
andutils.cpp
: Utility functionsbuildInfo.txt
: Compilation and dependency information
- Lexical analysis of Bassil language code
- Token generation and classification
- Error reporting with line and column information
- Extensive utility functions for string manipulation, file operations, and Windows API interaction
- Console output formatting with ANSI escape sequences
- File association and icon setting for Bassil files
- Windows operating system (Tested on Windows 10)
- GCC/G++ compiler (Tested with version 13.2.0)
- Windows API libraries: gdi32, user32, shell32
To build the project, use the following command:
g++ ./src/main.cpp ./src/cpp/utils.cpp ./src/cpp/lexer.cpp ./src/cpp/error_report.cpp -o C:/coding-projects/CPP-Dev/bassil/build/Bassil-Main-Build-ORS-A01 -lgdi32 -luser32 -lshell32
Optional: Add -w
flag to remove warnings from the compile message.
After building the project, run the executable Bassil-Main-Build-ORS-A01
. The program will perform lexical analysis on the input file specified in main.cpp
(default: C:/coding-projects/CPP-Dev/bassil/input/main.basl
).
main.cpp
: Contains theWinMain
function, initializes the application, performs lexical analysis, and handles errors.lexer.h
andlexer.cpp
: Define token types and implement the lexical analyzer.error_report.h
anderror_report.cpp
: Provide error reporting functionality.utils.h
andutils.cpp
: Contain various utility functions for string manipulation, file operations, and Windows API interactions.
The lexical analyzer in lexer.cpp
tokenizes input code into the following token types:
- Identifiers
- Keywords (int, char, float, string)
- Literals (integers, floats, strings)
- Operators (arithmetic, comparison, logical)
- Punctuation (parentheses, braces, semicolons, commas)
Each token contains:
- Type
- Value
- Line number
- Start column
- End column
The project includes an error reporting system that provides detailed information about lexical errors, including:
- File path
- Line number
- Column number
- Error message
The Utils
namespace in utils.cpp
provides a wide range of utility functions, including:
- String manipulation (splitting, trimming, formatting)
- File operations (reading, writing, logging)
- Console output formatting with ANSI escape sequences
- Windows API interactions (message boxes, notifications)
- Color and text formatting utilities
- Creation of Windows API 32-bit message boxes
- Windows API balloon notifications
- File association and icon setting for Bassil files
- Retrieval of monitor information
Contributions to the Bassil Language Project are welcome. Please ensure that your code adheres to the existing style and includes appropriate documentation and test coverage.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors and supporters of the Bassil project.
For any queries or suggestions, please open an issue in the GitHub repository.