A simple language transpiling to Python
Project description
Ash
A simple language transpiling to Python or interpreted. The default implementation of the transpiler and interpreter are written in Python 3.
Summary
Introduction
- First step with Ash 1.A Hello World! 1.B Comments 1.C Keywords
- Variables and constants
- Types and operators
- Functions and procedures
- Classes and objects
- Modules
- Exceptions
- Standard library
- Interacting with Python
- Links
Conclusion
Introduction
Todo
1. First steps with Ash
1.A Hello, World!
This program writes on the standard output the string Hello, World!
ash> writeln("Hello, World!")
The function writeln
writes on the standard output one or more arguments, goes to the next line and come back at its first position, on the left. It takes here only one argument, the string "Hello, World!". The entire line is a statement.
This second program below writes on the standard output the string What is your name? then reads a string stored in the variable name.
ash> name = read('What is your name?')
ash> writeln("Hello", name)
The function read
reads a string on the standard input. This code is composed of two lines, each line being a statement. But you can write the same example this way also:
ash> name = read('What is you name?') ; writeln("Hello", name)
This time, we have only one line composed of two statements separated by a ;
, called the statement separator. For both ways, the function writeln
is called this time with two arguments, the string literal "Hello" and the variable name. This function accepts a variable number of arguments.
1.B Comments
A comment is a text ignored by the interpreter. It does nothing. The transpiler with recopy the text in the transpiled output.
-- This is a comment
1.C Keywords
Ash uses 26 keywords which mustn't be used as variable or constant names:
- Nil literal:
nil
- Boolean literals:
true
,false
- Operators:
and
,or
,not
,xor
- Choice:
if
,then
,elif
,else
,end
- Loop:
while
,do
,end
,break
,next
- Subprogram:
fun
,pro
,return
- Class:
class
- Module:
import
- Exceptions:
try
,when
,finally
,raise
2. Variables and constants
Declare and assign a variable:
a = 5
Declare, assign and restrict a variable to a type:
a : int = 5
A constant starts with a capital letter and cannot be changed through the execution of the script:
A = 5
3. Types and operators
int
for integerflt
for floatbool
for boolean"..."
or'...'
for strings[a, b]
for list[a = 5, b = 34]
for hash
4. Functions and procedures
Todo
5. Classes and objects
Todo
6. Modules
Todo
7. Exceptions
Todo
8. Standard library
Todo
9. Interacting with Python
Todo
10. Links
Todo
Conclusion
Damien Gouteux 2020
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ashlang-0.0.2.tar.gz
.
File metadata
- Download URL: ashlang-0.0.2.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a21e9494fe478d680cfeafa5cf190092f77d30b0b5f35cfc15707a33bad1ee11 |
|
MD5 | bfc372ee6952c94f6d5ab43bc5bb27b9 |
|
BLAKE2b-256 | 20d582f92eae1bb2163c01894183fa7b454fa769782acfdfb7350b67c4db577b |
File details
Details for the file ashlang-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: ashlang-0.0.2-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df9a3fab1c22e90ecaa77015fb78168a51e1c56f86c139422bbcc7db9c31e721 |
|
MD5 | 1bb23b4d79604b6e8c7971155bdfea66 |
|
BLAKE2b-256 | a5bf4575cd7348c6959d34b0f4c0be6802324c9888153e5840a8fe0d328ead5d |