https://github.com/valkmjolnir/nas-sharp
A new script language and the subset of nasal
https://github.com/valkmjolnir/nas-sharp
compiler-principles interpreter language script
Last synced: about 2 months ago
JSON representation
A new script language and the subset of nasal
- Host: GitHub
- URL: https://github.com/valkmjolnir/nas-sharp
- Owner: ValKmjolnir
- Created: 2019-11-27T12:20:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-14T09:11:09.000Z (about 4 years ago)
- Last Synced: 2025-01-12T14:11:46.899Z (4 months ago)
- Topics: compiler-principles, interpreter, language, script
- Language: C++
- Size: 161 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nas-sharp script
this is a language for experiment
stack-based virtual machine
call-threading instruction dispatch
strong typing: cannot plus a number with a string(even this string is numerable)
LL(1) parser
easy to add your own built-in functions and use them
don't need to learn too much to use this language
# value types
function has closure
```javascript
var i=nil;
var i=1;
var i=0.1;
var i='str';
var i="str";
var i=[0,1,nil,[],{},func(){}];
var i={a:0,b:'str','s':[],s1:{}};
var i=func(x,elem...)
{
var sum=x;
for(var i=0;i hash.member_name;or
> hash['member_name'];
when calling a vector/string,use
> vec[index];
when calling a function,use
> fun(arguments);
```javascript
1+1;
2-2;
3*3;
4/4;
'hello '~'world';
!0;
!!0;
-1;i+=1;
i-=1;
i*=1;
i/=1;
i~='str';1==1;
1!=2;
1<2;
1<=2;
1>0;
1>=1;1 and 2;
1 or 2;
```# loop
```javascript
while(condition)
{
exprs;
continue;
break;
}
for(definition;condition;afterloop)
{
exprs;
continue;
break;
}
```# if-else
```javascript
if(1)
{
;
}
else if(2)
{
;
}
else
{
;
}
```