Skip to content

AlejandroGonzalR/CustomCompilerLexicalAnalyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHAB, a simple language

Lexical and syntactic analyzer for custom C based language using Flex and Bison.

Getting Started

You only need to run the build.sh file, then call the executable file using your terminal sending the wish file.

./out/test.exec <your-file.phab>

Prerequisites

An UNIX based OS, with Flex and Bison installed.

Custom syntax

Declarations and assignments

Let for constants.

let hello : text -> "Hello World!"

Var for variables, evidently.

var myNumber : numeric -> 4

And for functions or methods

fun sayHello() {
    ... Do something
}

If statement

The word if and else were replaced by cond and so respectively.

cond (condition) {
    ... Do something
} so {
    ... Do another
}

For statement

Statement based on Kotlin's progression for loop.

since iterator -> 1 until 5 step 1 {
    ... Do something
}

While and do while statement

In this case, the word while is represented by loop key word, on the other hand the do word is mark off with act word.

loop (condition) {
    ... Do something
}

And for the do while loop

act {
    ... Do something
} loop (condition)

For more precise details please check the Lex file.

Built With

  • Flex - The Fast Lexical Analyzer - scanner generator for lexing in C and C++
  • Bison - Open source parser generator
  • GCC - The GNU Compiler Collection

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Custom basic compiler using syntax and lexical analyzers C based

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published