Parser
elva.parser
Module defining parsers for change events from Y data types.
Classes:
-
EventParser–Parser base class.
-
TextEventParser–TextEventparser base class. -
ArrayEventParser–ArrayEventparser base class. -
MapEventParser–MapEventparser base class.
Attributes:
-
ParserState–The states of the
EventParsercomponent.
ParserState = create_component_state('ParserState')
module-attribute
The states of the EventParser component.
EventParser
Bases: Component
Parser base class.
This class is supposed to be inherited from and extended.
Methods:
-
run–Hook running after the
RUNNINGstate has been set. -
check–Check for the correct
eventtype. -
parse–Queue
eventfor parsing asynchronously. -
parse_nowait–Queue
eventfor parsing synchronously. -
parse_event–Hook called when an
eventhas been queued for parsing and which performs further actions.
Attributes:
-
event_type(TextEvent | ArrayEvent | MapEvent) –Event type this parser is supposed to handle.
-
states(ParserState) –The states this component can have.
event_type
instance-attribute
Event type this parser is supposed to handle.
states
property
The states this component can have.
run()
async
Hook running after the RUNNING state has been set.
It initializes the buffer and waits for incoming events to parse.
Source code in src/elva/parser.py
check(event)
Check for the correct event type.
Parameters:
-
event(TextEvent | ArrayEvent | MapEvent) –object holding event information of changes to a Y data type.
Raises:
-
TypeError–if
eventis not an instance ofevent_type.
Source code in src/elva/parser.py
parse(event)
async
Queue event for parsing asynchronously.
Parameters:
-
event(TextEvent | ArrayEvent | MapEvent) –object holding event information of changes to a Y data type.
Source code in src/elva/parser.py
parse_nowait(event)
Queue event for parsing synchronously.
Parameters:
-
event(TextEvent | ArrayEvent | MapEvent) –object holding event information of changes to a Y data type.
Source code in src/elva/parser.py
parse_event(event)
async
Hook called when an event has been queued for parsing and which performs further actions.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
event(TextEvent | ArrayEvent | MapEvent) –object holding event information of changes to a Y data type.
Source code in src/elva/parser.py
TextEventParser
Bases: EventParser
TextEvent parser base class.
Methods:
-
parse_event–Hook called when an
eventhas been queued for parsing and which performs further actions. -
on_retain–Hook called on action
retain. -
on_insert–Hook called on action
insert. -
on_delete–Hook called on action
delete.
Attributes:
-
event_type–Event type this parser is supposed to handle.
event_type = TextEvent
class-attribute
instance-attribute
Event type this parser is supposed to handle.
parse_event(event)
async
Hook called when an event has been queued for parsing and which performs further actions.
Parameters:
-
event(TextEvent) –object holding event information of changes to a Y text data type.
Source code in src/elva/parser.py
on_retain(range_offset)
async
Hook called on action retain.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset(int) –byte offset in the Y text data type.
Source code in src/elva/parser.py
on_insert(range_offset, insert_value)
async
Hook called on action insert.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset(int) –byte offset in the Y text data type.
-
insert_value(Any) –value that was inserted at
range_offset
Source code in src/elva/parser.py
on_delete(range_offset, range_length)
async
Hook called on action delete.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset(int) –byte offset in the Y text data type.
-
range_length(int) –number of bytes deleted starting at
range_offset
Source code in src/elva/parser.py
ArrayEventParser
Bases: EventParser
ArrayEvent parser base class.
Methods:
-
parse_event–Hook called when an
eventhas been queued for parsing and which performs further actions. -
on_retain–Hook called on action
retain. -
on_insert–Hook called on action
insert. -
on_delete–Hook called on action
delete.
Attributes:
-
event_type–Event type this parser is supposed to handle.
event_type = ArrayEvent
class-attribute
instance-attribute
Event type this parser is supposed to handle.
parse_event(event)
async
Hook called when an event has been queued for parsing and which performs further actions.
Parameters:
-
event(ArrayEvent) –object holding event information of changes to a Y array data type.
Source code in src/elva/parser.py
on_retain(range_offset)
async
Hook called on action retain.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset(int) –byte offset in the Y array data type.
Source code in src/elva/parser.py
on_insert(range_offset, insert_value)
async
Hook called on action insert.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset(int) –byte offset in the Y array data type.
-
insert_value(Any) –value that was inserted at
range_offset
Source code in src/elva/parser.py
on_delete(range_offset, range_length)
async
Hook called on action delete.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset(int) –byte offset in the Y array data type.
-
range_length(int) –number of items deleted starting at
range_offset
Source code in src/elva/parser.py
MapEventParser
Bases: EventParser
MapEvent parser base class.
Methods:
-
parse_event–Hook called when an
eventhas been queued for parsing and which performs further actions. -
on_add–Hook called on action
add. -
on_delete–Hook called on action
delete.
Attributes:
-
event_type–Event type this parser is supposed to handle.
event_type = MapEvent
class-attribute
instance-attribute
Event type this parser is supposed to handle.
parse_event(event)
async
Hook called when an event has been queued for parsing and which performs further actions.
Parameters:
-
event(MapEvent) –object holding event information of changes to a Y map data type.
Source code in src/elva/parser.py
on_add(key, new_value)
async
on_delete(key, old_value)
async
Hook called on action delete.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
key(str) –key deleted from the Y map data type.
-
old_value(Any) –value which was associated with
keyin the Y map data type.