| |
- builtins.object
-
- Standard
class Standard(builtins.object) |
|
Standard library class
Attributes:
PREFIX (str): The prefix of method. It is defined as "std_".
Almost methods of this library have general name like
"print", "if", and so on. It is confused host language's
functions and statements.
So this prefix is added: std_print, std_if, ... |
|
Static methods defined here:
- get_method(name: str)
- Get standard library's method.
Args:
name (str): Method name
Returns:
function or NoneType: Standard library's method if it is
available, None otherwise.
- std_do(evaluator, call, config=None)
- do { operations }
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st (Block): A list of operations as Block
config (Config or NoneType, optional): Configuration if
needed.
Returns:
Any: Result of Block evaluation
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_float(evaluator, call, config=None)
- float(value)
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st: A number whose type is int, float,
or string.
config (Config or NoneType, optional): Configuration if
needed.
Returns:
float: Number whose type is converted to float.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_for(evaluator, call, config=None)
- for ( ... ) { operations }
Example:
- for (init; condition; update) { operations }
- for (; condition; update) { operations }
- for (;; update) { operations }
- for (;;) { operations }
- for () { operations }
- for (value in list) { operations }
- for (init; condition; update; { operations })
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
statements.
When a list has 4 statements:
1st (Statement): initial operation
2nd (Statement): condition
3rd (Statement): update operation
4th (Block): A list of operations as Block
When a list has 2 statements:
1st (Binary): value in list
2nd (Block): A list of operations as Block
config (Config or NoneType, optional): Configuration if
needed.
Returns:
Any: Result of Block evaluation
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_if(evaluator, call, config=None)
- if/elseif/else
if (...) {...} [ elseif (...) {...} ... ] else {...}
For example,
if (...) {...}
----- -----
| |
| call.arguments.values[1]
call.arguments.values[0]
if (...) {...} else {...}
----- ----- -----
| | |
| | call.arguments.values[3]
| | call.arguments.values[2] is always true.
| call.arguments.values[1]
call.arguments.values[0]
if (...) {...} elif (...) {...} else {...}
----- ----- ----- ----- -----
| | | | |
| | | | call.arguments.values[5]
| | | | call.arguments.values[4] is
| | | | always true.
| | | call.arguments.values[3]
| | call.arguments.values[2]
| call.arguments.values[1]
call.arguments.values[0]
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
2 x n statements.
2 x n: condition
2 x n + 1: A list of operations as Block
config (Config or NoneType, optional): Configuration if
needed.
Returns:
Any: Result of Block evaluation
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_insert(evaluator, call, config=None)
- insert(array, index, value)
Insert a value into the array.
Inserted position can be given with "index".
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
3 statements.
1st (Array): An array
2nd (Statement): An index
3rd (Statement): A value
config (Config or NoneType, optional): Configuration if
needed.
Returns:
NoneType: It is always None.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_int(evaluator, call, config=None)
- int(value)
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st: A number whose type is int, float,
or string.
config (Config or NoneType, optional): Configuration if
needed.
Returns:
int: Number whose type is converted to int.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_len(evaluator, call, config=None)
- len(value)
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st: An array, a block, or a string.
config (Config or NoneType, optional): Configuration if
needed.
Returns:
int: Length of array, block, or string.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_print(evaluator, call, config=None)
- print(value [, value, ...])
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
statements that have printable values.
config (Config or NoneType, optional): Configuration if
needed.
Returns:
NoneType: It is always None.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_string(evaluator, call, config=None)
- string(value)
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st: Any value
config (Config or NoneType, optional): Configuration if
needed.
Returns:
str: Text that is converted from the given value.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_strip(evaluator, call, config=None)
- strip(value)
Remove white-space and new line code from the head/tail.
Double-byte space (Full-width space) is also removed.
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st: A string.
config (Config or NoneType, optional): Configuration if
needed.
Returns:
str or NoneType: Type is represented as text format.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_type(evaluator, call, config=None)
- type(value)
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
1 statement.
1st: Any value.
config (Config or NoneType, optional): Configuration if
needed.
Returns:
str or NoneType: Type is represented as text format.
- "int"
- "float"
- "string"
- "boolean"
- "null"
- "array"
- "block"
- "function"
None is returned for other type.
Raises:
EvaluateError: It is happen if evaluation is failed.
- std_while(evaluator, call, config=None)
- while (condition) { operations }
Args:
evaluator (Evaluator): Evaluator instance
call (Call): The information of calling.
call.arguments.values is a list of
2 statements.
1st (Statement): condition
2nd (Block): A list of operations as Block
config (Config or NoneType, optional): Configuration if
needed.
Returns:
Any: Result of Block evaluation
Raises:
EvaluateError: It is happen if evaluation is failed.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- PREFIX = 'std_'
| |