Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stynh/novabasicv2
Custom programming language interpreted in C#. I have no earlier experience building Interpreters. Hobby project.
https://github.com/stynh/novabasicv2
abstract-syntax-tree basic-programming csharp interpreter programming-language
Last synced: about 1 month ago
JSON representation
Custom programming language interpreted in C#. I have no earlier experience building Interpreters. Hobby project.
- Host: GitHub
- URL: https://github.com/stynh/novabasicv2
- Owner: StynH
- License: mit
- Created: 2023-11-28T10:35:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-13T11:31:59.000Z (about 1 year ago)
- Last Synced: 2023-12-13T16:37:45.351Z (about 1 year ago)
- Topics: abstract-syntax-tree, basic-programming, csharp, interpreter, programming-language
- Language: C#
- Homepage:
- Size: 2.79 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NovaBASICv2
![novabasic](https://github.com/StynVanDeHaterd/NovaBASIC/assets/9077578/80dc5727-aeb1-4a8d-b800-6cc74a2b202f)Second implementation of my own programming language called NovaBASIC. Made in C# .NET 8, using Blazor as front-end.
## Examples
Standard operations in NovaBASIC:### Variables
```
LET i = 50
IMMUTABLE j = 100
LET myArray = NEW[10]
```### Loops
```
FOR LET i = 0 TO 10
PRINT i
ENDFOR LET i = 0 TO 10 STEP 2
PRINT i
ENDLET j = 0
WHILE j < 10
PRINT j
j = j + 1
ENDWHILELET h = 10
REPEAT
PRINT h
h = h + 1
UNTIL h > 20
```### Functions & References
```
FUNC myFunc(arrRef, index)
arrRef[index] = 20
ENDFUNCLET myArray = NEW[5]
myFunc(REF myArray, 4)
```### If/Else
```
LET i = 6IF i % 2 == 0 THEN
PRINT "Value " + i + " is dividable by 2."
ELSEIF i % 3 == 0 THEN
PRINT "Value " + i + " is dividable by 3."
ENDIF
```### Switch
```
LET dayOfWeek = "Friday"SWITCH dayOfWeek
CASE "Monday":
PRINT "Start of the workweek"
BREAK
CASE "Friday":
PRINT "End of the workweek"
BREAK
DEFAULT:
PRINT "Middle of the workweek"
BREAK
ENDSWITCH
```### Guard
```
FUNC myFunc(param)
GUARD param < 20 ELSE
PRINT "Too much!"
RETURN null
ENDGUARDRETURN param * 50
ENDFUNCLET i = 10
LET j = 20
myFunc(i)
myFunc(j)
```### Type Checking
```
STRUCT Person
Name
ENDSTRUCTFUNC GetNameLength(p)
GUARD p IS Person ELSE
PRINT "Parameter must be a 'Person'!"
RETURN -1
ENDGUARDRETURN COUNT(p.Name)
ENDFUNCPRINT GetNameLength(NEW Person("Bob Ross"))
PRINT GetNameLength(25)
```### Array Slicing
```
LET arr = NEW[10]
LET firstTwo = arr[:3]
LET lastSeven = arr[3:]
LET between = arr[2:5]
LET inTwo = arr[1:10:2]
```### Import/Export (Desktop Only)
```
//File1.nova
IMMUTABLE myConst = 3.14STRUCT myStruct
Val
ENDSTRUCTEXPORT
myConst,
myStruct
ENDEXPORT//File2.nova
FUNC myFunc(var1)
PRINT var1
ENDFUNCEXPORT
myFunc
ENDEXPORT//File3.nova
IMPORT FROM "File1"
IMPORT "MyFunc" FROM "File2"LET i = NEW myStruct(myConst)
myFunc(i)
```