grammar,compiler: Add Support For Fixed-Width Integers
Distinguishing between signed and unsigned fixed-width integer types must still be done. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -40,9 +40,12 @@ export default grammar({
|
||||
|
||||
// Common - Types
|
||||
typeRef: $ => choice($.baseType, $.type_identifier),
|
||||
baseType: $ => choice($.bool, $.error, $.string, $.int, $.bit /* omitting "templated" types" */),
|
||||
baseType: $ => choice($.bool, $.error, $.string, $.int_type, $.bit /* omitting "templated" types" */),
|
||||
constructor_parameters: $ => seq('(', optional($.parameter_list), ')'),
|
||||
|
||||
int_type: $ => seq($.int, optional($.bit_width)),
|
||||
bit_width: $ => seq('<', $.integer, '>'),
|
||||
|
||||
// Common - Parsers
|
||||
parserType: $ => seq(optional($.annotations), $.parser, field('parser_name', $.identifier), optional($.typeParameters), $.parameters),
|
||||
|
||||
@@ -120,7 +123,7 @@ export default grammar({
|
||||
// Expressions
|
||||
expression: $ => choice($.grouped_expression, $.simple_expression),
|
||||
grouped_expression: $ => seq('(', $.expression, ')'),
|
||||
simple_expression: $ => choice($.identifier, $.integer, $.booleanLiteralExpression, $.string_literal, $.binaryOperatorExpression, $.arrayAccessExpression, $.fieldAccessExpression, $.function_call), // Very limited.
|
||||
simple_expression: $ => choice($.identifier, $.integer, $.integer_elaborated, $.booleanLiteralExpression, $.string_literal, $.binaryOperatorExpression, $.arrayAccessExpression, $.fieldAccessExpression, $.function_call), // Very limited.
|
||||
booleanLiteralExpression: $ => choice($.true, $.false),
|
||||
selectExpression: $ => seq($.select, '(', $.expression, ')', '{', $.selectBody, '}'), // TODO: Should be expression list and not just a single expression
|
||||
transitionSelectionExpression: $ => choice($.identifier, $.selectExpression),
|
||||
@@ -211,6 +214,7 @@ export default grammar({
|
||||
type_identifier: $ => /[A-Za-z_]+/,
|
||||
string_literal: $ => /"[^"]*"/,
|
||||
integer: $ => /[0-9]+/,
|
||||
integer_elaborated: $ => /[0-9]+[ws][-0-9]+/,
|
||||
annotation_literal: $ => /@[A-Za-z_]+/,
|
||||
default_keyset: $=> '_',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user