-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guides::FiftyTen::X223::HC837I cannot be parsed deterministically #155
Comments
Fortunately, my hypothesis was wrong! The issue was simply that the parentheses were incorrect. This will be fixed when 831c7e3 is merged. |
@kputnam Are you sure? I've been using Guides::FiftyTen::X223::HC837I as a basis for Guides::FiftyTen::X223A3::HC837I. And i did not encounter that issue. If I apply the same changes from 831c7e3 to a new X223A3 transaction I get an error. Without those changes bin/edi-pp outputs a valid transaction. |
I'm not sure about X223A3, but the change I made to plain old X223 was correct, I believe. You can double-check your parentheses by doing this: ruby -Ilib -rstupidedi -rpp -e 'pp Stupidedi::TransactionSets::FiftyTen::Implementations::X223A2::HC837' | grep -E '(Segment|Table|Loop)Def' Prior to 831c7e3, the output for
Notice the 2320I and 2320H loops are at the wrong depth |
The parser will complain because, starting from any segment in the
2400 SERVICE LINE NUMBER
loop, reading anNM1*DN
could either instantiate the 2420D child loop or the ancestor's older sibling, 2310F loop.The grammar is correct and does match the documentation, so it looks like the parser will need some changes to accommodate this kind of grammar. My guess is we need to take into consideration the position of the header segment of each loop. In this case, 2310F, whose entry segment has position 2500, shouldn't be instantiated because 2400's entry segment has position 3650.
I think this change shouldn't cause any negative effects for the grammars that were faithfully transcribed from official X12 documentation. But in some other grammars, I'm guessing the position was made up or copied from other places, so those may cause parser errors on legitimate inputs.
To detect those problems, we will need to add a spec for each grammar that asserts it can parse valid inputs without any errors or InvalidSegmentVals, etc. I suggest completely automating having to write those tests by using some kind of naming conventions for "good" inputs that will match the file to the correct definition, and generate the specification similarly to
auditor_spec
.The text was updated successfully, but these errors were encountered: