Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/c71n93/language
Compiler for primitive programming language
https://github.com/c71n93/language
compiler
Last synced: about 7 hours ago
JSON representation
Compiler for primitive programming language
- Host: GitHub
- URL: https://github.com/c71n93/language
- Owner: c71n93
- Created: 2022-01-12T17:59:55.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-11T12:35:01.000Z (almost 3 years ago)
- Last Synced: 2024-11-15T16:48:28.999Z (2 months ago)
- Topics: compiler
- Language: C++
- Homepage:
- Size: 1.06 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# С(ringe)
The *С(ringe)* language is a simplified copy of the *C* language.The source code is compiled via AST into assembly code, that can be execute by [Processor](https://github.com/RomanKorostinskiy/Processor).
## С(ringe) grammar:
I used [EBNF](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax to describe grammar of my language.**Grammar for recursive descent:**
```
G ::= St+, '\0' ;St ::= [Cond | As | E | FuncDef], ';' ;
Blk ::= '{', St+, '}' ;
Cond ::= 'if', '(', E, ')', Blk, ['else', '(', ')', Blk] ;
As ::= Vas, '=', E ;
FuncDef ::= 'def', '!', Func, Blk ;
Func ::= Name, '(', ')' ;
StdFunc ::= ('print' | 'sqrt' | 'scan'), '(', E, ')' ;
E ::= T ((+ | -), T)* ;
T ::= P ((* | /), P)* ;
P ::= ('(', E, ')') | N | Var | StdFunc | Func ;
N ::= FloatingPointNumber ;
Var ::= Name ;
```**Grammar for tokenizer:**
```
Name ::= Letter, (Letter | Digit | "_")* ;Letter ::= ('a'-'z') | ('A'-'Z') ;
```
```
FloatingPointNumber ::= ['-'], ('0' | NaturalNumber), '.', NaturalNumber ;NaturalNumber ::= DigitExcludingZero, Digit* ;
Digit ::= '0' | DigitExcludingZero ;
DigitExcludingZero ::= ('1'-'9');
```## How to use Language:
**Input** - is a program in С(ringe) language. You should pass a path to source code in the first argument of programm.**Output** - is a assembly code. You should pass a path to place where you want to see your assembly code in the second argument of programm.