Added support for floating point types
This commit is contained in:
parent
8f3c5919a7
commit
cac7dd6bec
137
corpus/types.txt
137
corpus/types.txt
|
|
@ -37,7 +37,8 @@ Derived type
|
|||
================================================================================
|
||||
|
||||
package P is
|
||||
type B is new Integer;
|
||||
type B is new Integer
|
||||
with Size => 8;
|
||||
end P;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
@ -54,6 +55,138 @@ end P;
|
|||
(derived_type_definition
|
||||
(subtype_indication
|
||||
(name
|
||||
(identifier)))))))
|
||||
(identifier)))))
|
||||
(aspect_specification
|
||||
(aspect_mark_list
|
||||
(aspect_association
|
||||
(aspect_mark
|
||||
(identifier))
|
||||
(aspect_definition
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))))))))))
|
||||
(name
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Modular types
|
||||
================================================================================
|
||||
|
||||
package P is
|
||||
type C is mod 256;
|
||||
end P;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(compilation
|
||||
(compilation_unit
|
||||
(package_specification
|
||||
(name
|
||||
(identifier))
|
||||
(type_declaration
|
||||
(full_type_declaration
|
||||
(identifier)
|
||||
(type_definition
|
||||
(integer_type_definition
|
||||
(modular_type_definition
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal))))))))))))
|
||||
(name
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Fixed points
|
||||
================================================================================
|
||||
|
||||
package P is
|
||||
type B is new Float range 0.0 .. 1.0;
|
||||
type D is delta 0.1 digits 8;
|
||||
type E is delta 0.1 range 0.0 .. 1.0;
|
||||
end P;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(compilation
|
||||
(compilation_unit
|
||||
(package_specification
|
||||
(name
|
||||
(identifier))
|
||||
(type_declaration
|
||||
(full_type_declaration
|
||||
(identifier)
|
||||
(type_definition
|
||||
(derived_type_definition
|
||||
(subtype_indication
|
||||
(name
|
||||
(identifier))
|
||||
(constraint
|
||||
(scalar_constraint
|
||||
(range_constraint
|
||||
(range_g
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal))))))))))))))
|
||||
(type_declaration
|
||||
(full_type_declaration
|
||||
(identifier)
|
||||
(type_definition
|
||||
(real_type_definition
|
||||
(fixed_point_definition
|
||||
(decimal_fixed_point_definition
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))))
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))))))))))
|
||||
(type_declaration
|
||||
(full_type_declaration
|
||||
(identifier)
|
||||
(type_definition
|
||||
(real_type_definition
|
||||
(fixed_point_definition
|
||||
(ordinary_fixed_point_definition
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))))
|
||||
(real_range_specification
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal))))))))))))
|
||||
(name
|
||||
(identifier)))))
|
||||
|
|
|
|||
45
grammar.js
45
grammar.js
|
|
@ -568,7 +568,7 @@ module.exports = grammar({
|
|||
// optional($.known_discriminant_part),
|
||||
reservedWord('is'),
|
||||
$.type_definition,
|
||||
// optional($.aspect_specification),
|
||||
optional($.aspect_specification),
|
||||
';',
|
||||
),
|
||||
// $.task_type_declaration,
|
||||
|
|
@ -577,7 +577,7 @@ module.exports = grammar({
|
|||
type_definition: $ => choice(
|
||||
// $.enumeration_type_definition,
|
||||
$.integer_type_definition,
|
||||
// $.real_type_definition,
|
||||
$.real_type_definition,
|
||||
// $.array_type_definition,
|
||||
// $.record_type_definition,
|
||||
// $.access_type_definition,
|
||||
|
|
@ -586,7 +586,42 @@ module.exports = grammar({
|
|||
),
|
||||
integer_type_definition: $ => choice(
|
||||
$.signed_integer_type_definition,
|
||||
// $.modular_type_definition,
|
||||
$.modular_type_definition,
|
||||
),
|
||||
modular_type_definition: $ => seq(
|
||||
reservedWord('mod'),
|
||||
$.expression,
|
||||
),
|
||||
real_type_definition: $ => choice(
|
||||
$.floating_point_definition,
|
||||
$.fixed_point_definition,
|
||||
),
|
||||
floating_point_definition: $ => seq(
|
||||
reservedWord('digits'),
|
||||
$.expression,
|
||||
optional($.real_range_specification),
|
||||
),
|
||||
real_range_specification: $ => seq(
|
||||
reservedWord('range'),
|
||||
$.simple_expression,
|
||||
'..',
|
||||
$.simple_expression,
|
||||
),
|
||||
fixed_point_definition: $ => choice(
|
||||
$.ordinary_fixed_point_definition,
|
||||
$.decimal_fixed_point_definition,
|
||||
),
|
||||
decimal_fixed_point_definition: $ => seq(
|
||||
reservedWord('delta'),
|
||||
$.expression,
|
||||
reservedWord('digits'),
|
||||
$.expression,
|
||||
optional($.real_range_specification),
|
||||
),
|
||||
ordinary_fixed_point_definition: $ => seq(
|
||||
reservedWord('delta'),
|
||||
$.expression,
|
||||
$.real_range_specification,
|
||||
),
|
||||
signed_integer_type_definition: $ => seq(
|
||||
reservedWord('range'),
|
||||
|
|
@ -594,7 +629,7 @@ module.exports = grammar({
|
|||
'..',
|
||||
$.simple_expression,
|
||||
),
|
||||
derived_type_definition: $ => seq(
|
||||
derived_type_definition: $ => prec.left(seq(
|
||||
optional(reservedWord('abstract')),
|
||||
optional(reservedWord('limited')),
|
||||
reservedWord('new'),
|
||||
|
|
@ -606,7 +641,7 @@ module.exports = grammar({
|
|||
// )),
|
||||
$.record_extension_part,
|
||||
)),
|
||||
),
|
||||
)),
|
||||
record_extension_part: $ => seq(
|
||||
reservedWord('with'),
|
||||
$.record_definition,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user