diff --git a/grammar.js b/grammar.js index acd857c..6950b86 100644 --- a/grammar.js +++ b/grammar.js @@ -243,8 +243,23 @@ module.exports = grammar({ ), class_type: ($) => seq(kw("CLASS"), choice($.identifier, $.qualified_name)), + generic_parameter: ($) => seq($.identifier, $.type_tuning), + generic_expression: ($) => + seq( + "<", + _list(choice($.identifier, $.qualified_name, $.generic_parameter), ","), + ">" + ), + generic_type: ($) => + seq(choice($.identifier, $.qualified_name), $.generic_expression), _type: ($) => - choice($.primitive_type, $.identifier, $.qualified_name, $.class_type), + choice( + $.primitive_type, + $.identifier, + $.qualified_name, + $.class_type, + $.generic_type + ), when_expression: ($) => seq(kw("WHEN"), $._expression), assignment: ($) => diff --git a/test/corpus/basic.txt b/test/corpus/basic.txt index 5661736..bfe7180 100644 --- a/test/corpus/basic.txt +++ b/test/corpus/basic.txt @@ -2164,6 +2164,9 @@ VAR INT x = a + b , y = a - b, z = x - y. /* Indeterminate integer array initialized using expressions */ VAR INT[ ] x = [funct( ), a + b]. +/* Generic type */ +var List ListOfAnts. + -------------------------------------------------------------------------------- (source_code @@ -2472,7 +2475,16 @@ VAR INT[ ] x = [funct( ), a + b]. (arguments)) (additive_expression (identifier) - (identifier))))))) + (identifier)))))) + (comment) + (var_statement + (type_tuning + (generic_type + (identifier) + (generic_expression + (identifier)))) + (variable + (identifier)))) ================================================================================ RUN statement