Copyright (C) 1998-2010 MKTMK Moscow, Russia
http://www.mktmk.narod.ru.
e-mail: mktmk<at>narod.ru
The short User’s guide of interpreter Open Basic
1.1. Enumeration
enum step{NOSTEP,STEP}; - this enumeration
determines step-by-step program execution mode.
1.2. Enumeration
enum
typeend{
DUMMYEND,ENDFILEEND,ENDOPERATORDETECT,EOLEND,BREAKPOINTEND,NOLOADEND,
BREAKBEFOREOPERATOR,BREAKAFTEROPERATOR
};
This
enumeration defines run method exit code.
1.3. Enumeration
enum
ob_type_ident {OB_IDENTFLO,OB_IDENTINT,OB_IDENTSTR,OB_NOIDENT};
This
enumeration determines type of a variable or an array. This enumeration is used
in typevar and typearray methods for determining of variable or array type.
1.4. Enumeration
enum typelex{
PLUS,MINUS,MUL,DIV,POWER,ASSIGN,LP,RP,STRING,SEMICOLON,COMMA,ENDPROGRAMM,EOL,
LESS,GREAT,SHARP,BREAKPOINT,
DECINTNUMBER,HEXINTNUMBER,FLOATNUMBER,
FUNC,OPERATOR,
OLDVARIABLE,OLDARRAY,NEWNAME,
BAD
};
This
enumeration defines current lexical token.
1.5. Enumeration
enum ob_type_del{OB_DELETE,OB_NODELETE}; - this enumeration determines type of allocation in memory of value returned by used-defined function. This enumeration is used in setfun method for attaching of user-defined functions that return ob_type_char*type.
If dt=OB_DELETE then returned value is put to
free memory by new operator. After user-defined function is terminated, this
value will be deleted by delete[] operator.
If dt=OB_NODELETE then returned value will
not be deleted by delete[] operator.
2.1. ob_obasic(ostream* o=&cout,istream*
read=&cin);
Constructor
of the interpreter.
Creates
an instance of Open Basic interpreter.
2.2. static const ob_type_char* about()
this method returns a string of information about the program.
2.3. void clear_project();
clear_project
method clears all tables except for user-defined functions table.
2.4. void load_project(ob_istreamcommon* i);
Loads the *.bas-program into the interpreter.
2.5. set_current_input_stream(ob_istreamcommon* i);
method points on stream that should be executed first when run() method is called.
2.6. ob_istreamcommon* get_current_input_stream();
method returns current running stream.
2.7. typeend run();
this method runs loaded program or continues program execution
2.8. void setstep(step ts)
this method sets step-by-step program execution mode on or off.
2.9. step getstep() const
this method returns current mode of step-by-step program execution.
2.10. ob_type_ident typevar(ob_type_char* name)
this method returns type of a variable with name name.
2.11. ob_type_ident typearray(ob_type_char* name)
this method returns type of an array with name name.
2.12. void createvar(ob_type_char* name)
this method creates a variable with name name in table of variables of the interpreter.
2.13. void createarray(ob_type_char* name, ob_type_arraydimension kr, ob_type_arraysize* as)
this method creates an array with name name in table of arrays of the interpreter.
2.14. ob_type_ident strlenvar(ob_type_char* name, ob_type_stringsize* len, ob_type_arraysize* as=OB_NULL)
this method determines variable type and length of variable or array element with name name.
2.15. Methods
bool writevar(ob_type_char* name, ob_type_flo val, ob_type_arraysize* as=OB_NULL)
bool writevar(ob_type_char* name, ob_type_int val, ob_type_arraysize* as=OB_NULL)
bool writevar(ob_type_char* name, ob_type_char* val, ob_type_arraysize* as=OB_NULL)
Methods write a variable (or array) with name name into table of variables and assign val value to it.
2.16. Methods
bool readvar(ob_type_char* name, ob_type_flo* val, ob_type_arraysize* as=OB_NULL)
bool readvar(ob_type_char* name, ob_type_int* val, ob_type_arraysize* as=OB_NULL)
bool readvar(ob_type_char* name, ob_type_char* val, ob_type_arraysize* as=OB_NULL)
Methods
read a variable with name name from table of variables into val pointer.
2.17. const ob_type_arraysize* getarraysize(ob_type_char* name, ob_type_arraydimension* kr)
this method returns number of array dimensions and size of each dimension.
2.18. Methods
bool setfun(ob_type_char* name, ob_type_flofun f)
bool setfun(ob_type_char* name, ob_type_intfun f)
bool setfun(ob_type_char* name, ob_type_charfun f, ob_type_del dt)
Methods for attaching of user-defined function to OB execution system is performed by using setfun methods.
Method bool delfun(ob_type_char* name)
This method detaches user-defined function from Open Basic execution system.
2.19. static const ob_type_serialnum serial_number()
this method returns serial number of the program.
2.20. static const ob_type_int version()
this method returns number of current version of the program multiplied by 100. For version 1.90 this method returns 190.
2.21. void clrtablfun()
this method clears user-defined functions table.
2.22. bool setoperatorbreak(ob_type_char* name, ob_functor_break_base* b);
For setting I/O functors.
void setout(ob_ostreamcommon* o)
this
method allow redefining output stream previously defined in the constructor.
2.24. void setin(ob_istreamcommon* i)
this
method allow redefining input stream previously defined in the constructor.
2.25. Metods
ob_lex::typelex gettypenextlex()
void restoreinputpointer()
These
methods are used for simplification of input and output operators
implementation.