Skip to content

Units cannot be parsed #3

@MilanCornelis

Description

@MilanCornelis

When testing a bit with this package, it seems like units cannot be parsed.
I used the SysML model below

package 'My-Vehicle' {

	private import SI::*;
	private import ISQ::*;
	
	part vehicle1 {
		part engine {
			part cylinder;
		}
		
		part frontAxleAssembly {
			part frontAxle;
			
			part frontWheelAssembly {
				part wheel;
				
				part tire : Tire {
					attribute pressure = 270000.0 [Pa];
				}
			}
		}
		
		part rearAxleAssembly {
			part rearAxle;
			
			part rearWheelAssembly {
				part wheel;
				
				part tire : Tire {
					attribute pressure = 320000.0 [Pa];
				}
			}
			
			part differential : Differential;
		}
	}
}


and parsed it with this Python code

from pysysml2.modeling.model import Model

model = Model()
model.from_sysml2_file('./demo.sysml')
print(model)

Giving the output below. Besides the errors, the tree is also not correctly represented anymore. The part rearAxleAssembly@11_None should have vehicle1@3_None as a parent and thus be rearAxleAssembly@11_3 (like frontAxleAssembly). For the moment, this can be solved by making the attribute type a String (e.g. "32000.0 [Pa]".

line 3:1 mismatched input 'private' expecting {'}', 'actor', 'attribute', 'comment', 'connect', 'doc', 'item', 'package', 'part', 'port', 'ref', 'use', 'in', 'out', COMMENT_LONG}
line 4:1 extraneous input 'private' expecting {<EOF>, 'actor', 'attribute', 'comment', 'connect', 'doc', 'import', 'item', 'package', 'part', 'port', 'ref', 'use', 'in', 'out', COMMENT_LONG}
line 18:35 token recognition error at: '[P'
line 18:38 token recognition error at: ']'
line 30:35 token recognition error at: '[P'
line 30:38 token recognition error at: ']'
line 18:37 no viable alternative at input 'parttire:Tire{attributepressure=270000.0a'
line 30:37 no viable alternative at input 'parttire:Tire{attributepressure=320000.0a'
line 35:2 extraneous input '}' expecting {<EOF>, 'actor', 'attribute', 'comment', 'connect', 'doc', 'import', 'item', 'package', 'part', 'port', 'ref', 'use', 'in', 'out', COMMENT_LONG}
[root]: 
├── [0]: My-Vehicle@0_None
├── [1]: SI@1_None
├── [2]: ISQ@2_None
├── [3]: vehicle1@3_None
│   ├── [4]: engine@4_3
│   │   └── [5]: cylinder@5_4
│   └── [6]: frontAxleAssembly@6_3
│       ├── [7]: frontAxle@7_6
│       └── [8]: frontWheelAssembly@8_6
│           └── [9]: wheel@9_8
├── [10]: rearAxleAssembly@10_None
│   ├── [11]: rearAxle@11_10
│   └── [12]: rearWheelAssembly@12_10
│       └── [13]: wheel@13_12
└── [14]: differential@14_None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions