# Parsing ADL 1.4 w/Python

**URL:** <https://discourse.openehr.org/t/parsing-adl-1-4-w-python/14744>\
**Category:** Technical (archive)\
**Created:** [6 May 2008 13:34 UTC](https://discourse.openehr.org/t/parsing-adl-1-4-w-python/14744 "2008-05-06T13:34:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Cook2](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@Tim\_Cook2](https://discourse.openehr.org/u/Tim_Cook2)\
**Post date:** [6 May 2008 13:34 UTC](https://discourse.openehr.org/t/parsing-adl-1-4-w-python/14744/1 "2008-05-06T13:34:25Z")

</div>

Hi All,

Today was "Stress Test Day" for my Python ADL 1.4. parser. The goal was  
to see how well I could parse ADL 1.4 in order to create a data  
structure that can be used for building in memory Python archetype  
objects from the reference model so they can be persisted in an  
archetype repository for local use.

I used almost all of the archetypes in SVN control on openEHR.org. The  
exceptions were the test ones involving automotive information and the  
duplicates between dev-uk-nhs, dev-uk-nhs-scotland and dev-nl-tno. The  
dev-uk-nhs tree took precedence. I'll probably do another test later  
on just the dev tree depending on any feedback I get.

I think that my findings are interesting for the following groups of  
people:  
1) Archetype tools developers  
2) Archetype tools users  
3) Clinical governance members  
4) Archetype consumers  
5) Python openEHR developers

... therefore, my reason for cross-posting.

Of the 755 ADL files tested, 216 of them failed parsing.

These failures are a combination of:

a) missing required sections such as 'archetype', 'definition',  
'language', etc.

b) missing structure closings such as '}' and '\>' (these very well could  
be errors in the parser itself?)

c) unexpected characters in certain locations (I still have to evaluate  
these to see if they are legal or not in the spec)

The main reason I think this is interesting enough to cross post is that  
several ADL files pass parsing between version numbers. My question is;  
were they edited with different versions of the same tool or different  
tools or was the output just somehow different? I will propose that the  
description section of the archetype carry an attribute that identifies  
the tool and version number used for creation/editing.

While all of these ADL files are listed as being in the development  
tree. I hope that this information may inform the Clinical Governance  
group about differences in files and especially about gross missing  
items.

I also note that some of the ADL files are intended to be tests. My  
feeling is that some of these have been around for some time and may not  
be truly 'test' files. Should they be removed or updated? I vote for  
updated. A set of really good test ADL files are essential and will  
really simplify the work of openEHR developers.

I have uploaded (see link below) the following files for information:

ADLParserTest.txt -- shows the console output of all the files tested.

parser\_errors.log-1st -- shows the files that failed along with why and the  
line # and col #

The \*.osh file is mostly for Python developers. It shows the nested  
list structure of the parsed ADL.

adl\_1\_4.py -- the parser  
parsertester.py -- calls the parser and logs errors.

tested\_adl\_files.zip -- the 755 ADL files.

The dev-tree\_adl\_files.zip and parser\_errors.log-2nd are the input/output  
from the ADL files in the dev tree (knowledge/archetypes/dev/\*). 69 Failed and at first  
glance many are the same ones that failed before and for the same  
reasons.

I want to also thank Paul McGuire for writing Pyparsing and for working  
so hard on this ADL parser.

\*\*\*\*\*\*\*\*\*\*IMPORTANT\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
The ADL files in this archive MUST not be used for any other purpose.  
They are now outside of the openEHR knowledge management framework and  
cannot be relied upon for any other use.

---

<div class="post-metadata">

**Author:** ![Peter\_Gummer1](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/p/258eb7/32.png) [@Peter\_Gummer1](https://discourse.openehr.org/u/Peter_Gummer1)\
**Post date:** [6 May 2008 14:20 UTC](https://discourse.openehr.org/t/parsing-adl-1-4-w-python/14744/2 "2008-05-06T14:20:55Z")

</div>

Tim Cook wrote (hidden away inside a text attachment):

> I also note that some of the ADL files are intended to be tests. My  
> feeling is that some of these have been around for some time and may not  
> be truly 'test' files. Should they be removed or updated? I vote for  
> updated. A set of really good test ADL files are essential and will  
> really simplify the work of openEHR developers.

The archetypes at  
[http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/validation/?rev=0&sc=0](http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/validation/?rev=0&sc=0)  
were all written a couple of months ago. Most of them contain deliberate  
errors, in order to test whether validation is working.

I haven't had a really close look at the other test directories, but having  
worked with them in an ad-hoc way they seem ok. A thorough review of all of  
the test archetypes would be welcome, of course!

- Peter

---

<div class="post-metadata">

**Author:** ![Tim\_Cook2](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@Tim\_Cook2](https://discourse.openehr.org/u/Tim_Cook2)\
**Post date:** [6 May 2008 14:57 UTC](https://discourse.openehr.org/t/parsing-adl-1-4-w-python/14744/3 "2008-05-06T14:57:47Z")

</div>

Hi Peter,

> The archetypes at  
> [http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/validation/?rev=0&sc=0](http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/validation/?rev=0&sc=0)  
> were all written a couple of months ago. Most of them contain deliberate  
> errors, in order to test whether validation is working.

Thanks for this. Though I have been doing regular svn updates; for some  
reason I had not picked these up. I am now doing a brand new complete  
checkout to be sure I have the latest. These validation files look VERY  
useful.

> I haven't had a really close look at the other test directories, but having  
> worked with them in an ad-hoc way they seem ok. A thorough review of all of  
> the test archetypes would be welcome, of course!

I will be using them as well.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)\
**Post date:** [7 May 2008 03:07 UTC](https://discourse.openehr.org/t/parsing-adl-1-4-w-python/14744/4 "2008-05-07T03:07:28Z")

</div>

Great!  
We, Ruby implementation project, should be catch up you.  
I believe light weight languages have enough power on openEHR.
