Skip to main content

express-schema

Continuous integration https://coveralls.io/repos/github/aas-core-works/express-schema/badge.svg?branch=main PyPI - version PyPI - Python Version

Parse EXPRESS Schema (ISO 10303-11).

Installation

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.2 (2026-01-07)

A very misleading reference to Git checkout is removed from the readme (the package is available on PyPI, so no checkout is necessary).

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.

Metadata

Release files for express-schema 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for express-schema 1.0.2
File Size Uploaded
express_schema-1.0.2.tar.gz 35.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for express-schema 1.0.2
File Interpreter ABI Platform
express_schema-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 71.3 kB

Release files / express_schema-1.0.2.tar.gz

Download URL express_schema-1.0.2.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7632370fa092a9d795d4430d6f2f8aecf7bccd1b874fd2e3017032a039e25c17
BLAKE2b-256 checksum
How to use checksums
2af4108d8291d449131acfbb116bfdc4bf32f67900c6e8f77978da8f060fda67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / express_schema-1.0.2-py3-none-any.whl

Download URL express_schema-1.0.2-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adb55a8472bf87677ea3d4c107076016d450f333080f9cb881c5e3ac90487680
BLAKE2b-256 checksum
How to use checksums
7c0fc9c2bf9eda1d8da67815bdccdaddcc6d9a82d83c64d4aded3489e4801a7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page