Skip to content

Minimal test of Ruby Treetop grammars for OFX v1xx and v2xx

Notifications You must be signed in to change notification settings

ddoherty03/treetop-ofx-test

Repository files navigation

Version 1xx versus 2xx

Headers

1xx and 2xx uses different headers, which have been removed from the sample response files, since parsing out the headers is not done by Treetop. The main thing we want from the header is the OFX version of the response file, which are just hardwired in this example.

Value Fields

1xx uses SGML syntax in which a value-bearing field can be expressed without a closing tag, like this:

<NAME>PERIODONTAL SPECIALIST LEAW

but since the end tag is optional, this should work as well:

<NAME>PERIODONTAL SPECIALIST LEAW</NAME>

In version 2xx, only the latter example should be valid.

Issues with my Treetop Grammars

Version 1xx

I have been using the version 1xx grammar for many years successfully, but there is an issue with it: the grammar does not allow a closing tag on a value field, even though it is optional. However, when I add an optional closing tag, the grammar breaks. This has not been a problem in the wild since it appears that almost all financial institutions leave off the closing tag.

Version 2xx

Most financial institutions seem to still use the version 1xx syntax, but I have run across one that uses the v2xx syntax, and I want a grammar that parses those files was well.

When I try a revised version of the grammar that makes the closing tag mandatory, however, the parser fails to parse an OFX2 response file.

Test Script

This repository has a test script, test-ofx.rb that you should be able to run it after installing the treetop gem.

As of this date, the version1 parsing succeeds (provided I don’t make closing tags optional), but the version2 parsing fails.

I’m asking for help from the mailing list to see if anyone can tell me where I am getting it wrong.

Questions

  1. On the version1 grammar, ofx_v1.treetop, why does it break if I uncomment lines 51-52 to make the close-tag element optional?
  2. On the version2 grammar, ofx_v2.treetop, why is it choking on the test script? I suspect that it involves the close-tag element at line 52, but I can’t see what’s wrong with it.

About

Minimal test of Ruby Treetop grammars for OFX v1xx and v2xx

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages