Go to file
Valk Richard Li 73c9f98f4f update 2020-12-14 00:10:31 +08:00
pic change project structure 2020-10-23 14:53:04 +08:00
test update 2020-11-19 23:42:51 +08:00
.gitignore Initial commit 2019-07-25 02:11:59 +08:00
README.md Update README.md 2020-12-12 20:13:23 +08:00
lib.nas update math.pi :) 2020-11-09 00:33:15 +08:00
main.cpp update 2020-12-12 19:58:43 +08:00
nasal.ebnf update 2020-10-24 12:16:55 +08:00
nasal.h update 2020-12-10 00:01:25 +08:00
nasal_ast.h update 2020-12-14 00:10:31 +08:00
nasal_builtin.h update 2020-12-01 19:35:32 +08:00
nasal_bytecode_vm.h update 2020-12-12 19:58:43 +08:00
nasal_codegen.h update 2020-12-12 19:58:43 +08:00
nasal_gc.h update 2020-12-12 01:58:40 +08:00
nasal_import.h update 2020-11-20 19:15:12 +08:00
nasal_lexer.h update 2020-12-14 00:10:31 +08:00
nasal_misc.h update 2020-11-20 00:18:17 +08:00
nasal_parse.h update 2020-12-14 00:10:31 +08:00
nasal_runtime.h update 2020-12-12 01:58:40 +08:00

README.md

Nasal Interpreter

nasal_new_logo

Nasal script language

Nasal is a script language that used in FlightGear.

There is a Nasal console in FlightGear but sometimes it is not so easy for every developer to use.

So this is an interpreter for Nasal written by C++.

The interpreter is still in development.We really need your support!

Why Writing Nasal Interpreter

Nasal is a script language first used in Flightgear.

But in last summer holiday, members in FGPRC told me that it is hard to debug with nasal-console in Flightgear, especially when checking syntax error.

So i tried to write a new interpreter to help them checking syntax error and even, runtime error.

I wrote the lexer, parser and runtime(nasal virtual machine/ast-runtime virtual machine) to help checking errors.

They found it easier for them to check errors before copying nasal-codes in nasal-console in Flightgear to test.

How to Compile

g++ -std=c++11 main.cpp -o main.exe

Lexical Analysis

The flow chart of lexer is here:

nasal_lexer.png

This picture seems ugly. I will re-draw it later(maybe 1000 years later).

Parser

Version 3.0

I refactored parser and make it easier to maintain.

The EBNF is also refactored.

Abstract Syntax Tree

Version 1.2

The ast has been completed in this version.

Version 2.0

A completed ast-interpreter with unfinished lib functions.

Version 3.0

The ast is refactored and is now easier to read and maintain.

Ast-interpreter uses new techniques so it can run codes more efficiently.

Now you can add your own functions as builtin-functions in this interpreter!

I decide to save the ast interpreter after releasing v4.0. Because it took me a long time to think and write...

Byte Code Interpreter

Version 4.0

I have just finished the first version of byte-code-interpreter.

This interpreter is still in test.After this test,i will release version 4.0!

Now i am trying to search hidden bugs in this interpreter.Hope you could help me! :)

There's an example of byte code below:

var (a,b,c)=(1,2,3);
.number 1
.number 2
.number 3
.symbol a
.symbol b
.symbol c
0x00000000: pone   0x00000000
0x00000001: load   0x00000000  (a)
0x00000002: pnum   0x00000001  (2)
0x00000003: load   0x00000001  (b)
0x00000004: pnum   0x00000002  (3)
0x00000005: load   0x00000002  (c)
0x00000006: nop    0x00000000