View Docs on my Website here. It currently contains almost all of the information provided in this README file in a more organized fashion. For prebuilt downloads, click here. Eventually, most of the documentation in this README file will no longer be provided here, but instead will be provided on the Website (with exception to compilation details, which will be kept in this README file).
Lydrige is a simple statically typed interpreted programming language inspired by Lisp. Although originally inspired by Lisp, there are some changes which make the Syntax of the language appear more C-like. Right now the language supports: functions, lists, list-manipulation, input, string, casting, casting a string into different values (string to int, etc.), and more!
You can find even more information about this language on my website at http://krixano.x10host.com/Lydrige, which includes:
The syntax is similar to the syntax in Lisp. You have an expression that has other expressions or data inside and is separated by spaces. When evaluating an expression, the first item should be a function. This is, however, not needed for List Literals and Q-Expressions.
Here is an example of the syntax of a simple print statement:
(print "This number evaluates to" (+ 1 1))
. This print statement returns ()
but does print out the arguments to the screen before the return.
print "This number evaluates to" (+ 1 1);
You can view an example of what a simple program would look like in version 0.6.0 when this version is complete in the examples/0.6.0NewSyntax.lydg file. This file explains many of the different features of the language and includes changes in version 0.6.0a. This version is not ready to be able to interpret this file yet. However, there are some examples that will work with the current feature-set in the Examples
section below.
Here are the builtin functions in the language. Many of these builtin functions are very common, therefore they were written directly into the interpreter rather than a library. Note that this list does not include the basic operators and conditionals (ex: +, -, *, /, %, ^ (power), ==, >, <, >=, <=, !=), however, they do exist within the langauge.
list
- returns a q-expression with all of the given arguments inside. (list 5 4 4 3;
returns [5, 4, 4, 3]
)first
- returns the first item in a given q-expression or list literal. (first [5, 4, 4, 3];
returns 5
)last
- returns the last item in a given q-expression or list literal. (last [5, 4, 4, 3];
returns 3
)head
- returns all but the last item from a given q-expression or list literal in a new q-expression. (head [5, 4, 4, 3];
returns [5, 4, 4]
)tail
- returns all but the first item from a given q-expression or list literal in a new q-expression. (tail [5, 4, 4, 3];
returns [4, 4, 3]
)join
- joins two lists together into a single list. (join [5, 4] [4, 3];
returns [5, 4, 4, 3]
)get
- gets item from given list at given index. (get 0 [5, 4, 4, 3];
returns 5
)set
- returns a new q-expression with the item at the given index of given q-expression set to a given value. Doesn't modify original q-expression. (set 0 4 [5, 4, 4, 3];
returns [4, 4, 4, 3]
)len
- returns the length of a given list. (len [5, 4, 4, 3];
returns 4
)typeof
- returns the type of the given value. (typeof [5, 4, 4, 3];
returns array
)print
- prints text to the screen. Returns 1
(print [5, 4, 4, 3] 23.5;
will print [5, 4, 4, 3] 23.5
and return 1
)Here are all of the data types in Lydrige and how you represent them within the language:
int
- simple number (ex: 12
)double
- number with decimal (ex: 12.0
)char
- character surrounded by single quotes (ex: 'c'
)string
- strings are surrounded by double quotes (ex: "this is a string"
)array
- a list of elements which are evaluated, but not the array itself. They are implemented as a value that allocates its elements on the heap in contiguous memory. They are not dynamic! (ex: [+, 1, (+ 1 1)]
returns [+, 1, 2]
)qexpression
- a list in which its children and itself are not evaluated until the qexpression is evaluated. These are very similar to Quotes in Scheme. (ex: {+ 3 (+ 3 3)}
doesn't evaluate, unless function it's passed to evaluates it)qidentifier
(aka symbol
or dotted identifier
) - An identifier that acts like a qexpression. The identifier is not automatically evaluated until passed to the eval function, or a function that does this (for example, the def
function). Note that the syntax has been recently changed to use a dot instead of a quote. Therefore you can call these dotted indentifiers
. (ex: .ident_name
is an identifier that is not evaluated until passed into a function that does so) (Former Syntax: 'ident_name
)There are examples of programs/functions written in this language in the examples directory
. Note that this directory contains code that only works for v0.5.0! It will not work with this version! This directory also includes prelude.lydg, the Prelude for the language, which is auto-loaded in the REPL and in every lydrige program (although, this is not the case for v0.6.0 until the interpreter has been fully rewritten). You can also find files for each of the Standard Library "modules" in the stdlib directory
. A sample of how I envision the language to look when v0.6.0 is released can be found in the examples/0.6.0NewSyntax.lydg
file.
Until Lydrige is fully rewritten, these examples won't currently work. However, some examples that do currently work are provided below:
print 5.2;
print (+ 3 4.4);
print (join [5, 4, 3, 3] [2, 2, 3]);
print (+ 1 (get 0 [3, 2, 2]));
print {3 3 unbound (unbound_also 3 3)};
print .symbol .also_known_as_dotted_identifier;
Run make debug
to make the debug build or make release
to make the release build. To run the debug build, enter make run-debug
, and for the release build, enter make run
.
GCC: Run build.bat gcc x64
for 64-bit, or build.bat gcc x86
for 32-bit.
Clang: Run build.bat clang x64
for 64-bit, or build.bat clang x86
for 32-bit.
MSVC: Run build.bat msvc x64
for 64-bit, or build.bat
for 32-bit.
To start the program, run build.bat run
.
You must install devel/gmake
in order to use the Makefile. Run gmake debug
to make the debug build or gmake release
to make the release build. To run the debug build, enter gmake run-debug
, and for the release build, enter gmake run
.
I have provided a tmLanguage file to get Syntax Highlighting for Lydrige in Sublime Text. It is not complete yet, as there are still a few bugs and other things to implement.
See LICENSE.md and LICENSE-3RD-PARTY.txt
Lydrige Version v0.6.0a Copyright (c) 2016-2017, Christian Seibold All Rights Reserved. Under MIT License
Uses MPC Library under the BSD-2-Clause License Copyright (c) 2013, Daniel Holden All Rights Reserved https://github.com/orangeduck/mpc/
Uses Linenoise Library under the BSD-2-Clause License
Copyright (c) 2010-2014, Salvatore Sanfilippo