Giter Club home page Giter Club logo

lemon's Introduction

The Lemon Programming Language

Overview

  • src source code of Lemon compiler and virtual machine
  • lib source code of core Lemon library
  • doc documentations of source code
  • test test code

Getting Source

$ git clone https://github.com/lemon-lang/lemon.git

Build Instructions

make

or

make DEBUG=0 STATIC=0 USE_MALLOC=0 MODULE_OS=1 MODULE_SOCKET=1
  • DEBUG, debug compiler flags, 0 is off.
  • STATIC, 0 build with dynamic-linked library, 1 build with static-linked.
  • USE_MALLOC, stdlib's malloc ensure return aligned pointer
  • MODULE_OS, POSIX builtin os library
  • MODULE_SOCKET, BSD Socket builtin library

Windows Platform

Lemon can build on Windows via TDM-GCC, getting source code and use command

mingw32-make

Porting

lib/os.c and lib/socket.c are support POSIX and Windows environment.

Contributing

  1. Accept Developer Certificate of Origin by adding Signed-off-by: Your Name <[email protected]> to commit log.
  2. Check Code Style.
  3. Send patch to commiter.

License

Copyright (c) 2017 Zhicheng Wei

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

lemon's People

Contributors

shatuda avatar zhicheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lemon's Issues

A couple of questions

First of all, great job; I love your coding style, it's super clean.

If I may, I would like to ask a couple of questions:

  • What led you, frustrated you, or even motivated you to build a new language?
  • What problems are you trying to solve?
  • Is it GIL-free?
  • Is it thread-safe by default?
  • JIT support please?
  • Any plans for generics support?

That's it for now.

Keep up the good work ๐Ÿ‘

Uncontrolled process operation

In line 2300 of compiler.c:

handle = dlopen(module_path, RTLD_NOW);

Using externally controlled strings in a process operation can allow an attacker to execute malicious commands.

Using the return value from snprintf without proper checks can cause overflow.

The size arguments of the following snprintf calls are derived from their return values, which may exceed the size of the buffer and overflow.

The return value of a call to snprintf is the number of characters that would have been written to the buffer assuming there was sufficient space. In the event that the operation reaches the end of the buffer and more than one character is discarded, the return value will be greater than the buffer size. This can cause incorrect behavior.

In line 312 of larray.c:

		length = snprintf(buffer + offset,
		                  maxlen - offset,
		                  fmt,
		                  lstring_to_cstr(lemon, string));

and
In line 357 of ltable.c:

		length = snprintf(buffer + offset,
		                  maxlen - offset,
		                  fmt,
		                  lstring_to_cstr(lemon, key),
		                  lstring_to_cstr(lemon, value));

How to build on Android using clang?

Termux don't have gcc.The only available c/cpp compiler is clang.
Current Makefile will generate an error that "couldn't find gcc-ar".
Thanks!

delete this

hey
please delete or rename

i literally built my whole personality around a language called lemon-lang and you are breaking my heart

https://github.com/imagine-hussain/lemonlang

It is based off my best friend luke-fisk-lennon who's brother died of cancer so we want to write a language in his honour :(

pls bro i beg u bro pls i am litarlly crying rn pls change name

.NET binding

ham2kh

Hello! I would like to say i discovered this language few days ago and instantly became a fan of it because it's easy to embed and not hard to learn.

I wanted to shout out here that i'm making a .NET binding for it because C# is my main language and i'd like to use this from time to time in some projects there.

https://github.com/cartman300/lemonade

The main repository is added as a submodule and compiles in visual studio just fine with some external supporting headers and without modifying the source code. ๐Ÿ‘

Also a side question, would it be possible to add a function similar to lemon_machine_execute and lemon_machine_execute_loop which only steps trough N machine instructions and returns back to the caller? I see this being useful when embedding the language into a video game update loop, it would prevent stuff like while (true) { } from hanging the game.

Almost a JS

Looks like Lemon is close to JS so why not to make it as a subset of JS?

Building on Windows?

Could this be possible? I've noticed that lemon depends on Linux specific libraries like select.h. Please keep in mind that all of us aren't running on the same OS as you.

drop var

the var here adds nothing:
def hello(var name) {

Unbounded write by strcpy

In line 2310 of compiler.c:

strcpy(init_name, module_name);

This 'call to strcpy' with input from call to getenv may overflow the destination.

Inconsistent null checks

symbol = scope_add_symbol(lemon,

lemon/lib/os.c

Line 369 in b1bb8a6

tmobject = lobject_create(lemon, sizeof(struct ltmobject), ltmobject_method);

symbol = scope_add_symbol(lemon, lemon->l_global, name, SYMBOL_GLOBAL);

frame = machine_peek_frame(lemon);

The functions called in these lines are consistently checked for null except in these instances. The lack of a null check could mask bugs.

history support

Lemon does not support retrieving the history via arrow keys. Is it possible to implement GNU Readline to support shell-like shortcuts?

lemon-issue

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.