Skip to content

Commit

Permalink
Merge branch 'bugfix/1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbsog0 committed Oct 1, 2023
2 parents e737c1c + 3ca45bb commit b9c4627
Show file tree
Hide file tree
Showing 5 changed files with 691 additions and 540 deletions.
66 changes: 66 additions & 0 deletions pkg/a2l/a2lextension.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ func (t *AxisDescrType) MapChildNodes(node any) {
t.DEPOSIT = node.(*DepositType)
case *CurveAxisRefType:
t.CURVE_AXIS_REF = node.(*CurveAxisRefType)
case *StepSizeType:
t.STEP_SIZE = node.(*StepSizeType)
case *PhysUnitType:
t.PHYS_UNIT = node.(*PhysUnitType)
default:
panic("not implemented yet...")
}
Expand Down Expand Up @@ -315,6 +319,12 @@ func (t *AxisPtsType) MapChildNodes(node any) {
t.CALIBRATION_ACCESS = node.(*CalibrationAccessType)
case *EcuAddressExtensionType:
t.ECU_ADDRESS_EXTENSION = node.(*EcuAddressExtensionType)
case *PhysUnitType:
t.PHYS_UNIT = node.(*PhysUnitType)
case *StepSizeType:
t.STEP_SIZE = node.(*StepSizeType)
case *SymbolLinkType:
t.SYMBOL_LINK = node.(*SymbolLinkType)
default:
panic("not implemented yet...")
}
Expand Down Expand Up @@ -633,6 +643,14 @@ func (t *CharacteristicType) MapChildNodes(node any) {
t.MATRIX_DIM = node.(*MatrixDimType)
case *EcuAddressExtensionType:
t.ECU_ADDRESS_EXTENSION = node.(*EcuAddressExtensionType)
case *DiscreteType:
t.DISCRETE = node.(*DiscreteType)
case *SymbolLinkType:
t.SYMBOL_LINK = node.(*SymbolLinkType)
case *StepSizeType:
t.STEP_SIZE = node.(*StepSizeType)
case *PhysUnitType:
t.PHYS_UNIT = node.(*PhysUnitType)
default:
panic("not implemented yet...")
}
Expand Down Expand Up @@ -1026,6 +1044,14 @@ func (t *DepositType) MarshalA2L(indentLevel int, indentString string, _ bool) (
return indentContent(fmt.Sprintf("DEPOSIT %s", t.Mode), indentLevel, indentString)
}

func (t *DiscreteType) MapChildNodes(_ any) {
panic("leaf node")
}

func (t *DiscreteType) MarshalA2L(indentLevel int, indentString string, _ bool) (result string) {
return indentContent("DISCRETE", indentLevel, indentString)
}

func (t *DisplayIdentifierType) MapChildNodes(_ any) {
panic("leaf node")
}
Expand Down Expand Up @@ -1513,6 +1539,14 @@ func (t *InMeasurementType) MarshalA2L(indentLevel int, indentString string, _ b
return strings.Join(tmpResult, "\n")
}

func (t *LayoutType) MapChildNodes(_ any) {
panic("leaf node")
}

func (t *LayoutType) MarshalA2L(indentLevel int, indentString string, _ bool) (result string) {
return indentContent(fmt.Sprintf("LAYOUT %s", t.IndexMode), indentLevel, indentString)
}

func (t *LeftShiftType) MapChildNodes(_ any) {
panic("leaf node")
}
Expand Down Expand Up @@ -1631,6 +1665,14 @@ func (t *MeasurementType) MapChildNodes(node any) {
t.MATRIX_DIM = node.(*MatrixDimType)
case *EcuAddressExtensionType:
t.ECU_ADDRESS_EXTENSION = node.(*EcuAddressExtensionType)
case *DiscreteType:
t.DISCRETE = node.(*DiscreteType)
case *SymbolLinkType:
t.SYMBOL_LINK = node.(*SymbolLinkType)
case *LayoutType:
t.LAYOUT = node.(*LayoutType)
case *PhysUnitType:
t.PHYS_UNIT = node.(*PhysUnitType)
default:
panic("not implemented yet...")
}
Expand Down Expand Up @@ -2446,6 +2488,14 @@ func (t *ProjectType) MarshalA2L(indentLevel int, indentString string, sort bool
return strings.Join(tmpResult, "\n")
}

func (t *PhysUnitType) MapChildNodes(_ any) {
panic("leaf node")
}

func (t *PhysUnitType) MarshalA2L(indentLevel int, indentString string, _ bool) (result string) {
return indentContent(fmt.Sprintf("PHYS_UNIT %s", t.Unit.A2LString()), indentLevel, indentString)
}

func (t *ReadOnlyType) MapChildNodes(_ any) {
panic("leaf node")
}
Expand Down Expand Up @@ -2957,6 +3007,14 @@ func (t *SRecLayoutType) MarshalA2L(indentLevel int, indentString string, _ bool
return indentContent(fmt.Sprintf("S_REC_LAYOUT %s", t.Name.A2LString()), indentLevel, indentString)
}

