Sauci / pya2l

BSD 3-Clause "New" or "Revised" License
31 stars 9 forks source link

error: invalid sequence with A2ML struct content where the "string" #2

Closed kozmers closed 6 years ago

kozmers commented 6 years ago

I got invalid sequence error when test the pya2l for my project's a2l file like below. `from pya2l.parser import A2lParser as Parser

a2l_string = """
ASAP2_VERSION 1 60
    /begin PROJECT prj "PRJ"
        /begin MODULE DIM ""
            /begin A2ML
                struct aaaa{
                    float;
                    taggedstruct{
                        block "BBBB" struct{
                            uchar;
                            taggedstruct{                              
                                (block "C2222" struct{
                                    ulong;                            
                                })*;
                                (block "C3333" struct{
                                    taggedunion{
                                        "TEST";  ////////////// ERROR //////////A2lFormatException: invalid sequence
                                        "DDDD" struct{
                                            "TEST111" ulong;  ////////////// ERROR //////////A2lFormatException: invalid sequence
                                        };
                                    };
                                    taggedstruct{
                                       "TEST222" (ulong)*;  ////////////// ERROR //////////A2lFormatException: invalid sequence
                                    };
                                })*;   
                            };
                        };
                    };
                };
            /end A2ML
        /end MODULE
    /end PROJECT"""
a2l = Parser(a2l_string)`
kozmers commented 6 years ago

` block "FLASH" struct

  {

     taggedunion

     {                            /* ECU mode for copying RAM into Flash   */

          "NOFLASHBACK";   /// invalid sequence error

           "AUTOFLASHBACK";  /// invalid sequence error

        "TOOLFLASHBACK" struct

          {

           uint;                  /* routine number to copy RAM            */

                                  /* into flash (WP->RP)                   */

           taggedstruct

            {

              "COPY_FRAME" (uchar)*; /* list of frames to be copied */

            };

           taggedunion

           {

              "RequestRoutineResults" taggedstruct

                 {

                   "RNC_RESULT" (uchar)*;  /* result codes, that         */

                                           /* sign copy in progress      */

                 };

              "StartRoutine";  /// invalid sequence error

              "CodedResult"; /// invalid sequence error

           };

          };

     };

   };

`

kozmers commented 6 years ago

I add "a2ml_tag SEMICOLON " in parser.py, and the error resolved : @staticmethod def p_a2ml_taggedunion_member(p): """a2ml_taggedunion_member : a2ml_tag SEMICOLON | a2ml_tag a2ml_member SEMICOLON | a2ml_block_definition SEMICOLON"""

Sauci commented 6 years ago

thanks for your feedback. I looked in the specification, and you are right, the 'tag semicolon' string is valid. I just pushed on the bugfix branch, could you give me a feedback please? thanks

kozmers commented 6 years ago

The bugfix solved this problem. I got another issue, so, just close this and open another.