Giter Site home page Giter Site logo

axion-lang / axion Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 2.0 10.63 MB

Experimental programming metalanguage, targeting on intertranspiling with other languages.

License: GNU General Public License v3.0

C# 99.46% Lua 0.54%
axion programming-language lexical-analysis parser interpreter compiler translator language-oriented-programming lexer parse

axion's Introduction

Welcome to Axion programming language toolset

๐Ÿšง Under construction ๐Ÿšง

Codacy Badge Build Status Gitmoji

๐Ÿ“‚ Distribution

Entire codebase is implemented in .NET 6 (+ .NET Standard 2.1)

Directory Contents
Axion User interface for compiler: CLI, ScriptBench editor, interpreter
Axion.Core Language core, lexer, parser, frontend interface, compiler API
Axion.Emitter.Axion Extension to translate Axion syntax tree back into Axion source code
Axion.Emitter.CSharp Extension to translate Axion AST into C# source code
Axion.Emitter.Python Extension to translate Axion AST into Python source code
Axion.Testing NUnit-based unit tests for the toolset
CodeConsole Sub-repo for ScriptBench - console code editor (still unstable)
misc Code examples, arts, etc.

๐ŸŽฏ Key features

  • Expressiveness

    Maintaining the "perfect balance" (ยฉ Thanos) between usage of expressive symbols and readable names.
    Support for language-oriented programming (LOP) and macros system allows you to:

    • Add new language syntax of almost any complexity
    • Implement common design patterns quickly and simply
  • Inter-transpiling to other popular languages

    At the moment Axon targets C# and Python code output. More languages are planned!

  • Static typing with less annotations

    Support for full type soundness and type inferring (in design).

  • High-performance

    Compile-time computations, macros expansion, and transpiling to fastest target language's code.

๐Ÿ’น Progress

  • Lexical analyzer
  • Syntax parser
  • Interpreter (based on C# transpiling)
  • Console code editor with syntax highlighting & error reporting
  • C#, Python transpilers

๐Ÿš€ Launching

You can launch compiler with dotnet run in Axion.csproj folder and type -h in console to get support about arguments for compiler interface.

At the moment toolset supports interpretation of the Axion source with -i CLI argument (through console code editor) and file processing with -f "<path>.ax" -m <output lang> arguments.

Interpretation is performed by transpiling Axion to C# and running it through Roslyn (still incomplete and doesn't support some syntax).

๐Ÿ“œ You can take a look at the language syntax in project wiki

axion's People

Contributors

codacy-badger avatar dependabot[bot] avatar f1uctus avatar furesoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

fossabot furesoft

axion's Issues

`BlockExpression.ToCSharp` - invalid `;` placing

https://github.com/F1uctus/Axion/blob/a4e33355a629f7ea6c3ebc9428a596b23f94355b/Axion.Core/Processing/Syntactic/Ast.cs#L150-L159

When block has function/class/struct/other top level expression, then C# doesn't allow semicolons to be placed after that expressions.

for example:
Axion:

fn Hello
    Console.WriteLine("Hello, world!")

C#:

void Hello() {
    Console.WriteLine("Hello, world!");
}; // semicolon here is not permitted
// (results in 'error CS1597: Semicolon after method or accessor block is not valid')

Functions syntax

fn sum (a: int, b: int) -> int
    return a + b

Note: Regular/anonymous functions are implemented as FunctionDef class.

`LangException` rendering

Render exception like:

Error: Unknown operator.

8| someInt $= 340
           ^^

src\main.ax,
line 8, column 9.

Feature is already partially implemented.

for comprehension on new line inside collection

https://github.com/F1uctus/Axion/blob/a4e33355a629f7ea6c3ebc9428a596b23f94355b/Axion.Core/Processing/Syntactic/Expression.cs#L424-L429

There is a check, that for keyword is not placed at new line, to resolve that code:
Axion:

<expression>
for x in y
    code()

not to be parsed as for comprehension (<expression> for x in y).

But also, for is allowed to be placed in that context:

(float(f)
   for a in l
     ...
       for f in e
         unless e.length == 0)

and, because of newline check, we must write it like:

(float(f) for a in l
            ...
              for f in e
                unless e.length == 0)

so, for allowed to be placed on new line if it's invoked by function, that parses
collection expression embraced in (), {} or [].

Implement modules system

Modules should be organized by nesting directories.

Definitions from one module should have straight accessibility from other module's parts.
e.g: examine the hierarchy:

app1
- frontend
  - button.ax
  - list-view.ax
- backend
  - converter.ax
  - parser.ax

Here, parts of module frontend should have access to each other without imports.
Same goes for backend.

Format syntax documentation comments for `Expr` parsing functions

Doc-comment for every function-expression builder and every expression constructor should contain valid ANTLR grammar rule, describing syntax of constructing expression.
Doc-comment format:

<summary>
    <c>
        expression: syntax;
    </c>
</summary>

Every expression rule should end with expr (except for comprehension, name, definition and type expressions).

Indentation bug

In cases with equal line indentation, like:

use:
   System: Module1;
   Axion: Module2;
   Etc;

Lexer products Unknown token instead of nothing.
Should be fixed to v. 0.2.9.5.

`match` construction

Example:

count = x match
    1: "one"
    2: "two"
    3: "three"
    _: "?"

Note: Implemented as a macro.

Implement automatic span marking for expressions

At the moment compiler logic enforces explicit span (start/end location) marking for expressions.
Idea is in marking the span while binding expression part to it's parent.
This is achieved by usage of Bind(Node) and InitIfNull(NodeList<Node>) in Node-based properties.

Dataclasses

class Point (x: Int, y: Int)

Note: Implemented as a NodeList<Expr> DataMembers property of ClassDef.

Unsuccessful macro match reports false-error

Consider the following macros definition snippet:

macro for-in-statement ('for', item: Atom, 'in', iterable: Infix, scope: Scope)

macro for-index-statement ('for', init: Any, ',', condition: Infix, ',', step: Infix, scope: Scope)
    return {{
        $init
        while $condition {
            $scope
            $step
        }
    }}

And piece of code that uses it:

for (x, y) in zip(1..9, 9..1) Console.print(x, y)

First macro will try to match it, but it'll fail and report error.
Then, 2-nd macro will match successfully, but error will remain.

Variables syntax

a: int = 1 # immediate assignment (type can be omitted)
b = 2      # type is inferred
c: int     # type required without initializer
let a: int = 1 # immediate assignment
let b = 2      # type is inferred
let c: int     # type required without initializer
c = 3          # deferred assignment (now type of `let c` can be omitted)

Still Alive?

Is this project still alive? I love the idea of language orientatet programming. I am the developer of backlang and I want to make axion a full robsu language that can be compiled to il, like backlang does.

Pipeline operator `|>` (like in F#)

messages =
   friends
   |> Seq.map(fn (x): x.Messages)
   |> Seq.concat

Note: Implemented as infix operator, converted to regular FuncCallExpr through traversing.

Multiple arguments usage still unimplemented.

Build a dsl

How would you build a dsl with this?
like only expand macros in a certain context:

mydsl { do x on after y unless z }

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.