Skip to content
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

file parse fail for MATRIX_DIM in v1.7 a2l #16

Open
xujinpeng1117 opened this issue May 9, 2022 · 1 comment
Open

file parse fail for MATRIX_DIM in v1.7 a2l #16

xujinpeng1117 opened this issue May 9, 2022 · 1 comment

Comments

@xujinpeng1117
Copy link

xujinpeng1117 commented May 9, 2022

Hello, I use Asap2 to parse a v1.7 a2l file, it report error when meet MATRIX_DIM like this:
MATRIX_DIM 1 200

I have check the specification, the MATRIX_DIM have fix 3 member x,y,z in v1.6, but v1.7 define like this:
MATRIX_DIM (uint Dim)+

The count of Dim can be 1,2,3,......

So I change my local project, in file Asap2.Language.grammar.y line 1194-1197 change to
matrix_dim : MATRIX_DIM NUMBER {
$$ = new MATRIX_DIM(@$, (uint)$2);
}
;

matrix_dim : MATRIX_DIM NUMBER NUMBER {
$$ = new MATRIX_DIM(@$, (uint)$2, (uint)$3);
}
;

matrix_dim : MATRIX_DIM NUMBER NUMBER NUMBER {
$$ = new MATRIX_DIM(@$, (uint)$2, (uint)$3, (uint)$4);
}
;

And class MATRIX_DIM in file Asap2File.cs change to
[Base(IsSimple = true)]
public class MATRIX_DIM : Asap2Base
{
public MATRIX_DIM(Location location, uint xDim, uint yDim, uint zDim) : base(location)
{
_Dims.Add(xDim);
_Dims.Add(yDim);
_Dims.Add(zDim);
Dims_str = xDim.ToString() + " " + yDim.ToString() + " " + zDim.ToString();
}
public MATRIX_DIM(Location location, uint xDim, uint yDim) : base(location)
{
_Dims.Add(xDim);
_Dims.Add(yDim);
Dims_str = xDim.ToString() + " " + yDim.ToString();
}
public MATRIX_DIM(Location location, uint xDim) : base(location)
{
_Dims.Add(xDim);
Dims_str = xDim.ToString();
}
[Element(0, IsArgument = true)]
public string Dims_str = "";
public List _Dims = new List();
}

Now it work for my a2l file, but the count of MATRIX_DIM is limit to 3, is there a better solution?

@sven-n
Copy link

sven-n commented Sep 25, 2024

From the specification:

ASAM MCD-2 MC V1.7 defines the dimensions as optional numbers. This allows to add only 
the dimensions used. 
In earlier versions (<= V1.6.1) always 3 dimensions are given. To describe objects with less 
than 3 dimensions ASAM MCD-2 MC V1.6.1 defined a rule that not used dimensions are 
stated as ‘1’. 
This leads to inconsistency in case of usage of MATRIX_DIM for 1 or two dimensions. E.g. 
MATRIX_DIM 4 2 1 describes in V1.7 a 3-dimensional object (z-dimension = 1) and in V1.6.1 
a 2-dimensional object.
To avoid conflicts MATRIX_DIM must be handled version dependent.

So, there is a little bit more to handle to support V1.7 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants