Skip to content

Commit

Permalink
Some LDF grammar improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Dec 27, 2018
1 parent 68b7c48 commit 2c073cf
Show file tree
Hide file tree
Showing 5 changed files with 2,813 additions and 1,930 deletions.
30 changes: 21 additions & 9 deletions pydbc/ldfListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def exitJitter(self, ctx):
ctx.value = ctx.n.value

def exitNode_attributes_def(self, ctx):
print("node_attr_def", ctx.name.value, ctx.getChildren())
items = [x.value for x in ctx.items]
ctx.value = items
print("node_attr_def", ctx.value)

def exitNode_attribute(self, ctx):
name = ctx.name.value
Expand All @@ -82,7 +84,19 @@ def exitDiag_address(self, ctx):
ctx.value = ctx.i.value

def exitAttributes_def(self, ctx):
pass
sid = ctx.sid.value
fid = ctx.fid.value
v = ctx.v.value if ctx.v else None
sn0 = ctx.sn0.value
sn1s = [x.value for x in ctx.sn1s]
cf = ctx.cf.value
p2Min = ctx.p2Min.value
stMin = ctx.stMin.value
nAs = ctx.nAs.value
nCr = ctx.nCr.value
ctx.value = OrderedDict(supplierID = sid, functionID = fid, variant = v, responseErrorSignal = sn0, faultStateSignals = sn1s,
p2Min = p2Min, stMin = stMin, nAs = nAs, nCr = nCr, configurableFrames = cf
)

def exitSupplier_id(self, ctx):
ctx.value = ctx.i.value
Expand All @@ -95,7 +109,7 @@ def exitVariant(self, ctx):

def exitSignal_name(self, ctx):
ctx.value = ctx.i.value
print("signal_name", ctx.value)
#print("signal_name", ctx.value)

def exitConfigurable_frames(self, ctx):
ctx.value = [x.value for x in ctx.frames]
Expand Down Expand Up @@ -133,7 +147,7 @@ def exitLogical_node(self, ctx):
def exitSignal_def(self, ctx):
ctx.value = [x.value for x in ctx.items]

def exit_Signal_item(self, ctx):
def exitSignal_item(self, ctx):
sname = ctx.sname.value
ssize = ctx.ssize.value
initValue = ctx.initValue.value
Expand All @@ -149,7 +163,6 @@ def exitInit_value(self, ctx):
scalar = ctx.s.value if ctx.s else None
array = ctx.a.value if ctx.a else None
ctx.value = OrderedDict(scalar = scalar, array = array)
print("init_value:", ctx.value)

def exitInit_value_scalar(self, ctx):
ctx.value = ctx.i.value
Expand All @@ -176,8 +189,8 @@ def exitSignal_groups_def(self, ctx):
ctx.value = [x.value for x in ctx.items]

def exitSignal_group(self, ctx):
sgname = signal_group_name ':'
gsize = group_size '{'
sgname = ctx.sgname.value
gsize = ctx.gsize.value
items = [x.value for x in ctx.items]
ctx.value = OrderedDict(signalGroupName = sgname, groupSize = gsize, items = items)

Expand Down Expand Up @@ -257,7 +270,7 @@ def exitDiag_frame_def(self, ctx):
sitems = [x.value for x in ctx.sitems]
ctx.value = OrderedDict(masterID = mid, slaveID = sid, masterSignals = mitems, slaveSignals = sitems)

def ExitDiag_frame_item(self, ctx):
def exitDiag_frame_item(self, ctx):
sname = ctx.sname.value
soffs = ctx.soffs.value
ctx.value = OrderedDict(signalName = sname, signalOffset = soffs)
Expand Down Expand Up @@ -362,7 +375,6 @@ def exitLogical_value(self, ctx):
pass

def exitPhysical_range(self, ctx):
#minValue = min_value ',' maxValue = max_value ',' s = scale ',' o = offset (',' t = text_info)?
minValue = ctx.minValue.value
maxValue = ctx.maxValue.value
scale = ctx.scale
Expand Down
Loading

0 comments on commit 2c073cf

Please sign in to comment.