XScript: An object oriented language based on java
| _file_ | _line_ | _version_ | bigint | bigreal |
| bool | break | case | char | const |
| continue | def | default | do | else |
| false | for | if | import | instanceof |
| int | native | new | null | override |
| real | return | sizeof | string | struct |
| super | switch | this | true | virtual |
| while |
| name | size | init | name | size | init |
|---|---|---|---|---|---|
| char | 2 | '\0' | string | x | "" |
| int | 4 | 0i | real | 4 | 0.0r |
| bigint | x | 0I | bigreal | x | 0.0R |
| bool | 1 | false | |||
| struct | x | null | array | x | null |
while(bool-type expression) statementfor(def-expression;bool-type expression;expression) statementdo statement while(bool-type expression);if(bool-type expression) statementif(bool-type expression) else statementswitch(expression){expression should be int,char or stringcase constant-expression:expression should be constantbreak if jumping out is neededdefault:default casebreak;(in loops or switch)continue;(in loops)return expression;(in functions)def return-type func-name ( [param-type param-name,…] ){this variable in function body)
def return-type structure-name.func-name ([param-type param-name,…]){def structure-name.this([param-type param-name,…]){
2. function-body
3. }def return-type func-name([param-type param-name,…]);struct name;pre-declarationstruct name:base-name; pre-declaration with base structstruct name {def this([param-type param-name,…]);def this([param-type param-name,…]){def return-type func-name([param-type param-name,…]);def return-type func-name([param-type param-name,…]){struct derive-name:base-namedef [default] virtual return-type func-name([param-type param-name,…])def [default] override return-type func-name([param-type param-name,…])virtual,and so it can’t use overridestruct name {def return-type func-name([param-type param-name,…]);+,-,*,/,%,>,<,<=,>=, and types(except the self-type and array)+,-,*,* overloading should&only have 1 parameter whose type is the struct,
and return this struct type<,>,<=,>= overloading should&only have 1 parameter whose type is the struct,
and return-type should be bool==,!= is a built-in operation,they compared by reference,
disable their overloading to avoid confusionthis and super,but with super,it must have a base struct and this base struct must
have implemented this member(function or variable).import “file-path”;+= expression(variable’s type can be string)=,-=,*=,/=,%=) expression(%= only for int & char)type-name ) expressionvar-expression [expression]…-,!,++,--++,--+,-,*,/,%) expression(% for int & char)
==,!=,>,>=,<,<=) expression&&,||) bool-type expressionnew struct-type(arguments){def this(param-list){optional,default is from base structstatementsdef [virtual/override] ret-type func-name(param-list){statementsnew struct-type[^param-name-list]->{statements}new struct-type[^param-name-list]->expressionparam-names)This struct should and must have one default function(virtual).
And lambda expression can ignore params legally
int:only decimal integer is supported(ends with ‘i’ or less than IntMax)char:’character’(character includes escape character \n,\t,\r,\',\",\?,\b,\f,\\)string:”characters”real:just support decimal real number(ends with ‘r’ or less than RealMax)bool:true,falsebigint:integer larger than IntMax(or ends with ‘I’)bigreal:real larger than RealMax(or ends with ‘R’)null:used for array and structnew type [expression];expression should be integernew type[]{ init-list };array with initializationnew struct-type;struct has no defined initial functionsnew struct-type([argument,…]);struct has a defined initial functionsizeof array-type-expressiontrue or false)
instanceof basic-type_line_: line number of the source file_file_: file name of the source file_version_: compiler version(major-version * 100 + minor-version)_args_: command line arguments(runtime variable)nativeand then there comes 2 ways to do ex-struct definition:
Compose a struct by coding(it feels very bad)
Or compose a struct by class ExtensionStructHelper as following:
Init for struct initialization function
param for parameters’ typesStructMethod for struct member function
value :function name,java method name by defaultparam :parameters’ typesret :return typevirtual :if the function is virtualpurevirtual :if the function is pure virtual,if it is set,virtual is set.PassThisReference if you need pass this reference to this natively,
note that the java method needs an extra arg(typed Value or StructValue) for this in 1st positionclass-name stands for relative path native extension classclass-name stands for absolute path native extension classnew StructValue(symbols.Struct.StructPlaceHolder,xxxxx);,vm will dynamic cast its typedef return-type func-name([param-type param-name,…]) = expression;