Merge remote-tracking branch 'github/development' into development
This commit is contained in:
commit
a95a99f722
3 changed files with 10 additions and 4 deletions
|
|
@ -16,6 +16,8 @@ def display_value(val: any, type_name: str, indentation=0, newline_character='\n
|
||||||
return '"'+val+'"'.replace('\n', newline_character)
|
return '"'+val+'"'.replace('\n', newline_character)
|
||||||
elif type_name == "Integer" or type_name == "Boolean":
|
elif type_name == "Integer" or type_name == "Boolean":
|
||||||
return str(val)
|
return str(val)
|
||||||
|
elif type_name == "Bytes":
|
||||||
|
return val
|
||||||
else:
|
else:
|
||||||
raise Exception("don't know how to display value" + type_name)
|
raise Exception("don't know how to display value" + type_name)
|
||||||
|
|
||||||
|
|
@ -48,6 +50,9 @@ class TBase(Transformer):
|
||||||
def CODE(self, token):
|
def CODE(self, token):
|
||||||
return _Code(str(token[1:-1])) # strip the ``
|
return _Code(str(token[1:-1])) # strip the ``
|
||||||
|
|
||||||
|
def BYTES(self, token):
|
||||||
|
return (bytes(token[2:-1], "utf-8"), token.line) # Strip b"" or b''
|
||||||
|
|
||||||
def INDENTED_CODE(self, token):
|
def INDENTED_CODE(self, token):
|
||||||
skip = 4 # strip the ``` and the following newline character
|
skip = 4 # strip the ``` and the following newline character
|
||||||
space_count = 0
|
space_count = 0
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,14 @@ from abc import ABC, abstractmethod
|
||||||
from typing import Any, List, Tuple, Optional, Union
|
from typing import Any, List, Tuple, Optional, Union
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
primitive_types = (int, float, str, bool)
|
primitive_types = (int, float, str, bool, bytes)
|
||||||
INTEGER = ("Integer",)
|
INTEGER = ("Integer",)
|
||||||
FLOAT = ("Float",)
|
FLOAT = ("Float",)
|
||||||
STRING = ("String",)
|
STRING = ("String",)
|
||||||
BOOLEAN = ("Boolean",)
|
BOOLEAN = ("Boolean",)
|
||||||
TYPE = ("Type",)
|
TYPE = ("Type",)
|
||||||
type_values = (INTEGER, FLOAT, STRING, BOOLEAN, TYPE)
|
BYTES = ("Bytes",)
|
||||||
|
type_values = (INTEGER, FLOAT, STRING, BOOLEAN, TYPE, BYTES)
|
||||||
|
|
||||||
|
|
||||||
Node = UUID
|
Node = UUID
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from concrete_syntax.textual_od import parser, renderer
|
||||||
from services.scd import SCD
|
from services.scd import SCD
|
||||||
from util.timer import Timer
|
from util.timer import Timer
|
||||||
|
|
||||||
PRIMITIVE_TYPES = set(["Integer", "String", "Boolean", "ActionCode"])
|
PRIMITIVE_TYPES = set(["Integer", "String", "Boolean", "ActionCode", "Bytes"])
|
||||||
|
|
||||||
# Merges N models. The models must have the same meta-model.
|
# Merges N models. The models must have the same meta-model.
|
||||||
# Care should be taken to avoid naming collisions before calling this function.
|
# Care should be taken to avoid naming collisions before calling this function.
|
||||||
|
|
@ -12,7 +12,7 @@ def merge_models(state, mm, models: list[UUID]):
|
||||||
with Timer("merge_models"):
|
with Timer("merge_models"):
|
||||||
primitive_types = {
|
primitive_types = {
|
||||||
type_name : UUID(state.read_value(state.read_dict(state.read_root(), type_name)))
|
type_name : UUID(state.read_value(state.read_dict(state.read_root(), type_name)))
|
||||||
for type_name in ["Integer", "String", "Boolean", "ActionCode"]
|
for type_name in ["Integer", "String", "Boolean", "ActionCode", "Bytes"]
|
||||||
}
|
}
|
||||||
|
|
||||||
merged = state.create_node()
|
merged = state.create_node()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue