Skip to content

Commit

Permalink
Add syntax for datatypes in JML
Browse files Browse the repository at this point in the history
  • Loading branch information
Drodt committed Feb 22, 2024
1 parent d86d57a commit c6bc033
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions key.core/src/main/antlr4/JmlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ CAPTURES: 'captures' Pred -> pushMode(expr);
CODE: 'code'; //?
CONSTRAINT: 'constraint' Pred -> pushMode(expr);
CONTINUES: 'continues' -> pushMode(expr);
DATATYPE: 'datatype';
DEBUG: 'debug'; //?
DECREASING: ('decreasing' | 'decreases' | 'loop_variant') Pred -> pushMode(expr);
DETERMINES: 'determines' -> pushMode(expr);
Expand Down Expand Up @@ -143,6 +144,7 @@ C_IDENT: '\\'? LETTER (LETTERORDIGIT)* -> type(IDENT);
C_COLON: ':' -> type(COLON);
C_DOT: '.' -> type(DOT);
C_COMMA: ',' -> type(COMMA);
C_INCLUSIVEOR: '|' -> type(INCLUSIVEOR);

SL_COMMENT: {jmlMarkerDecision.isComment("//")}? ('//' ('\n'|'\r'|EOF) | '//' ~'@' ~('\n'|'\r')*) -> channel(HIDDEN);
ML_COMMENT: {jmlMarkerDecision.isComment("/*")}? '/*' -> more, pushMode(mlComment);
Expand Down
22 changes: 22 additions & 0 deletions key.core/src/main/antlr4/JmlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classlevel_element
| monitors_for_clause | readable_if_clause | writable_if_clause
| datagroup_clause | set_statement | nowarn_pragma
| accessible_clause | assert_statement | assume_statement
| datatype_declaration
;

methodlevel_comment: (modifiers? methodlevel_element modifiers?)* EOF;
Expand All @@ -41,7 +42,28 @@ modifier
| CODE_JAVA_MATH | CODE_SAFE_MATH | CODE_BIGINT_MATH)
;

datatype_declaration:
DATATYPE
dt_name=IDENT
LBRACE
datatype_constructor (INCLUSIVEOR datatype_constructor)*
SEMI_TOPLEVEL
(datatype_function)*
RBRACE
;

datatype_constructor:
con_name=IDENT
(
LPAREN
(argType+=type argName+=IDENT
(COMMA argType+=type argName+=IDENT)*
)?
RPAREN
)?
;

datatype_function: type IDENT param_list method_body;

class_axiom: AXIOM expression SEMI_TOPLEVEL;
initially_clause: INITIALLY expression SEMI_TOPLEVEL;
Expand Down

0 comments on commit c6bc033

Please sign in to comment.