From 02ecdf3940493c33f2c25f7a59cc43b068a259fa Mon Sep 17 00:00:00 2001 From: Amanda Tang <59590407+amanda849@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:30:25 -0700 Subject: [PATCH] Minor LARK changes (#39) * Include punct in suffix_id * Lark empty comment * Escaped braces should be strings --------- Co-authored-by: Amanda Tang --- mlir/dialect.py | 4 ++-- mlir/lark/mlir.lark | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mlir/dialect.py b/mlir/dialect.py index 3a192ee..fb1cc64 100644 --- a/mlir/dialect.py +++ b/mlir/dialect.py @@ -79,8 +79,8 @@ def make_rules(cls): for fname, ftype in sfields: syntax = syntax.replace('{%s.%s}' % (fname, ftype), ftype) # Replace back braces - syntax = syntax.replace('{LBRACE}', '{') - syntax = syntax.replace('{RBRACE}', '}') + syntax = syntax.replace('{LBRACE}', '"{"') + syntax = syntax.replace('{RBRACE}', '"}"') lark_exprs.append(syntax) cls._fields_ = list(fields) diff --git a/mlir/lark/mlir.lark b/mlir/lark/mlir.lark index 39de4a5..9258111 100644 --- a/mlir/lark/mlir.lark +++ b/mlir/lark/mlir.lark @@ -27,7 +27,7 @@ constant_literal : bool_literal | integer_literal | float_literal | string_liter // Identifier syntax bare_id : (letter| underscore) (letter|digit|underscore|id_chars)* -suffix_id : digits | bare_id +suffix_id : digits | ((letter | id_punct) (letter | id_punct | digits)*) // Dimensions dimension : "?" | decimal_literal @@ -335,5 +335,5 @@ mlir_file: definition_and_function_list* -> only_functions_and_definitions // Things to ignore: whitespace, single-line comments %ignore WS -COMMENT : "//" /(.)+/ NEWLINE +COMMENT : "//" /(.)*/ NEWLINE %ignore COMMENT