Вы находитесь на странице: 1из 10

Ring Documentation, Release 1.

97.2 Language Functions

Functions Count : 197


len() add() del() sysget() clock() lower()
upper() input() ascii() char() date() time()
filename() getchar() system() random() timelist() adddays()
diffdays() version() clockspersecond() prevfilename() swap() shutdown()
isstring() isnumber() islist() type() isnull() isobject()
hex() dec() number() string() str2hex() hex2str()
str2list() list2str() left() right() trim() copy()
substr() lines() strcmp() eval() raise() assert()
isalnum() isalpha() iscntrl() isdigit() isgraph() islower()
isprint() ispunct() isspace() isupper() isxdigit() locals()
globals() functions() cfunctions() islocal() isglobal() isfunction()
iscfunction() packages() ispackage() classes() isclass() packageclasses()
ispackageclass() classname() objectid() attributes() methods() isattribute()
ismethod() isprivateattribute() isprivatemethod()
addattribute() addmethod() getattribute()
setattribute() mergemethods() packagename() ringvm_fileslist()
ringvm_calllist() ringvm_memorylist()
ringvm_functionslist() ringvm_classeslist() ringvm_packageslist()
ringvm_cfunctionslist() ringvm_settrace() ringvm_tracedata()
ringvm_traceevent() ringvm_tracefunc() ringvm_scopescount()
ringvm_evalinscope() ringvm_passerror() ringvm_hideerrormsg()
ringvm_callfunc() list() find() min() max() insert()
sort() reverse() binarysearch() sin() cos() tan()
asin() acos() atan() atan2() sinh() cosh()
tanh() exp() log() log10() ceil() floor()
fabs() pow() sqrt() unsigned() decimals() murmur3hash()
fopen() fclose() fflush() freopen() tempfile() tempname()
fseek() ftell() rewind() fgetpos() fsetpos() clearerr()
feof() ferror() perror() rename() remove() fgetc()
fgets() fputc() fputs() ungetc() fread() fwrite()
dir() read() write() fexists() int2bytes() float2bytes()
double2bytes() bytes2int() bytes2float()
bytes2double() ismsdos() iswindows()
iswindows64() isunix() ismacosx() islinux() isfreebsd() isandroid()
windowsnl() currentdir() exefilename() chdir() exefolder() loadlib()
closelib() callgc() varptr() intvalue() object2pointer() pointer2object()
nullpointer() space() ptrcmp() ring_state_init()
ring_state_runcode() ring_state_delete()
ring_state_runfile() ring_state_findvar() ring_state_newvar()
ring_state_runobjectfile()

97.3 Compiler Errors

Error (C1) : Error in parameters list, expected identifier


Error (C2) : Error in class name
Error (C3) : Unclosed control strucutre, ok is missing
Error (C4) : Unclosed control strucutre, end is missing
Error (C5) : Unclosed control strucutre, next is missing
Error (C6) : Error in function name

97.2. Language Functions 1725


Ring Documentation, Release 1.5

Error (C7) : Error in list items


