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: 11 months 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 (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-13T11:31:59.000Z (over 2 years ago)
- Last Synced: 2025-07-01T10:03:49.523Z (11 months ago)
- Topics: abstract-syntax-tree, basic-programming, csharp, interpreter, programming-language
- Language: C#
- Homepage:
- Size: 2.79 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NovaBASICv2

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
END
FOR LET i = 0 TO 10 STEP 2
PRINT i
END
LET j = 0
WHILE j < 10
PRINT j
j = j + 1
ENDWHILE
LET h = 10
REPEAT
PRINT h
h = h + 1
UNTIL h > 20
```
### Functions & References
```
FUNC myFunc(arrRef, index)
arrRef[index] = 20
ENDFUNC
LET myArray = NEW[5]
myFunc(REF myArray, 4)
```
### If/Else
```
LET i = 6
IF 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
ENDGUARD
RETURN param * 50
ENDFUNC
LET i = 10
LET j = 20
myFunc(i)
myFunc(j)
```
### Type Checking
```
STRUCT Person
Name
ENDSTRUCT
FUNC GetNameLength(p)
GUARD p IS Person ELSE
PRINT "Parameter must be a 'Person'!"
RETURN -1
ENDGUARD
RETURN COUNT(p.Name)
ENDFUNC
PRINT 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.14
STRUCT myStruct
Val
ENDSTRUCT
EXPORT
myConst,
myStruct
ENDEXPORT
//File2.nova
FUNC myFunc(var1)
PRINT var1
ENDFUNC
EXPORT
myFunc
ENDEXPORT
//File3.nova
IMPORT FROM "File1"
IMPORT "MyFunc" FROM "File2"
LET i = NEW myStruct(myConst)
myFunc(i)
```