Zom is a fast and secure programming language
zom-lang / zom Goto Github PK
View Code? Open in Web Editor NEWZom is a Ahead Of Time compiled system programming language.
License: Other
Zom is a Ahead Of Time compiled system programming language.
License: Other
For the code generation and compilation (LLVM related crates), in the Zom compiler. We could replace it with the C++ library, because it's the official way to use LLVM, there is some issues in this project that is related to LLVM not working : #24, #20, #23, #21. If we replace it with an a C++ package, we could just follow the doc and not wasting its time to found the function in Inkwell, etc ..
N°1
Write a serializer that serialize the result of the type checking (or the end of the compilation pipeline that doesn't need LLVM). And the C++ program will be executed in a child process, with the serialized input, and we deserialize and return the output desired by the compiler.
N°2
Write a C++ lib that uses LLVM and emit the desired output by the compiler, and his functions is called by the the Zom compiler with the Rust FFI
to C++.
Originally posted by @Larsouille25 in #25 (comment)
Change the enumerate in the lexer for an peekable.
After the transition to a Zom self compiling compiler, add colors to the errors. They can be dissabled using a flag are in the configuration.
This is a tracking issue for the RFC "var-const" (zom-lang/rfcs#2).
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or
open design questions. A tracking issue is however not meant for large scale
discussion, questions, or bug reports about a feature. Instead, open a dedicated
issue for the specific matter and add the relevant feature gate label.
Symbol
LocalSymbol
GlobalSymbol
N/A
Is your feature request related to a problem? Please describe.
Kinda yes. I want to be able when I want, start a benchmark and send the result in a floder on the repo.
Describe the solution you'd like
Implementing that -> https://github.com/benchmark-action/github-action-benchmark/blob/master/.github/workflows/criterion-rs.yml
Describe alternatives you've considered
Do it manually but it will be too painful.
All of these issues are in the same issue because it's easier to follow and because there are only small errors.
Err: Lexer, in file `<stdin>` at line 1 :
... |
1 | a@
... | ^
Illegal Character
~> func foo_bar(a, b)
> .eof
cannot parse integer from empty string
_
in identifiers, at the beginning and in the middle.Tracking issue for RFC-0001
.
This is a tracking issue for the RFC "primitives" (zom-lang/rfcs#3).
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or
open design questions. A tracking issue is however not meant for large scale
discussion, questions, or bug reports about a feature. Instead, open a dedicated
issue for the specific matter and add the relevant feature gate label.
char
str
\xNN
\n
\r
\t
\\
\0
\'
\"
usize
and isize
true
and false
keywordsundefined
keywordundefined
expressionN/A
Here is the list of things related to the language, that is needed to be implemented for the v0.1.0
milestone. And with there own RFC, -> #22
return
statementfor
loopwhile
looploop
loopwhile (true) { .. }
instead.continue
break
{ expr, expr, expr, ... }
defer
statements -> will be done in another version. Their is things more important for now$ident(...)
to $expr(...)
..*
deref operator and right unary operationa.b
Here is a list of things, we can change to improve error handling in the zom compiler :
zom_errors
LogStream
it would contain a vector of BuiltLog
with methods ->
BuiltLog
into the vector.BuiltLog
from a passed Log
and push into the vectorLog
that would contain all possible parsing error, with a dummy one: Custom
to create custom errors where there is not a logkind and creating a logkind would be overkill. Log
s will share to common fields : a reference counted to the file content and a RC to the file path. In general a log kind will take a location into the code.
Log
into BuiltLog
BuiltLog
containing a kind : warning / error / error with an error code, a description, an optional help message and a vector of note (a string). In general a BuiltLog is kinda dummy, it contains the line where the log cursor point, the cursor (just a range). A BuiltLog is an intermediate simple representation of a log.
Log
with a trait and make ExpectedToken and UnclosedDelimiter structs that implements the Log
trait and then use it in the builder for the logThis is a tracking issue for the RFC "operators" (zom-lang/rfcs#4).
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or
open design questions. A tracking issue is however not meant for large scale
discussion, questions, or bug reports about a feature. Instead, open a dedicated
issue for the specific matter and add the relevant feature gate label.
ParserSettings::default()
N/A
Add issues templates for:
ISSUE_TEMPLATE
and the link is the pre-rfc stream of the Zulip server.Is your feature request related to a problem? Please describe.
Add a README file in src/
and explain all the files / sub directories
Create type analyzer, that will infer type of expressions + create a typed AST in crate zom_typeizer
zom_parser
but with types annotated to expressions.comptime_int
and comptime_float
to make the type analyzer easier ??Is your feature request related to a problem? Please describe.
No, actually not but it's cool.
Describe the solution you'd like
when you're in the REPL, you can have mutli line, by pressing enter and when you finished you press ctrl + d
or a thing like that.
Additional context
Like that ->
Mona v0.1.0-alpha, to exit enter `.quit`
~> func foo(bar) {
. var a = bar
. a = bar + 2
. // etc ..
. }
${ctrl + d here}
~>
where ${ctrl + d here}
isn't show up but it's when the user press ctrl + d
Is your feature request related to a problem? Please describe.
Add error that clearly point to the code.
Describe the solution you'd like
Token
enum into TokenType
Token
that stores a TokenType and a range, named the span.After that the token stream has the location in the code.
CodeLocation
that will have a function span()
that return the span of the AST.CodeLocation
)In the reverse lexer, skip comments and empty lines.
If in the future, you have an error on a line greater than 99,999, you'll have an error by the formater.
By hardcoding the line number in the error message like that (in GeneralError, fmt implementation at line 140, at commit a190c95) and we make the REPL have a GeneralError (e.g., with float parsing error) :
// ...
num_str_fix_len(100_000, 5)
// ...
You have the following error :
thread 'main' panicked at 'attempt to subtract with overflow', src/error.rs:57:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It's the tracking issue of the RFC-0007
/*
to begin and */
to finish//
Clarify, packages, modules, create an import system in Zom:
import std.debug.println;
to import scope of the println function in the module. You can reexport symbols to another scole, with public imports,
pub import std.debug.println;
pub import std.test.assert;
pub import std.test.expect;
// ...
pub
isn't specified.pub
keyword in front of the item.export
in front of an Item, the name mangling is disabled, and the symbol is exported. It's meant to facilitate interop with C. And because names aren't mangled, an error is omitted if to export
ed symbol have the same namemod childmod {
// items ...
}
module declaration is an item so it can have a visibility identifier. Modules can also be declaraded from another file, like that:
mod modfile;
// main.zom and package named 'example':
fn main() void {} // => example.main
pub mod somecode {
fn hello() void { ... } // => example.somecode.hello
}
The idea is to make the Zom compiler like gcc
or rustc
, only one command with many options. And if anyone wants to make an alternative package manager they can do (for now their is no official package manager but one will come).
zom
to zomc
dev
, gettarget
, version
SOURCE_FILE
that is the main file, e.g: bor a bin, it's main.zom
, for a lib it's lib.zom
--verbose
, print to stdout more details.--version --verbose
shows the version + the commit hash + build date + target triple of the compiler.--target TARGET
, where TARGET is the target triple used when compiling with LLVM.--emit [asm|llvm-ir|llvm-bc|obj]
, comma separated list of types of output for the compiler to emit.--pkg-type [bin|zlib|lib|dylib|staticlib]
, what type of output the compiler will emit. zomlib
will be covered in an RFC, and for now it'll not be done but will be their.--pkg-name NAME
, specify the name of the package, used when the output filename isn't specified to determine a filename.--link-dir -L PATH
, add a directory to the library search path.--link -l NAME[:RENAME]
, link the generated package to the specified native library NAME. The RENAME is used if in the Zom source of the package you use another name for the library NAME.--error -E [human|json]
, how stdout will look like. human
is beautiful error messages, human readable. json
is to print a json with the error if there is.--opt LEVEL
, optimization level, used by LLVM optimizer.--output -O FILENAME
, write output to FILENAME--output-dir DIR
, write the output in the DIR with the filename based on the package name.First Mona
was chosen because I had the idea to make the syntax in French. So Idk why but the idea of Mona Lina (la Joconde in french) popped up in my head. But with almost a month passed, I don't like the name Mona
, the project changed a lot, the first idea was an interpreted language like Python. But now it's a safe and still light alternative to C.
<name>_fe
, <name>_codegen
etcMona
in the source codeMona
in the docs.Mona
lld
library to interact with in rust and latter in Zom.bin
, staticlib
, lib
, dylib
.stripped
to strip a binary or a lib.zlib
file format. That will contains all metadata, like function name, function full path, enum entries, structs fields and types of structs, everything. It will be used to compile Zom Library, it will be used as default to Zom libs. That will facilate the compiler job, and in particular the @Import(..)
builtin function.Questions
I don't know exactly if just use the metadata things provided by LLVM could do the job, or if I .zlib
will be archive that contains the compiled code + metadata ?
It's said in e769064 that the parser can partialy return multiple errors, it's normal and it can only return multiple errors when an unexpected token is in the while let
loop of the function parse() because after the smaller function need to return something and for the moment I don't know how to do it.
But it's planed to when an error occur while parsing a function definition or declaration, to skip tokens related to this AST and push the error into the list and continue parse other function definition / declaration etc ...
Originally posted by @Larsouille25 in #30 (comment)
Some improvements :
expect_token!
macro when the token we got isn't what we would want, push the error with context.push_err
and try to recall the macro, but idk if it's a good idea ??Describe the bug
The CI doesn't have LLVM so when working code is pushed, there is a compile error
Expected behavior
The CI should, if the code works says that's working.
Kinda, for verifying and test Mona, it should have unit tests.
Adding Unit / Integration test for every important functions / struct like Lexer, Parser, ASTNode etc...
zomc
zom_fe
zom_common
zom_codegen
zom_compiler
In the binary zom
, replace all anyhow errors with custom made errors in zom_common
.
ZomError
struct,Error
trait.location
optional.IllegalCharError
with a function (or macro) that create a new ZomError.EOF
tokenzom
, replace anyhow errors with ZomError.anyhow = { version = "1.0.71", default-features = false }
, in zom/Cargo.toml
To facilitate debugging of the code and why there is errors,
Vec<Result<..,..>>
instead of Result<vec<..>,..>
Result<(Vec<ASTNode>, Vec<Token>), ZomError>
to Result<Vec<ASTNode>, Vec<ZomError>>
-> #30 (comment)In another branch,
To clarify and standardize how Zom work, I've created the repository zom-lang/rfcs that contain all document, but we need to wrote all RFC.
var
& const
, RFC-0002for
loop & while
loop & loop
, RFC-0006/docs/lang/
and its content.Mark as done when the PR is merged.
=> see zom-lang/rfcs#9 so, before writing the docs
feat/docs-compiler
docs/
feat/docs-compiler
)Change the Apache-2.0
+ MIT
dual licensing to a Apache-2.0
with LLVM Exception
?
Is your feature request related to a problem? Please describe.
The CI says LLVM isn't installed but there is an action to install it. After an issue opened here, the CI needs to install llvm-config
with the according version of LLVM. (for the moment as long as this issue is not closed, the CI will be deactivated)
Describe the solution you'd like
Install, rather compile llvm with https://github.com/llvmenv/llvmenv
Describe alternatives you've considered
Create a github action that compiles LLVM and install it but too long and maybe later I'll do it but now I don't have time.
I'm not very happy with the current, project, I realize that Mona is more a Ahead Of Time compiled programming language than a Just In Time compiled one. So here is the steps to modify Mona to be a AOT compiled one :
Remove all things related to JIT, so the REPL, in src/driver.rs
.
Move the src/main.rs
in src/bin/main.rs
because later, subcommands will have there own module, in the binary.
mona_fe
will be the lexer, parser, token.mona_common
will be all common things like errors.mona_codegen
will be a crate that transform an AST to "LLVM IR".mona_build
mona_compiler
will be the thing that transform the "LLVM IR" to object filesmona
will be the binary, the thing that use all of the other ones to make a project.mona_mem
or mona_gc
Make a CI for mona_fe
mona_common
Adding subcommand bobj
that transform a .mn
to an object file.
#29 -> This is for 0.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.