Remix.run Logo
▲ Parsing EDIFACT in Python with syntax trees(github.com)
15 points by alexprengere 2 days ago | 3 comments
▲CharlesW 14 minutes ago | parent | next [-]

In case other HNers have also not heard of this: https://en.wikipedia.org/wiki/EDIFACT

▲DonaldPShimoda 21 minutes ago | parent | prev | next [-]

What is a "real" syntax tree? I wonder if the intent was "concrete" (the contrast to an abstract syntax tree), or if it's meant colloquially (as in "you really get a syntax tree" or "you get an actual syntax tree") rather than as a technical term.

▲alexprengere 2 days ago | parent | prev [-]

Edison is a Python library for parsing EDIFACT messages. Instead of treating a message as a flat list of segments, it models messages as a syntax tree: segments can define groups of child segments, recursively.

You define the syntax tree once, then parse, validate, or pretty-print messages against that structure. It works by converting the syntax tree to a state machine of possible transitions between segments.