Error (C8) : Parentheses ) is missing
Error (C9) : Brackets ] is missing
Error (C10) : Error in parent class name
Error (C11) : Error in expression operator
Error (C12) : No class definition
Error (C13) : Error in variable name
Error (C14) : Try/Catch miss the Catch keyword!
Error (C15) : Try/Catch miss the Done keyword!
Error (C16) : Error in Switch statement expression!
Error (C17) : Switch statement without OFF
Error (C18) : Missing closing brace for the block opened!
Error (C19) : Numeric Overflow!
Error (C20) : Error in package name
Error (C21) : Unclosed control strucutre, again is missing
Error (C22) : Function redefinition, function is already defined!
Error (C23) : Using ( after number!
Error (C24) : The parent class name is identical to the subclass name
Error (C25) : Trying to access the self reference after the object name
Error (C26) : Class redefinition, class is already defined!

97.4 Runtime Errors

Error (R1) : Cannt divide by zero !


Error (R2) : Array Access (Index out of range) !
Error (R3) : Calling Function without definition !
Error (R4) : Stack Overflow !
Error (R5) : Cant access the list item, Object is not list !
Error (R6) : Variable is required
Error (R7) : Cant assign to a string letter more than one character
Error (R8) : Variable is not a string
Error (R9) : Using exit command outside loops
Error (R10) : Using exit command with number outside the range
Error (R11) : error in class name, class not found!
Error (R12) : error in property name, property not found!
Error (R13) : Object is required

97.4. Runtime Errors 1726


Ring Documentation, Release 1.5

Error (R14) : Calling Method without definition !


Error (R15) : error in parent class name, class not found!
Error (R16) : Using braces to access unknown object !
Error (R17) : error, using Super without parent class!
Error (R18) : Numeric Overflow!
Error (R19) : Calling function with less number of parameters!
Error (R20) : Calling function with extra number of parameters!
Error (R21) : Using operator with values of incorrect type
Error (R22) : Using loop command outside loops
Error (R23) : Using loop command with number outside the range
Error (R24) : Using uninitialized variable
Error (R25) : Error in package name, Package not found!
Error (R26) : Calling private method from outside the class
Error (R27) : Using private attribute from outside the class
Error (R28) : Using bad data type as step value
Error (R29) : Using bad data type in for loop
Error (R30) : parent class name is identical to child class name
Error (R31) : Trying to destory the object using the self reference
Error (R32) : The CALL command expect a variable contains string!
Error (R33) : Bad decimals number (correct range >= 0 and <=14) !
Error (R34) : Variable is required for the assignment operation
Error (R35) : Cant create/open the file!
Error (R36) : The column number is not correct! Its greater than the number of columns in the list
Error (R37) : Sorry, The command is not supported in this context
Error (R38) : Runtime Error in loading the dynamic library!

97.5 Language Grammar

Program > {statement}


Statement > package <Identifier> { . <Identifier> } [{ {statement} }] [end|endpackage]
Statement > class <Identifier> [ from|:|< <Identifier> ] [{ {statement} }][end|endclass]
Statement > func|def <Identifier> [ParaList] [{ {statement} }][end|endfunc]
Statement > import <Identifier> { . <Identifier> }
Statement > private
Statement > load <Literal>
Statement > loadsyntax <Literal>

97.5. Language Grammar 1727


Ring Documentation, Release 1.5

Statement > changeringkeyword <OldKeyword> <NewKeyword>


Statement > changeringoperator <OldOperator> <NewOperator>
Statement > see|put <Expr>
Statement > give|get <Identifier>
Statement > if <Expr> [{] {statement} [ {but|elseif <Expr> {Statement} } ] [else {Statement} ]
ok|end|}
Statement > Switch <Expr> [{] { on|case <Expr> {statement} } [other {Statement} ] off|end|}
Statement > for <Identifier> = <Expr> to <Expr> [ step <Expr> ] [{] {Statement} next|end|}
Statement > for <Identifier> in <Expr> [ step <Expr> ] [{] {statement} next|end|}
Statement > while <Expr> [{] {statement} end|}
Statement > do {statement} again <Expr>
Statement > try {statement} [{] catch {statement} done|end|}
Statement > return <Expr>
Statement > bye
Statement > exit
Statement > loop
Statement > <Expr>
Statement > epslion
ParaList > epslion
ParaList > [(] <Identifier> [{ , <Identifier> }] [)]
Expr > <LogicNot> [{ and|or <LogicNot> }]
LogicNot > [not] <EqualOrNot>
EqualOrNot > [ =|!= ] <Compare>
Compare > <BitOrXor> [ { < | > | <= | >= <BitOrXor> } ]
BitOrXor > <BitAnd> [ { | | ^ <BitAnd> } ]
BitAnd > <BitShift> [ { & <BitShift> } ]
BitShift > <Arithmetic> [ { << | >> <Arithmetic> } ]
Arithmetic > <Term> [ { + | - <Term> } ]
Term > <Range> [ { * | / | % <Range> } ]
Range > <Factor> [ : <Factor> ]
Factor > <Identifier> [ {Mixer} ] [ = <Expr> ]
Factor > <Number>
Factor > <Literal>
Factor > : <Identifier>
Factor > - <Expr>
Factor > ( <Expr> )

97.5. Language Grammar 1728


Ring Documentation, Release 1.5

Factor > <List>


Factor > new <Identifier>
Factor > <AnonymousFunction>
Factor > call <identifier> { . <Identifier> } ( <Parameters> )
List > [ [ <Expr> { , <Expr> } ] ]
Mixer > { . <Identifier> }
Mixer > [ <Expr> ]
Mixer > ( [ <Expr> [ { , <Expr> }] ] )
Mixer > { {Statement} }
AnonymousFunction > func|def| [<ParaList>] { {Statement} }

97.6 Virtual Machine (VM) Instructions

Definitions :-
VM : Virtual Machine
Stack : VM Stack
IR : Instruction Register
PC : Program Counter
VP : Variable Pointer
Stack[nSize] : Last Item in the Stack (Last In - First Out)
VV : Variable Value (We have a Pointer to a variable, And we access this variable value)
(Stack and Variables)

97.6. Virtual Machine (VM) Instructions 1729


Ring Documentation, Release 1.5

Operation Description
Add string from the IR to the stack
ICO_PUSHC

Add number from the IR to the stack


ICO_PUSHN

Replace VP in the stack[nSize] with the variable value


ICO_PUSHV

Read variable name from the IR, push VP to the stack


ICO_LOADADDRESS

Stack[nSize-1] VV = Stack[nSize] VV , POP


ICO_ASSIGNMENT
Stack[nSize]
Increment Number in Stack[nSize] by 1
ICO_INC

The same as ICO_LOADADDRESS then ICO_PUSHV


ICO_LOADAPUSHV

Store new line number (debug info)


ICO_NEWLINE

Remove all items from the stack , nSize = 0


ICO_FREESTACK

Store the source code file name (debug info)


ICO_FILENAME

Free the Scope List of the current Expression


ICO_FREELOADASCOPE

(Jump)
Operation Description
Set PC to new value from the IR
ICO_JUMP

If Stack[nSize] is a number = 0 then Set PC to new value


ICO_JUMPZERO
from the IR
End of for loop
ICO_JUMPFOR

If Stack[nSize] is a number = 1 then Set PC to new value


ICO_JUMPONE
from the IR
As ICO_JUMPZERO but add 1 to the stack (required
ICO_JUMPZERO2
for many AND conditions)
As ICO_JUMPONE but add 1 to the stack (required for
ICO_JUMPONE2
many OR conditions)

(Compare)

97.6. Virtual Machine (VM) Instructions 1730


Ring Documentation, Release 1.5

Operation Description
If stack[nSize-1] <= stack[nSize] , POP stack[nSize], set
ICO_LESSEQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] = stack[nSize] , POP stack[nSize], set
ICO_EQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] < stack[nSize] , POP stack[nSize], set
ICO_LESS
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] > stack[nSize] , POP stack[nSize], set
ICO_GREATER
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] >= stack[nSize] , POP stack[nSize], set
ICO_GREATEREQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] != stack[nSize] , POP stack[nSize], set
ICO_NOTEQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0

