Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions py/dml/dmllex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

# Reserved words allowed as identifiers
reserved_idents_common = (
'ATTRIBUTE', 'BANK', 'BITORDER', 'CONNECT', 'CONSTANT', 'DATA',
'ATTRIBUTE', 'BANK', 'BITORDER', 'CONNECT', 'CONSTANT',
'DEVICE', 'EVENT', 'FIELD', 'FOOTER', 'GROUP', 'HEADER', 'IMPLEMENT',
'IMPORT', 'INTERFACE', 'LOGGROUP', 'METHOD', 'PORT', 'SIZE',
'SUBDEVICE', 'NOTHROW', 'THEN', 'THROWS', '_HEADER', 'PROVISIONAL',
'SUBDEVICE', 'THEN', 'THROWS', '_HEADER', 'PROVISIONAL',
)

reserved = reserved_idents_common + (
Expand Down
5 changes: 3 additions & 2 deletions py/dml/dmllex12.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
t_HASH = r'\#'

keywords_dml12 = dict(keywords_common)
for kw in ['parameter', 'trait']:
reserved_idents = reserved_idents_common
for kw in ['parameter', 'trait', 'nothrow', 'data']:
keywords_dml12[kw] = kw.upper()
tokens += (kw.upper(),)
reserved_idents = reserved_idents_common + (kw.upper(),)
reserved_idents = reserved_idents + (kw.upper(),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait so the old code failed to properly have PARAMETER as part of reserved_idents? That's hilarious. Given how DML 1.2 code has clearly adapted to this, I'd vote for keeping parameter restricted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote against that because it complicates code for no gain. The gain of keeping it reserved is to open for extending syntax in some ways, like allowing parameter declarations inside methods, and if we ever will want to do that kind of change, then it will be 1.4 exclusive.


def t_ID(t):
r'[A-Za-z_][\w_]*'
Expand Down
8 changes: 4 additions & 4 deletions py/port_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,14 @@ def apply(self, f):
# this.val`, which should not trigger a declaration.
if len(outargs) == 1:
[(_, name)] = outargs
# e.g., an outarg named `data` is lexed as a 'DATA' token
from dml import dmllex12
kind = (name.upper() if name.upper() in dmllex12.reserved_idents
# e.g., an outarg named 'group' is lexed as a 'group' token
from dml import dmllex14
kind = (name.upper() if name.upper() in dmllex14.reserved_idents
else 'ID')
tokens = list(f.read_tokens(self.offset(f, body_start),
self.offset(f, body_end)))
add_locals = any(
(kind2, tok2) == (kind, name) and kind1 != 'DOT'
(kind2, tok2) == (kind, name) and kind1 != 'PERIOD'
for ((_, _, kind1), (_, tok2, kind2))
in zip(tokens, tokens[1:]))
else:
Expand Down
2 changes: 1 addition & 1 deletion test/1.2/misc/porting.dml
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ template evt {
method get_event_info(void *data) -> (attr_value_t attr) {
attr = SIM_make_attr_nil();
}
method set_event_info(attr_value_t attr) -> (void *data) {
method set_event_info(attr_value_t attr) -> (void *param) {
}
method destroy(void *data) {}
method event(void *data) {}
Expand Down
1 change: 1 addition & 0 deletions test/1.2/syntax/T_ident.dml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ method init() {
local int port;
local int size;
local int throws;
local int parameter;
}
5 changes: 2 additions & 3 deletions test/1.4/misc/porting.dml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ bank b {
param soft_reset_val = 4;
is read;
method read() -> (uint64) {
local uint64 val;
local int r2;
return this.val + r6.val;
}
Expand Down Expand Up @@ -431,8 +430,8 @@ template evt is event {
return SIM_make_attr_nil();
}
method set_event_info(attr_value_t attr) -> (void *) {
local void *data;
return data;
local void *param;
return param;
}
method destroy(void *data) {}
method event(void *data) {}
Expand Down