kallemooo / Asap2

Asap2 parser.
MIT License
38 stars 21 forks source link

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

Open xujinpeng1117 opened 2 years ago

xujinpeng1117 commented 2 years ago

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?