Have you ever wondered how programming languages actually work under the hood? Do you believe that languages are just magical entities?
In this project, I set out to create a simple stack-oriented programming language and its syntax looks like JSX (because I love react js 😊) and all of that using the Go programming language with 0 dependencies. Inspired by my curiosity and desire to understand the inner workings of languages, this project served as an educational endeavor to demystify the magic behind programming languages, even it just an interpreted language not a compiled language but it worth it.
Download jsx-language from the releases then create a file and run:
./jsx-language [file path]
start with #
Math operations: +
& -
& *
& /
& %
Supported values:
-
string
-
number
-
array
-
boolean
-
object member call
<App>
<Let id={"name"} value={"Mohammad"}/>
<App/>
<App>
<Let id={"num"} value={1 1 +}/>
<App/>
<App>
<Let id={"data"} value={[1,"hi",false]}/>
<App/>
<App>
<Let id={"data"} value={[1,"hi",false]}/>
<Let id={"dataLength"} value={data array.length()}/>
<App/>
Logical operators:
-
==
-
!=
-
greater
like>
-
smaller
like<
<App>
<If condition={1 2 greater}>
...
<If/>
<App/>
<App>
<For var={"i"} from={0} to={10}>
<Print value={i}/>
<For/>
<App/>
<App>
<For var={"i"} from={0} to={10}>
<If condition={i 2 greater}>
<Print value={i}>
<Break/>
<If/>
<For/>
<App/>
<App>
<For var={"i"} from={0} to={10}>
<If condition={i 2 ==}>
<Continue/>
<If/>
<Print value={i}>
<For/>
<App/>
<App>
<Function id={"Sum"} args={"x","y"}>
<Print value={x y +}>
<Function/>
<App/>
<App>
<Sum x={1} y={2}/>
<App/>
// [array] array.length()
<App>
<Let id={"data"} value={[1,2,"hello",false,423]}/>
<Print value={data array.length()}/>
<App/>
// [array] [index] array.at()
<App>
<Let id={"data"} value={[1,2,"hello",false,423]}/>
<Print value={0 data array.at()}/>
<App/>
// [array] [value] array.push()
<App>
<Let id={"data"} value={[]}>
<Print value={"hello" data array.push()}/>
<App/>
// [array] array.pop()
<App>
<Let id={"data"} value={[1,2,3]}>
<Print value={data array.pop()}/>
<Print value={data}/>
<App/>