PrzemekWirkus / sbs2xml-conv

Very simple SBS (IBM Rhapsody) file format converter to XML.
MIT License
1 stars 2 forks source link

"syntax error" when parsing .sbs for Rhapsody 8.2.1 #2

Open xena7201 opened 2 years ago

xena7201 commented 2 years ago

Hi! I tried to parse an .sbs file and I'd get "syntax error".

I am using Rhapsody 8.2.1 and I think the issue is somehow related to a possible syntax difference between the repository files generated by the two Rhapsody versions, 7.5 and 8.2.1.

Could you help me find a solution for this?


I leave a sample file as attachment. ComponentX.zip

PrzemekWirkus commented 2 years ago

Hello,

I've built tool under Ubuntu 20.04.3 LTS and I can parse example SBS you've attached:

Quick build:

sbs2xml-conv$ make all
flex lexer.l
gawk '/#define YY_BUF_SIZE/{gsub(/16384/, "(1024*1024)")};{print}' lex.yy.c > lex.yy.c.new
rm -f lex.yy.c
mv lex.yy.c.new lex.yy.c
bison -d grama.y
grama.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
gcc -O2 lex.yy.c grama.tab.c -c
grama.y: In function ‘yyparse’:
grama.y:141:50: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  141 | number:     _INT            { $$ = $1; }
      |                                                  ^
grama.y:143:50: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  143 |             | _FLOAT        { $$ = $1; }
      |                                                  ^
g++ -O2 -fpermissive main.cpp -c
g++ -O2 -fpermissive -s  lex.yy.o  grama.tab.o  main.o -o sbs2xml.exe

Install some usefull xml parsing tools:

$ sudo apt install libxml2-utils

And parsing:

sbs2xml-conv$ xmllint --format <(cat ComponentX/ComponentX.sbs | ./sbs2xml.exe)

PS: Please note that above <( COMMAND ) in Bash just creates temporary unnamed file so it can be used as parameter for xmllint. Because xmllint --format FILE requires file and I was too lazy to create new parsed XML from sbs2xml.exe output.

Please can you paste your command and syntax error, I can have a look!

PrzemekWirkus commented 2 years ago

Just a proof it actually parses:

sbs2xml-conv$ xmllint --format <(cat ComponentX/ComponentX.sbs | ./sbs2xml.exe) | head
<?xml version="1.0"?>
<ISubsystem>
  <_id>GUID 4cae735d-e9cf-4574-bad9-82ba20751878</_id>
  <_myState>8192</_myState>
  <_name><![CDATA["ComponentX"]]></_name>
  <Stereotypes>
    <IRPYRawContainer>
      <size>1</size>
      <value>
        <IHandle>

...

sbs2xml-conv$ xmllint --format <(cat ComponentX/ComponentX.sbs | ./sbs2xml.exe) | tail
              <_m2Class><![CDATA[""]]></_m2Class>
            </IHandle>
          </_itsStateChart>
          <_classModifier>Unspecified</_classModifier>
        </IClass>
      </value>
    </IRPYRawContainer>
  </Classes>
  <_configurationRelatedTime>1.2.1990::0:0:0</_configurationRelatedTime>
</ISubsystem>
xena7201 commented 2 years ago

Hi!

Thanks a lot for the feedback!

Firstly, I want to apologize: I have uploaded by mistake an example that is actually parsed by sbs2xml on my machine as well.

I add below some examples for which the tool reports "syntax error".

I would greatly appreciate if you could take the time to check them as well.

Examples.zip

PrzemekWirkus commented 2 years ago

I will have a look, cheers!

PrzemekWirkus commented 2 years ago

Hello, So I can see what the problem is. Can you in first line change "C" to "C++" like this:

< I-Logix-RPY-Archive version 8.14.0 C++ 9810313
---
> I-Logix-RPY-Archive version 8.14.0 C 9810313

Looks like I've only took under cosideration C++ and not C SBS modules. I will fix it in free time but now you can just in place change C to C++ in first line.

Let me know if this works for you?

xena7201 commented 2 years ago

Hi! I checked and it seems to work this way, thank you! In case you release a new version, I'll make sure to test it as well.

PrzemekWirkus commented 2 years ago

I'm glad to hear that! I will update source when I have some time to spare.