func (t *StepSizeType) MapChildNodes(_ any) {
panic("leaf node")
}

func (t *StepSizeType) MarshalA2L(indentLevel int, indentString string, _ bool) (result string) {
return indentContent(fmt.Sprintf("STEP_SIZE %s", t.StepSize.A2LString()), indentLevel, indentString)
}

func (t *SubFunctionType) MapChildNodes(_ any) {
panic("leaf node")
}
Expand Down Expand Up @@ -3001,6 +3059,14 @@ func (t *SupplierType) MarshalA2L(indentLevel int, indentString string, _ bool)
return indentContent(fmt.Sprintf("SUPPLIER %s", t.Manufacturer.A2LString()), indentLevel, indentString)
}

func (t *SymbolLinkType) MapChildNodes(_ any) {
panic("leaf node")
}

func (t *SymbolLinkType) MarshalA2L(indentLevel int, indentString string, _ bool) (result string) {
return indentContent(fmt.Sprintf("SYMBOL_LINK %s %s", t.SymbolName.A2LString(), t.Offset.A2LString()), indentLevel, indentString)
}

func (t *SystemConstantType) MapChildNodes(_ any) {
panic("leaf node")
}
Expand Down
51 changes: 51 additions & 0 deletions pkg/a2l/a2lnodeimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,16 @@ func (n *Listener) ExitDeposit(_ *parser.DepositContext) {
n.Last().MapChildNodes(node)
}

func (n *Listener) EnterDiscrete(_ *parser.DiscreteContext) {
n.Push(&DiscreteType{Present: true})
}

func (n *Listener) ExitDiscrete(_ *parser.DiscreteContext) {
node := n.Pop()

n.Last().MapChildNodes(node)
}

func (n *Listener) EnterDisplayIdentifier(ctx *parser.DisplayIdentifierContext) {
n.Push(&DisplayIdentifierType{DisplayName: identifierToIdentType(ctx.GetDisplay_name())})
}
Expand Down Expand Up @@ -971,6 +981,16 @@ func (n *Listener) ExitInMeasurement(_ *parser.InMeasurementContext) {
n.Last().MapChildNodes(node)
}

func (n *Listener) EnterLayout(ctx *parser.LayoutContext) {
n.Push(&LayoutType{IndexMode: ctx.GetIndexMode().GetText()})
}

func (n *Listener) ExitLayout(_ *parser.LayoutContext) {
node := n.Pop()

n.Last().MapChildNodes(node)
}

func (n *Listener) EnterLeftShift(ctx *parser.LeftShiftContext) {
n.Push(&LeftShiftType{BitCount: a2lLongToLongType(ctx.GetBitcount())})
}
Expand Down Expand Up @@ -1343,6 +1363,16 @@ func (n *Listener) ExitProject(_ *parser.ProjectContext) {
n.Last().MapChildNodes(node)
}

func (n *Listener) EnterPhysUnit(ctx *parser.PhysUnitContext) {
n.Push(&PhysUnitType{Unit: a2lStringToStringType(ctx.GetUnit_())})
}

func (n *Listener) ExitPhysUnit(_ *parser.PhysUnitContext) {
node := n.Pop()

n.Last().MapChildNodes(node)
}

func (n *Listener) EnterReadOnly(_ *parser.ReadOnlyContext) {
n.Push(&ReadOnlyType{Present: true})
}
Expand Down Expand Up @@ -1642,6 +1672,16 @@ func (n *Listener) ExitSRecLayout(_ *parser.SRecLayoutContext) {
n.Last().MapChildNodes(node)
}

func (n *Listener) EnterStepSize(ctx *parser.StepSizeContext) {
n.Push(&StepSizeType{StepSize: floatToFloatType(ctx.GetStepSize_())})
}

func (n *Listener) ExitStepSize(_ *parser.StepSizeContext) {
node := n.Pop()

n.Last().MapChildNodes(node)
}

func (n *Listener) EnterSubFunction(ctx *parser.SubFunctionContext) {
e := &SubFunctionType{Identifier: make([]*IdentType, 0)}

Expand Down Expand Up @@ -1684,6 +1724,17 @@ func (n *Listener) ExitSupplier(_ *parser.SupplierContext) {
n.Last().MapChildNodes(node)
}

func (n *Listener) EnterSymbolLink(ctx *parser.SymbolLinkContext) {
n.Push(&SymbolLinkType{SymbolName: a2lStringToStringType(ctx.GetSymbolName()),
Offset: a2lLongToLongType(ctx.GetOffset())})
}

func (n *Listener) ExitSymbolLink(_ *parser.SymbolLinkContext) {
node := n.Pop()

n.Last().MapChildNodes(node)
}

func (n *Listener) EnterSystemConstant(ctx *parser.SystemConstantContext) {
n.Push(&SystemConstantType{
Name: a2lStringToStringType(ctx.GetName()),
Expand Down
Loading

0 comments on commit b9c4627

Please sign in to comment.