Giter Club home page Giter Club logo

fly's Issues

Cannot expand tar.gz file for Mac

I tried to download the tar.gz file for Mac, but an error is thrown:

Unable to expand "https__github.com_fly-lang_releases_download_v0.2.0_fly-0.2.0-macos-x86_64.tar.gz". It is in an unsupported format.

Add package feature

Related to: Syntax: define package, imports and namespace

Implements module features in order to prepare the logic for packages

A single source file:

  • have to belongs to only one package,
  • can have the same package of more other source files

More source files:

  • can be grouped into one package as a logical group
  • of the same package raises an error if own same variables, constants, functions.

Add package keywords to:

KEYWORD(auto)

Syntax: define the block of code delimiter

Each programming languages use a different kind of block delimiter, for functions and statements defining:

  • {} used in C/C++, Java, Go, PHP, C#, Swift, Rust ...
  • tab and spaces used in Python, Haskell
  • Special keywords like Begin/End used in Pascal, Delphi, ML
  • A mix of brace, spaces, and keywords like in Ruby

Chose the Fly solution for maintaining code readability and ease of use.

Create print() in AST classes

Each AST class need to to have a print() function that write the content like the fly language does.
Example:
ASTFunction::print()

public void test() {
...
}

Error Management

Refactoring from Parser to CodeGen for including error management.
Remove not useful assertions.

Syntax: define package, imports and namespace

Define the syntax for the best approach for defining a package, importing, and use in the code.
Following some programming language examples:

  • Javascript: import "modname";
  • Java: import package.*
  • PHP: use Namespace\function_name as function_alias_name;
  • Rust: use module::submodule::symbol as altname
  • C++: #include and using namespace std;
  • Go: import m "math" or import . "math"

Easy, readable and powerful

Syntax: define statement separator or terminator

How to demarcate boundaries between two separate statements?
Define statement terminator for using to demarcate the end of an individual statement and its implicit behavior:

  • C/C++, Java: uses a semicolon
  • Javascript: use an implicit semicolon if not present in the code
  • Go: not use semicolons but the compiler inserts them.
  • Python: newline terminated

Syntax: define a function

Create the Fly syntax for defining a function

Following different examples from known languages, chose the best syntax (combination permitted) by considering the most readable solution. You can also make a different proposal.

Python

def printme( str ):
   print str
   return true

Rust

fn printme(str: String) -> bool {
    println!(str);
    return true;
}

C/C++

bool printme(char str*) {
  cout << str;
  return true;
}

Javascript

function printme(str) {
  alert(str)
  return true;
}

Go

func printme(str string) bool {
  fmt.Println(str)
  return true
}

Syntax: define variable declaration

How to declare a variable in two scopes:

  • at the package level
  • at the function level

Package Var

A var can be accessed from all functions in that package. This var needs to be declared out the functions and not initialized, can be initialized only into a function.

Function Var

A var can be accessed from only elements in the same function where declared.

Define Function Body Parser

Based on #5 and #14

Parse the body of a Function by identifying:

  • Return
  • Var declarations (with assignment or not)
  • Var assignment
    • Reference to other Var
    • Add Expression with operators with all complex combinations
    • Call to a Function
    • Ternary Operator
  • Call to a Function

Add all to the Function AST

Syntax: define builtin data types

Define the main types for variables and constants to be used in the code considering to manage the common data types: integer and float numbers, boolean, strings, and array.
Moreover, it's important to expect:

  1. integer with different number of bits, signed or unsigned
  2. float with different number of bits, signed or unsigned
  3. string representation, encoding, escape.
  4. boolean representation
  5. array representation

Think about it is better to include other built-in data types.

Module Import System and Linking

Import External/Internal Module into a LLVM Module by creating dependency.
Enable Linker to build a single file ready to be executed in a target machine.

Syntax: define operators

Chose the representation of the following operators:

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators

Add Types feature

Create Types:

int for integer type numbers of 32bits
float for floating point decimal numbers of 32bits
boolfor boolean types of 1 bits

Syntax: define constant declaration

How to declare a constant in two different scopes:

  • at the package level
  • at the function level

Package Const

A constant can be accessed from all functions in that package. This constant needs to be declared out the functions and immediately initialized.

Function Const

A constant can be accessed from only elements in the same function where declared.

Add Global Vars feature

Create global vars with default values:

int a create a var with default value 0
float b create b var with default value 0
bool c create c var with default value false

Create global vars with assigned values:

int a=1 create a var with value 1
float b=1.0 create b var with value 1.0
bool c=true create c var with value true

Global vars can be defined only after package definition:

package packageA

int a=1

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.