paul@440 | 1 | Introduction
|
paul@440 | 2 | ============
|
paul@440 | 3 |
|
paul@450 | 4 | Lichen is both a Python-like language and a toolchain for that language. The
|
paul@450 | 5 | language foregoes various dynamic aspects of Python to provide a foundation
|
paul@450 | 6 | upon which more predictable programs can be built, while preserving essential
|
paul@450 | 7 | functionality to make the core of the language seem very much "like Python"
|
paul@450 | 8 | (thus yielding the name "Lichen"). The general syntax is largely identical to
|
paul@450 | 9 | Python, with only certain syntactic constructs being deliberately unsupported,
|
paul@450 | 10 | largely because the associated features are not desired.
|
paul@440 | 11 |
|
paul@440 | 12 | The toolchain employs existing tokeniser and parser software to obtain an
|
paul@440 | 13 | abstract syntax tree which is then inspected to provide data to support
|
paul@440 | 14 | deductions about the structure and nature of a given program. With the
|
paul@440 | 15 | information obtained from these processes, a program is then constructed,
|
paul@440 | 16 | consisting of a number of source files in the target compilation language
|
paul@440 | 17 | (which is currently the C programming language). This generated program may be
|
paul@450 | 18 | compiled and run, hopefully producing the results intended by the source
|
paul@450 | 19 | program's authors.
|
paul@450 | 20 |
|
paul@450 | 21 | Lichen source files use the .py suffix since the language syntax is
|
paul@450 | 22 | superficially compatible with Python, allowing text editors to provide
|
paul@450 | 23 | highlighting and editing support for Lichen programs without the need to
|
paul@450 | 24 | reconfigure such tools. However, an alternative suffix is likely to be
|
paul@450 | 25 | introduced in future.
|
paul@450 | 26 |
|
paul@450 | 27 | Getting Started
|
paul@450 | 28 | ===============
|
paul@450 | 29 |
|
paul@450 | 30 | The principal interface to the toolchain is the lplc command which can be run
|
paul@450 | 31 | on source files as in the following example:
|
paul@450 | 32 |
|
paul@450 | 33 | lplc tests/unicode.py
|
paul@450 | 34 |
|
paul@450 | 35 | This causes the inspection of the indicated program file and all imported
|
paul@450 | 36 | modules, the deduction and optimisation of program information, and the
|
paul@450 | 37 | generation and translation of the program to a form suitable for compilation.
|
paul@450 | 38 | By default, compilation is performed by invoking the widely-known make
|
paul@450 | 39 | utility.
|
paul@450 | 40 |
|
paul@450 | 41 | The results of this process are stored in the _lplc directory, with the
|
paul@450 | 42 | executable program being written out as "_main" in the working directory
|
paul@450 | 43 | unless the -o option is presented to lplc. For example:
|
paul@450 | 44 |
|
paul@450 | 45 | lplc -o unicode tests/unicode.py
|
paul@450 | 46 |
|
paul@450 | 47 | The executable program here will be written out as "unicode" and can be run
|
paul@450 | 48 | directly:
|
paul@450 | 49 |
|
paul@450 | 50 | ./unicode
|
paul@450 | 51 |
|
paul@450 | 52 | Since the executable program is merely C source code and can be compiled using
|
paul@450 | 53 | a normal C compiler, it may also be compiled using a cross compiler by setting
|
paul@450 | 54 | the ARCH environment variable. For example:
|
paul@450 | 55 |
|
paul@450 | 56 | ARCH=mipsel-linux-gnu lplc -o unicode tests/unicode.py
|
paul@450 | 57 |
|
paul@450 | 58 | This employs a cross compiler targeting the mipsel (little-endian MIPS)
|
paul@450 | 59 | architecture running GNU/Linux.
|
paul@440 | 60 |
|
paul@440 | 61 | Contact, Copyright and Licence Information
|
paul@440 | 62 | ==========================================
|
paul@440 | 63 |
|
paul@440 | 64 | See the following Web pages for more information about this work:
|
paul@440 | 65 |
|
paul@440 | 66 | http://projects.boddie.org.uk/Lichen
|
paul@440 | 67 |
|
paul@440 | 68 | The author can be contacted at the following e-mail address:
|
paul@440 | 69 |
|
paul@440 | 70 | paul@boddie.org.uk
|
paul@440 | 71 |
|
paul@440 | 72 | Copyright and licence information can be found in the docs directory - see
|
paul@440 | 73 | docs/COPYING.txt and docs/gpl-3.0.txt for more information.
|