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

https://github.com/kashicode/simplescript

Interpreter built in C
https://github.com/kashicode/simplescript

c education

Last synced: about 1 year ago
JSON representation

Interpreter built in C

Awesome Lists containing this project

README

          

- Lexical analysis 🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦 100%
- Syntax analysis 🟦🟦🟦🟦🟦🟦🟦🟦⬜️⬜️ 80%
- Semantic analysis ⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️ 0%

## πŸ“Œ Language Example:

```
Value1(Int): 100
Value2(String): 'Hello'
Output{Value1}
Output{Value1,Value2}
Output{'this is a test'}
@ comment
Output{'enter your age'}

```

## πŸ“Œ Grammar rules

```
assignment: ':'
output: "Output" '{' ( (',' )*)? '}'
comment: '@'
variable:
type: "Int" | "String"
value: |
identifier: ( | )*
number: +
string_literal: "'" "'"
string_content: *
text: *
letter: [a-zA-Z]
digit: [0-9]
character: any valid character except for single quote
```

## πŸ“ŒLexer output

```
Token: Value1, Type: 0
Token: Int, Type: 1
Token: :, Type: 2
Token: 100, Type: 4
Token: Value2, Type: 0
Token: String, Type: 1
Token: :, Type: 2
Token: Hello, Type: 3
Token: Output, Type: 6
Token: {, Type: 7
Token: Value1, Type: 0
Token: }, Type: 8
Token: Output, Type: 6
Token: {, Type: 7
Token: Value1, Type: 0
Token: Value2, Type: 0
Token: }, Type: 8
Token: Output, Type: 6
Token: {, Type: 7
Token: this is a test, Type: 3
Token: }, Type: 8
Token: @ comment, Type: 5
Token: Output, Type: 6
Token: {, Type: 7
Token: enter your age, Type: 3
Token: }, Type: 8

```

## πŸ“Œ Parser output

```
Assignment: Variable = Value1, Value = 100
Assignment: Variable = Value2, Value = Hello
Output: Values = Value1
Output: Values = Value1 Value2
Output: Values = this is a test
Comment: This line is a comment
Output: Values = enter your age
```