C-Grass PLUS 🌊🌱 C-Grass PLUS is a proposed compiler for a programming language that holds Python Language Utilization System. It is inspired by the ease and clarity of Python language, as well as the power and structure of C language. It aims to help both programming language creators and programmers to maintain a good coding standard.
C-Grass PLUS is created by HerbiCode as a partial fulfillment of the CSC 0311 - Automata Theory and Formal Languages and CSC 0322-1 - Compiler Design subjects for the degree of Bachelor of Science in Computer Science.
Language Overview 📖 The name C-Grass PLUS comes from the analogy of seagrass, the tallest plant in the world that grows under the ocean and provides shelter and protection to many marine creatures. Seagrass represents the strength and resilience of this programming language project, as well as its environmental awareness and advocacy. 🐠🐬🐳
Compiler Stages 🛠️ The process of compiling a C-Grass PLUS program involves several stages, which are:
Lexical Analysis or Lexer: This stage reads the source code and breaks it into a stream of tokens, which are the basic units of the programming language. The tokens are then passed on to the next stage for further processing. Syntax Analysis or Parser: This stage takes the stream of tokens generated by the lexical analysis stage and checks whether they conform to the grammar of the programming language. The output of this stage is usually an Abstract Syntax Tree (AST). Semantic Analysis: This stage checks whether the code is semantically correct, i.e., whether it conforms to the language’s type system and other semantic rules. In this stage, the compiler performs type checking, which ensures that variables are used correctly and that operations are performed on compatible data types. The compiler also checks for other semantic errors, such as undeclared variables and incorrect function calls. Intermediate Code Generation: This stage generates an intermediate representation of the source code that can be easily translated into machine code. Code Optimization: This stage applies various optimization techniques to the intermediate code to improve the performance of the generated machine code.