Skip to content
/ paco Public

Paco is a compiler prototype written in Golang, it compiles to C.

License

Notifications You must be signed in to change notification settings

pacolang/paco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


👩🏼‍💻 A simple compiled programming language.

The language is written in Go and the target language is C. The built-in library is written in C too. ⚠️ This project is a prototype Please consider it.


Example

Code example

- returns a random number between 0 and 6
fn rollDice() int
    random|randInt(6)
end

- gets the user entry
console|println("Enter your name")
name = console|getStringEntry()

- uses pipe character to use multiple time built-in functions coming
- from the same package
console
    |print("Hello, ")
    |println(*name)
    |println("Please enter a number")

- asks the user to enter a number and prints the number given
number = console|getIntEntry()
stdio|printf("You've entered: %d\n" *number)

- check if the given number is in the 0-6 range
if *number < 0 or *number > 6
    console|println("the number must be contained between 0 and 6")
- roll the dice and check if the given number is the same as the computer
else
    computerNumber = rollDice()
    if *number == *computerNumber
        console|println("you won! same number as the computer!")
    else
        stdio|printf("you lost! the computer's number was %d" *computerNumber)
    end
end

Module file

mod "console"

fn println(string)
fn print(string)
fn getStringEntry() string
fn getIntEntry() int


Made by Hugo Lageneste