Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/polinasavelyeva/simplelanguage

Simple programming language with parser, interpreter and code analyzer
https://github.com/polinasavelyeva/simplelanguage

intrepreter optimizer parser-combinators

Last synced: about 2 months ago
JSON representation

Simple programming language with parser, interpreter and code analyzer

Awesome Lists containing this project

README

        

# SimpleLanguage

This repository contains simple programming language with parser, interpreter and code analyzer. The language includes basic constructs such as conditional and print statements, variable assignment and logical expressions.

## Syntax

### Conditional Statement

The syntax for the `if` statement is as follows,

```fsharp
if:then:

else:

end
```

where
- `` represents a boolean expression which contains operators such as `<`, `&&`, boolean variables [etc](#logical-expressions).
- `` could be one or more statements e.g [print](#print-statement), [variable assignment](#variable-assignment) or other if statements. Make sure there are no tabs between the if-else construction and the statements. Line breaks are also required, as they appeared on the code-syntax block.

### Variable Assignment

The syntax for variable assignments is as follows,

```fsharp
=
```

where
- `` is the name of the variable. It can only be a sequence of lowercase letters.
- `` one of the available [logical](#logical-expressions) or [arithmetic](#arithmetic-expressions) expressions.

### Print Statement

The syntax for the `print` statement is as follows,

```fsharp
print:
```

where
- `` one of the available [logical](#logical-expressions) or [arithmetic](#arithmetic_expressions) expressions.

### Logical Expressions

Logical expressions can be used in every statement. The supported operators are:

- `==` equal
- `<` less than
- `>` greater than
- `<=` less than or equal
- `>=` greater than or equal
- `!=` inequality
- `&&` logical and
- `||` logical or

### Arithmetic Expressions

Arithmetic expressions can be used in every statement. The supported operators are:

- `+` addition
- `*` multiplication

## Examples

Here are some examples of code written in this language:

```fsharp
if:true>falsethen:
x=true
print:x