(Math)
Operation Description
Stack[nSize-1] = Stack[nSize-1] + Stack[nSize] , POP
ICO_SUM
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] - Stack[nSize] , POP
ICO_SUB
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] * Stack[nSize] , POP
ICO_MUL
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] / Stack[nSize] , POP
ICO_DIV
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] % Stack[nSize] , POP
ICO_MOD
stack[nSize]
Stack[nSize] = - Stack[nSize-1]
ICO_NEG

Stack[nSize] = Stack[nSize] + 1
ICO_PLUSPLUS

Stack[nSize] = Stack[nSize] - 1
ICO_MINUSMINUS

(Logic)
Operation Description
Stack[nSize-1] = Stack[nSize-1] && Stack[nSize] ,
ICO_AND
POP stack[nSize]
Stack[nSize-1] = Stack[nSize-1] || Stack[nSize] , POP
ICO_OR
stack[nSize]
Stack[nSize] = ! Stack[nSize]
ICO_NOT

(Lists)

97.6. Virtual Machine (VM) Instructions 1731


Ring Documentation, Release 1.5

Operation Description
Start New List in Temp. Memory
ICO_LISTSTART

Add List Item


ICO_LISTITEM

End List
ICO_LISTEND

Stack[nSize-1] = Stack[nSize-1] VV [ Stack[nSize] ] ,


