nadata 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nadata/__init__.py +15 -0
- nadata/api.py +894 -0
- nadata/cli.py +445 -0
- nadata/console.py +486 -0
- nadata/core/__init__.py +0 -0
- nadata/core/database/__init__.py +38 -0
- nadata/core/database/builtins.py +87 -0
- nadata/core/database/database.py +958 -0
- nadata/core/database/dumper.py +285 -0
- nadata/core/database/entity_id.py +142 -0
- nadata/core/database/instance.py +706 -0
- nadata/core/database/network_index.py +1142 -0
- nadata/core/database/page_manager.py +175 -0
- nadata/core/database/persistence/__init__.py +28 -0
- nadata/core/database/persistence/binary_cells.py +1141 -0
- nadata/core/database/persistence/compaction.py +97 -0
- nadata/core/database/persistence/dumper.py +798 -0
- nadata/core/database/persistence/lazy_instances.py +1537 -0
- nadata/core/database/persistence/loader.py +424 -0
- nadata/core/database/persistence/record_store.py +228 -0
- nadata/core/database/persistence/serialization.py +605 -0
- nadata/core/database/query_engine.py +222 -0
- nadata/core/database/queryset.py +508 -0
- nadata/core/database/reconciliation.py +287 -0
- nadata/core/database/slotted_page.py +190 -0
- nadata/core/database/spatial_index.py +1080 -0
- nadata/core/expressions/__init__.py +44 -0
- nadata/core/expressions/autograd.py +2909 -0
- nadata/core/expressions/builtins.py +4673 -0
- nadata/core/expressions/expression.py +2658 -0
- nadata/core/expressions/io_builtins.py +972 -0
- nadata/core/expressions/scope.py +336 -0
- nadata/core/expressions/statement.py +953 -0
- nadata/core/struct/__init__.py +14 -0
- nadata/core/struct/struct.py +218 -0
- nadata/core/struct/struct_attribute.py +100 -0
- nadata/core/struct/struct_method.py +324 -0
- nadata/core/types/__init__.py +33 -0
- nadata/core/types/bits/__init__.py +0 -0
- nadata/core/types/bits/bits.py +686 -0
- nadata/core/types/home_types/__init__.py +19 -0
- nadata/core/types/home_types/color.py +102 -0
- nadata/core/types/home_types/coordinate.py +1008 -0
- nadata/core/types/home_types/datetime.py +362 -0
- nadata/core/types/home_types/geogrid.py +92 -0
- nadata/core/types/home_types/geometry.py +1223 -0
- nadata/core/types/home_types/graph.py +0 -0
- nadata/core/types/home_types/planet.py +359 -0
- nadata/core/types/home_types/sea_level.py +98 -0
- nadata/core/types/home_types/vec.py +0 -0
- nadata/core/types/types.py +1345 -0
- nadata/core/values/__init__.py +14 -0
- nadata/core/values/values.py +1568 -0
- nadata/parser/__init__.py +0 -0
- nadata/parser/expressions/__init__.py +6 -0
- nadata/parser/expressions/dependencies.py +318 -0
- nadata/parser/expressions/expression_parser.py +993 -0
- nadata/parser/expressions/splitter.py +98 -0
- nadata/parser/expressions/statement_parser.py +1425 -0
- nadata/parser/expressions/tokenizer.py +402 -0
- nadata/parser/expressions/type_parser.py +187 -0
- nadata/parser/nadata_loader/__init__.py +8 -0
- nadata/parser/nadata_loader/loader.py +951 -0
- nadata/parser/nastruct_parser/__init__.py +0 -0
- nadata/parser/nastruct_parser/declaration.py +105 -0
- nadata/parser/nastruct_parser/imports.py +164 -0
- nadata/parser/nastruct_parser/nastruct_parser.py +209 -0
- nadata/parser/nastruct_parser/parse_attributes.py +149 -0
- nadata/parser/nastruct_parser/parse_callables.py +436 -0
- nadata/parser/nastruct_parser/parse_expression.py +59 -0
- nadata/parser/nastruct_parser/parse_structs.py +206 -0
- nadata/parser/nastruct_parser/parser_state.py +84 -0
- nadata/parser/nastruct_parser/resolver.py +1412 -0
- nadata/parser/nastruct_parser/struct_body_state.py +50 -0
- nadata/parser/nastruct_parser/tmp_structs.py +156 -0
- nadata/parser/utils/__init__.py +20 -0
- nadata/parser/utils/brackets.py +252 -0
- nadata/parser/utils/comments_remove.py +149 -0
- nadata/parser/utils/identifiers.py +121 -0
- nadata/session.py +868 -0
- nadata-0.1.0.dist-info/METADATA +191 -0
- nadata-0.1.0.dist-info/RECORD +86 -0
- nadata-0.1.0.dist-info/WHEEL +5 -0
- nadata-0.1.0.dist-info/entry_points.txt +2 -0
- nadata-0.1.0.dist-info/licenses/LICENSE +21 -0
- nadata-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Shared parser state for .nastruct schema parsing.
|
|
3
|
+
|
|
4
|
+
Provides the NaStructParserState class holding all cross-file parsing
|
|
5
|
+
context: the target database, the intermediate representation being built,
|
|
6
|
+
and the dependency bookkeeping used by the resolution phase.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Import Modules
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
from typing import Any, Optional
|
|
12
|
+
|
|
13
|
+
from nadata.core.database.database import NaDataDatabase
|
|
14
|
+
from nadata.parser.nastruct_parser.tmp_structs import (
|
|
15
|
+
TmpStruct,
|
|
16
|
+
TmpFunction,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class NaStructParserState:
|
|
21
|
+
"""
|
|
22
|
+
Shared state of a .nastruct parsing session.
|
|
23
|
+
|
|
24
|
+
Holds everything the parsing functions need across files and items:
|
|
25
|
+
the database under construction and the intermediate representation
|
|
26
|
+
of the structs and functions discovered so far.
|
|
27
|
+
|
|
28
|
+
Attributes:
|
|
29
|
+
database (NaDataDatabase): Database being populated by the parser.
|
|
30
|
+
tmp_structs (dict[str, TmpStruct]): Intermediate struct declarations
|
|
31
|
+
by name, awaiting type resolution.
|
|
32
|
+
tmp_functions (dict[str, TmpFunction]): Intermediate standalone
|
|
33
|
+
function declarations by name, awaiting type resolution.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
database: Optional[NaDataDatabase] = None
|
|
39
|
+
) -> None:
|
|
40
|
+
"""
|
|
41
|
+
Initializes the NaStructParserState instance.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
database (Optional[NaDataDatabase], optional): Database to populate.
|
|
45
|
+
Defaults to None (a fresh NaDataDatabase is created).
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
# Database where we will register the structs and functions
|
|
49
|
+
self.database: NaDataDatabase = (
|
|
50
|
+
database if database is not None else NaDataDatabase()
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Intermediate representation awaiting resolution
|
|
54
|
+
self.tmp_structs: dict[str, TmpStruct] = {}
|
|
55
|
+
self.tmp_functions: dict[str, TmpFunction] = {}
|
|
56
|
+
|
|
57
|
+
# When True (session schema re-merge), re-declared structs /
|
|
58
|
+
# attributes / methods / functions replace instead of raising
|
|
59
|
+
self.merge: bool = False
|
|
60
|
+
|
|
61
|
+
# Structs re-declared in the current merge -> member names that
|
|
62
|
+
# the re-declarations explicitly carry (union across parses);
|
|
63
|
+
# members absent from the set were removed from the schema
|
|
64
|
+
self.redeclared_members: dict[str, set[str]] = {}
|
|
65
|
+
|
|
66
|
+
def to_ir_dict(self) -> dict[str, Any]:
|
|
67
|
+
"""
|
|
68
|
+
Converts the intermediate representation to a plain JSON serializable dict.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
dict[str, Any]: Dict with 'structs' and 'functions' keys mapping
|
|
72
|
+
names to their serialized representations.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
"structs": {
|
|
77
|
+
name: tmp_struct.to_dict()
|
|
78
|
+
for name, tmp_struct in self.tmp_structs.items()
|
|
79
|
+
},
|
|
80
|
+
"functions": {
|
|
81
|
+
name: tmp_function.to_dict()
|
|
82
|
+
for name, tmp_function in self.tmp_functions.items()
|
|
83
|
+
},
|
|
84
|
+
}
|