Giter VIP home page Giter VIP logo

pine's Introduction

Alt text

Pine

Master
GCC Not Tested
Clang Build Status

Abstract

Pine is a compiler and a programming language that's intended for 64-bit machines, with 32-bit backport in the future. Pine depends on gcc for the linker. Pine is a statically-typed programming language. A more comprehensive Pine tutorial will be written in the future.

Set Up

Run the Makefile located in src to build Pine.

cd src/
make

Open Main.pn, and replace its contents with:

func main() -> Int {
    print("Hello, World from Pine!");
};

Compile the program by passing it into Pine, and then run the executable.

./Pine Main.pn
./a.out

You should see Hello, World from Pine! printed to the console.

Pine Tutorial

Syntax:

Pine is white-space insensitive. All statements must be ended with a semi-colon.

Variables:

This is how you define a new variable named acorn that's of type String with the value "Tree".

let pine:String = "Tree";

All variables in Pine are statically-typed. All variables must have unique names in the given scope. Names can be composed of one or more characters, numbers, or symbols, but the first character in the name cannot be a number or symbol. Re-assigning a variable with a value of different type from its original type definition will result in a Pine exception. The type given at the definition site is optional, but it's highly recommendend. Pine will make an attempt to infer the type of the variable at the definition point if no type is given.

Numeric Values

Pine supports integers, floating point numbers, and double precision floating point numbers, Int, Float, Double respectively. Int will follow two's complement, and it will have a width of 64-bits on 64-bit Pine compilers, and implementation defined width on 32-bit Pine compilers no less than 32-bits. Float and Double will follow IEEE 754 standard of precision. On 64-bit Pine compilers, Float values will be 64-bits. Division will result in integer division with integer operands, but regular division with floating or double precision operands.

Numeric Operations

Pine supports the following operators on numeric operands. All numeric operators must have operand(s) that are the same type else a Pine exception will occur. From greatest to least precendence:

Operators
Parentheses (expression)
Negation -expression
Multiplcation, Division *, \
Addition, Subtraction +, -
Left Shift, Right Shift <<, >>
BitAnd &
BitXor ^
BitOr |

Note: << and >> operators assume its operands are 32-bit integers, else the behavior is undefined. >> will follow right-arithmetic shift and << will follow left-logical shift.

Example

let  pineConeCountPerTree:Int = 42;
let         numberOfTrees:Int = 100;
let totalNumberOfPineCone:Int = pineConeCountPerTree * numberOfTrees;

Pine supports the follow integer bases: Binary, Octal, Decimal, and Hexidecimal. By default, any integer literal without a base prefix will be a base-10 integer.

let  binary:Int = 0b00101010; /* 42 in Binary */
let   octal:Int = 0o52;       /* 42 in Octal  */
let decimal:Int = 0d42;       /* 42 in decimal. Doing 42 without 0d prefix is the same. */
let     hex:Int = 0x2A;       /* 42 in hex */

Boolean Values

Pine supports the boolean type, Bool. Any variable that is of type Bool must have a value that is of type Bool or be evaluable to type Bool.

Logical Operations Pine supports the following operators on Bool operands. All logical operators must have operand(s) that are the same type else a Pine exception will occur. From greatest to least precendence:

Operators
Parentheses (expression)
Logical And &&
Logical Or ||

Example

let arePineTreeReferencesFun:Bool = True;
let       pineConeTeaIsTasty:Bool = False;

Arrays

Arrays in Pine can hold elements of the same type.

let array:[Int] = [1, 2, 4, 9, 16];

Arrays in an array must have the same dimensions as its neighboring elements.

/* This array is valid since each inner-array are the same dimesion: 1x3 */   
let identity:[[Int]] = [[1, 0, 0],
                        [0, 1, 0],
                        [0, 0, 1]];  
                 
/* This array is invalid since all of the inner-arrays are different dimesions. */
let invalidArray:[[Int]] = [[1],
                            [1, 2],
                            [1, 2, 3]]; 
                            

pine's People

Contributors

mita4829 avatar

Stargazers

Andrew Johnson avatar

Watchers

James Cloos avatar  avatar Daniel Scott avatar

pine's Issues

String error

It looks like the string type does not work well.

Here is my code:

func main() -> Int {
    let e:String = "Hello";
    print(e);
};

Here is the outpt:
?n?

Thank you,
Telly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.