Tasmota/lib/libesp32/Berry/tools/grammar/berry.bytecode

97 lines
2.6 KiB
Plaintext
Executable File

-------------------------------------------------------------------------------
-- the Berry's bytecode file structure (version 1)
--
-- description
--
-- a double dash ('--') start a line comment.
-- a: n means that the size of entity 'a' is 'n' bytes.
-- 'a: .n means that the size of entity 'a' is 'n' bits.
-- a:
-- b means that the entity 'a' is realized by the 'b' structure.
-- a:
-- b
-- c 'b' and 'c' are arranged in a compact order (one byte alignment).
-- [a] means that structure 'a' can be repeated 0 to any times.
-- [a](b) means that structure 'a' can be repeated 'b' times.
-- a | b means that the entity can be implemented by structure 'a' or 'b'.
-- a -> b is equivalent to 'a:
-- b'.
-- only the first entity is a file entity (the root).
-------------------------------------------------------------------------------
bytecode_file: -- little endian
header
global_desc
main_function
header: 8
magic_number: 3 -- 0xbecdfe (berry code file)
version: 1 -- update with file structure definition
integer_size: .1
float_size: .1
-- reserved space
main_function -> function
global_desc:
builtin_count: 4
global_count: 4
global_name -> [
string
](global_count)
function:
information:
function_name:
string
source:
string
argc: 1 -- arguments count
nstack: 1 -- number of stack size by this function
extra: 2 -- extra data
bytecode:
code_size: 4
code_array -> [ -- bytecode array
instruction: 4
](code_size)
constant_table:
constant_count: 4
[constant_value](constant_count)
proto_table:
proto_count: 4
[function](proto_count)
upval_table:
upval_count: 1
upvals -> [
instack: 1
index: 1
](upval_count)
debug_info:
-- reserved
constant_value:
type: 1 -- type of value
integer | float | string | class
string:
string_size: 2
byte_array: string_size
class:
class_name:
string
member_count: 4 -- number of member variables
method_count: 4 -- number of method
method_table -> [
string -- method name
function -- method function body
](method_count)
member_index_table -> [
string -- member name
](member_count)
nil: 1
boolean: 1
integer: 4 or 8
float: 4 or 8