ICO_LOADINDEXADDRESS
POP stack[nSize]

(Functions)
Operation Description
Find function
ICO_LOADFUNC

Call function
ICO_CALL

Return from function


ICO_RETURN

Return NULl from function


ICO_RETNULL

Return after eval()


ICO_RETFROMEVAL

Return the list item reference - not the value


ICO_RETITEMREF

Start new function


ICO_NEWFUNC

Flag to determine where to jump later (after


ICO_BLOCKFLAG
ICO_RETURN)
Start executing function
ICO_FUNCEXE

End function execution


ICO_ENDFUNCEXE

Anonymous function
ICO_ANONYMOUS

(User Interface)
Operation Description
Print value to the standard output
ICO_PRINT

Get input from the keyboard


ICO_GIVE

(End Program/Loop)

97.6. Virtual Machine (VM) Instructions 1732


Ring Documentation, Release 1.5

Operation Description
End execution of VM
ICO_BYE

Place to exit to from a loop


ICO_EXITMARK

Remove exit mark


ICO_POPEXITMARK

Break from one loop or more


ICO_EXIT

Continue to next loop


ICO_LOOP

(For Better Performance)


Operation Description
Push pointer to the stack
ICO_PUSHP

Increment variable value using pointer


ICO_INCP

Push value of variable using variable pointer


ICO_PUSHPV

Increment then jump


ICO_INCJUMP

Increment using pointer then jump


ICO_INCPJUMP

Jump if variable value is <= numeric value


ICO_JUMPVARLENUM

Jump if variable value (using pointer) <= numeric value


ICO_JUMPVARPLENUM

Push function pointer


ICO_LOADFUNCP

Push pointer to local variable


ICO_PUSHPLOCAL

Increment value using pointer to local variable then


ICO_INCLPJUMP
jump
Jump if the variable value (using pointer) <= numeric
ICO_JUMPVARLPLENUM
value
Increment value using variable pointer then jump (for
ICO_INCPJUMPSTEP1
loop step = 1)
Increment value using variable pointer then jump (for
ICO_JUMPVARPLENUMSTEP1
loop step = 1)

(Try-Catch-Done)

97.6. Virtual Machine (VM) Instructions 1733


Ring Documentation, Release 1.5

Operation Description
Start try region
ICO_TRY

End try region


ICO_DONE

(Duplicate and Range)


Operation Description
Duplicate stack value
ICO_DUPLICATE

Create list from value to value


ICO_RANGE

(OOP)
Operation Description
Create new object, get class name from the IR, push ob-
ICO_NEWOBJ
ject pointer to the stack.
Called after creating new object, set the active scope to
ICO_SETSCOPE
be the object scope.
Get object attribute, push the pointer to the stack.
ICO_LOADSUBADDRESS

Find object method


ICO_LOADMETHOD

Used after calling a method - normal case


ICO_AFTERCALLMETHOD

Used after calling a method - second case


ICO_AFTERCALLMETHOD2

Start new class region


ICO_NEWCLASS

Open brace
ICO_BRACESTART

End brace
ICO_BRACEEND

Import package
ICO_IMPORT

start private attributes region


ICO_PRIVATE

set attribute value - check for setter.


ICO_SETPROPERTY

call call init() method.


ICO_CALLCLASSINIT

(Other)

97.6. Virtual Machine (VM) Instructions 1734

Вам также может понравиться