Skip to content

Commit

Permalink
Update exitPartialIdentifier rule
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Apr 17, 2020
1 parent c6d6d55 commit 860a281
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
34 changes: 17 additions & 17 deletions pya2l/a2l.g4
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ byteOrder:

calibrationAccess:
'CALIBRATION_ACCESS'

type_ =
(
'CALIBRATION' |
Expand All @@ -122,7 +122,7 @@ defaultValue:

deposit:
'DEPOSIT'

mode_ =
(
'ABSOLUTE' |
Expand Down Expand Up @@ -187,7 +187,7 @@ maxRefresh:

monotony:
'MONOTONY'

monotony_ =
(
'MON_DECREASE' |
Expand Down Expand Up @@ -358,7 +358,7 @@ characteristic:
BEGIN 'CHARACTERISTIC'
name = identifierValue
longIdentifier = stringValue

type_ =
(
'ASCII' |
Expand Down Expand Up @@ -411,7 +411,7 @@ characteristic:

axisDescr:
BEGIN 'AXIS_DESCR'

attribute =
(
'CURVE_AXIS' |
Expand Down Expand Up @@ -517,7 +517,7 @@ compuMethod:
BEGIN 'COMPU_METHOD'
name = identifierValue
longIdentifier = stringValue

conversionType =
(
'IDENTICAL' |
Expand Down Expand Up @@ -590,7 +590,7 @@ compuTab:
BEGIN 'COMPU_TAB'
name = identifierValue
longIdentifier = stringValue

conversionType =
(
'TAB_INTP' |
Expand All @@ -617,7 +617,7 @@ compuVtab:
BEGIN 'COMPU_VTAB'
name = identifierValue
longIdentifier = stringValue

conversionType =
'TAB_VERB'

Expand Down Expand Up @@ -835,7 +835,7 @@ errorMask:

layout:
'LAYOUT'

indexMode =
(
'ROW_DIR' |
Expand Down Expand Up @@ -975,7 +975,7 @@ epk:

memoryLayout:
BEGIN 'MEMORY_LAYOUT'

prgType =
(
'PRG_CODE' |
Expand All @@ -1002,7 +1002,7 @@ memorySegment:
BEGIN 'MEMORY_SEGMENT'
name = identifierValue
longIdentifier = stringValue

prgType =
(
'CALIBRATION_VARIABLES' |
Expand All @@ -1015,7 +1015,7 @@ memorySegment:
'VARIABLES'
)


memoryType =
(
'EEPROM' |
Expand All @@ -1026,7 +1026,7 @@ memorySegment:
'REGISTER'
)


attribute =
(
'INTERN' |
Expand Down Expand Up @@ -1289,7 +1289,7 @@ fncValues:
'FNC_VALUES'
position = integerValue
datatype = dataType

indexMode =
(
'ALTERNATE_CURVES' |
Expand Down Expand Up @@ -1509,7 +1509,7 @@ unit:
name = identifierValue
longIdentifier = stringValue
display = stringValue

type_ =
(
'DERIVED' |
Expand Down Expand Up @@ -1625,7 +1625,7 @@ varForbiddenComb:

varNaming:
'VAR_NAMING'

tag =
(
'NUMERIC' |
Expand Down Expand Up @@ -1656,7 +1656,7 @@ identifierValue:
;

partialIdentifier:
i = IDENT (a = arraySpecifier)*
i = IDENT (a += arraySpecifier)*
;

arraySpecifier:
Expand Down
11 changes: 5 additions & 6 deletions pya2l/a2l_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,11 @@ def exitIdentifierValue(self, ctx):
ctx.value = text

def exitPartialIdentifier(self, ctx):
text = ctx.i.text if ctx.i else None
arr = ctx.a.value if ctx.a else None
if arr is not None:
ctx.value = "{}[{}]".format(text, arr)
else:
ctx.value = text
text = ctx.i.text if ctx.i else ""
result = ""
for element in ctx.a:
result += "[{}]".format(element.value)
ctx.value = text + result

def exitArraySpecifier(self, ctx):
if ctx.i is not None:
Expand Down

0 comments on commit 860a281

Please sign in to comment.