Skip to content

Commit

Permalink
example A2L have values out of bounds, handle them "properly"
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbsog0 committed Jun 30, 2023
1 parent ca785ab commit 2b61f43
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion grammar/A2L.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,6 @@ FLOAT:
('0'..'9')+ '.' ('0'..'9')* EXPONENT?
| '.' ('0'..'9')+ EXPONENT?
| ('0'..'9')+ EXPONENT
| 'Inf'
)
;

Expand Down
6 changes: 3 additions & 3 deletions pkg/a2l/a2lhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func a2lLongToLongType(integerValue parser.IIntegerValueContext) (result *LongTy

if tmpResult, err = strconv.ParseInt(rawString, int(base), 64); err == nil {
result = &LongType{
Value: int32(tmpResult),
Value: tmpResult,
Base: base,
Size: uint32(len(rawString)),
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func numericToLongType(integerValue parser.INumericValueContext) (result *LongTy

if tmpResult, err = strconv.ParseInt(rawString, int(base), 64); err == nil {
result = &LongType{
Value: int32(tmpResult),
Value: tmpResult,
Base: base,
Size: uint32(len(rawString)),
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func floatToFloatType(integerValue parser.INumericValueContext) (result *FloatTy
}

if tmpResult, err = strconv.ParseFloat(originalString, 64); err == nil {
result.Value = float32(tmpResult)
result.Value = tmpResult
} else {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/a2l/a2mlhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func arraySpecifierToLongType(integerValue parser.IArraySpecifierContext) (resul

if tmpResult, err = strconv.ParseInt(rawString, int(base), 64); err == nil {
result = &LongType{
Value: int32(tmpResult),
Value: tmpResult,
Base: base,
Size: uint32(len(rawString)),
}
Expand Down
4 changes: 2 additions & 2 deletions protobuf/shared.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ message IntType {
}

message LongType {
int32 Value = 1;
int64 Value = 1;
uint32 Base = 2;
uint32 Size = 3;
}

message FloatType {
float Value = 1;
double Value = 1;
optional string IntegralSign = 2;
uint32 IntegralSize = 3;
uint32 DecimalSize = 4;
Expand Down

0 comments on commit 2b61f43

Please sign in to comment.