Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/alexdremov/ngg

"Never gonna give you up" programming language
https://github.com/alexdremov/ngg

ast compiler education language meme never-gonna-give-you-up programming-language

Last synced: about 3 hours ago
JSON representation

"Never gonna give you up" programming language

Awesome Lists containing this project

README

        

# NGG
**Never Gonna Give** (you up) programming language

Language with the power of the legend. Code can be executed on [SPU](https://github.com/AlexRoar/SPUAsm)

# Syntax

[Beautiful PDF](https://github.com/AlexRoar/NGG/raw/main/NGG.pdf)

*Main*

Start ::= {FuncDecl | VarDefStmt}*

*Identifier*

Identifier ::= Identifier[Character {Character | Number}*]
Number ::= Number[Digit+]
Digit ::= "regexp:[0-9]"
Character ::= EngCharacter | '_'
EngCharacter ::= "regexp:[a-zA-Z]"

*Function essentials*

FuncDecl ::= FDecl['never gonna'] Identifier
LPA['('] ArgumentsList? RPA[')'] BlockStmt
ArgumentsList ::= Identifier {Comma[','] Identifier}*
CallList ::= rValue {Comma[','] rValue}*

*Values*

rValue ::= AddSubExpr {(Eq['=='] | Leq['<='] | Geq['>=']
| Neq['!='] | Gr['>']| Le['<']) AddSubExpr}?
AddSubExpr ::= MulDivExpr
{(Plus['+'] | Minus['-']) MulDivExpr}*
MulDivExpr ::= UnaryExpr {(Mul['*'] | Div['/'] | Pow['^']) UnaryExpr}*
UnaryExpr ::= ((Plus['+'] | Minus['-']) PrimaryExpr)
| PrimaryExpr
PrimaryExpr ::= LPA['('] rValue RPA[')']| Input | Number | FuncCall |
Identifier
FuncCall ::= Identifier LPA['('] CallList? RPA[')']

*Blocks*

BlockStmt ::= BStart['strangers'] Statement* BEnd['to love']
Statement ::= (VarDef | Print | AssignExpr |
FuncCall) StEnd['bdum']
| ReturnStmt | IfStmt | WhileStmt | BlockStmt

AssignExpr ::= Identifier (Assg['='] | AdAssg['+='] |
MiAssg['-=']
| MuAssg['*='] | DiAssg['/=']) rValue
VarDef ::= VDecl['make you'] (Identifier Assg['=']
rValue | Identifier )
VarDefStmt ::= VarDef StEnd['bdum']
Print ::= Print['goodbye'] rValue
Input ::= Input['ask me']

*Control Sequences*

IfStmt ::= If['you know the rules']
LPA['('] rValue RPA[')']
BlockStmt {Else['and so do I'] BlockStmt}?
WhileStmt ::= While['run around']
LPA['('] rValue RPA[')'] BlockStmt
ReturnStmt ::= Return['known each other for so long'] rValue
StEnd['bdum']
# Memory management

… | global variables | stack memory

| Use | Register |
|:--|:--|
| Bp register | rex |
| Tmp calculations | rax |
| Tmp calculations2 | rbx |

# Example

```
never gonna giveYouUp() strangers
goodbye fact(ask me) bdum
to love

never gonna fact(num) strangers
you know the rules (num <= 1) strangers
known each other for so long 1 bdum
to love and so do i strangers
known each other for so long fact(num - 1) * num bdum
to love
to love
```