Parse EXPRESS Schema (ISO 10303-11).
Project description
Parse EXPRESS Schema (ISO 10303-11).
Installation
Check out the repository and change to its directory.
Create a virtual environment:
python -m venv venv
Activate it (on Windows):
venv/Scripts/activate
… or on Unix:
source venv/bin/activate
Install the dependencies:
pip3 install express-schema
You can now use the modules express_schema.parse (see “Usage” section below) or run express-schema (see --help section below).
Usage
The Abstract Syntax Tree and parsing functionality lives in express_schema.parse module.
Example:
>>> import express_schema.parse as parse
>>>
>>> # Define a simple EXPRESS schema as a string
>>> schema_text = '''SCHEMA SimpleExample;
...
... ENTITY Person;
... name : STRING;
... age : INTEGER;
... END_ENTITY;
...
... END_SCHEMA;'''
>>>
>>> # Parse the schema
>>> schema, errors = parse.parse(schema_text)
>>>
>>> # Check for parsing errors
>>> if errors is not None:
... print("Parsing errors occurred:")
... for error in errors:
... print(
... f" Line {error.line}, Column {error.column}: "
... f"{error.message}"
... )
... else:
... print("Schema parsed successfully!")
... print(f"Schema name: {schema.identifier}")
... print(f"Number of entities: {len(schema.entity_declarations)}")
...
... # Dump the parsed schema back to text
... dumped_text = parse.dump(schema)
... print("Dumped schema:")
... print(dumped_text)
Schema parsed successfully!
Schema name: SimpleExample
Number of entities: 1
Dumped schema:
Schema(
position=1:1,
identifier='SimpleExample',
reference_clauses=[],
use_clauses=[],
constant_definitions=[],
entity_declarations=[EntityDeclaration(
position=3:1,
identifier='Person',
explicit_clauses=[
ExplicitAttributeDefinition(
position=4:3,
attributes=[NameRef(
position=4:3,
identifier='name'
)],
optional=False,
type_selection=StringType(
position=4:10,
fixed=False
)
),
ExplicitAttributeDefinition(
position=5:3,
attributes=[NameRef(
position=5:3,
identifier='age'
)],
optional=False,
type_selection=IntegerType(
position=5:9
)
)
],
derive_clauses=[],
inverse_clauses=[],
unique_rules=[],
domain_rules=[]
)],
function_declarations=[],
procedure_declarations=[],
type_declarations=[],
rule_declarations=[]
)
If, for some reason, you only want to tokenize and not parse the schema, you can use express_schema.lex module.
Example:
>>> import express_schema.lex as lex
>>>
>>> # Define a simple EXPRESS schema text to tokenize
>>> schema_text = '''SCHEMA Example;
... ENTITY Person;
... name : STRING;
... END_ENTITY;
... END_SCHEMA;'''
>>>
>>> # Tokenize the schema
>>> tokens, success = lex.lex(schema_text)
>>>
>>> # Check if tokenization was successful
>>> if success:
... print("Tokenization successful!")
... print(f"Number of tokens: {len(tokens)}")
... print("First few tokens:")
... for token in tokens[:5]:
... print(
... f" {token.kind.name} at {token.position}: "
... f"{token.text!r}"
... )
... else:
... print("Tokenization failed!")
Tokenization successful!
Number of tokens: 14
First few tokens:
SCHEMA at 1:1: 'SCHEMA'
IDENTIFIER at 1:8: 'Example'
SEMI at 1:15: ';'
ENTITY at 2:1: 'ENTITY'
IDENTIFIER at 2:8: 'Person'
--help
usage: express-schema [-h] --schema SCHEMA [--version]
Parse EXPRESS Schema (ISO 10303-11) and print the Abstract Syntax Tree.
options:
-h, --help show this help message and exit
--schema SCHEMA Path to the EXPRESS schema file
--version show the current version and exit
Contributing
See CONTRIBUTING.rst.
Change Log
1.0.1 (2026-01-07)
We add the py.typed marker so that downstream clients can use this package with mypy.
1.0.0 (2026-01-07)
This is the first version where we successfully performed the experiments with IFC to AAS conversion.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file express_schema-1.0.1.tar.gz.
File metadata
- Download URL: express_schema-1.0.1.tar.gz
- Upload date:
- Size: 35.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ce6fdd349d7374f5b43726b5096d485d028be140242380b9fa077926cd958b5
|
|
| MD5 |
e966c5395efa6ac46cda2ae13af9f777
|
|
| BLAKE2b-256 |
c4d9539050bd9c504cf34bb8ba3471e10c274a5b5dce87cc0a14b7bd335deeb6
|
File details
Details for the file express_schema-1.0.1-py3-none-any.whl.
File metadata
- Download URL: express_schema-1.0.1-py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6961c670af1ce0c64adccecbf02e567cb2e371560dc7e59e8248c7a1c3a9759
|
|
| MD5 |
80a2672069224f27495b33e0eb185169
|
|
| BLAKE2b-256 |
f7a605f957c5bc2d721c2b152ceac9dbde7ad2f04ca1d883a92b7f82d4e26c2c
|