1
0

Rename base_type to type_base

This commit is contained in:
Jip J. Dekker 2021-01-14 13:35:10 +11:00
parent 2983b86b9e
commit 64c0fa9e9f
7 changed files with 124 additions and 124 deletions

View File

@ -151,9 +151,9 @@ multiple = let {var int: a, var int: b} in a + b;
(source_file
(assignment (identifier) (let_expression (integer_literal)))
(assignment (identifier) (let_expression (declaration (base_type (primitive_type)) (identifier)) (infix_operator (identifier) (integer_literal))))
(assignment (identifier) (let_expression (declaration (type_base (primitive_type)) (identifier)) (infix_operator (identifier) (integer_literal))))
(assignment (identifier) (let_expression (constraint (infix_operator (identifier) (identifier))) (identifier)))
(assignment (identifier) (let_expression (declaration (base_type (primitive_type)) (identifier)) (declaration (base_type (primitive_type)) (identifier)) (infix_operator (identifier) (identifier)))))
(assignment (identifier) (let_expression (declaration (type_base (primitive_type)) (identifier)) (declaration (type_base (primitive_type)) (identifier)) (infix_operator (identifier) (identifier)))))
===========
Precedences

View File

@ -12,8 +12,8 @@ annotation funcdef(int: x, int: y) = other(x, y);
(source_file
(annotation (identifier))
(annotation (identifier) (identifier))
(annotation (identifier) (base_type (primitive_type)) (base_type (primitive_type)))
(annotation (identifier) (base_type (primitive_type)) (identifier) (base_type (primitive_type)) (identifier) (call (identifier) (identifier) (identifier))))
(annotation (identifier) (type_base (primitive_type)) (type_base (primitive_type)))
(annotation (identifier) (type_base (primitive_type)) (identifier) (type_base (primitive_type)) (identifier) (call (identifier) (identifier) (identifier))))
==========
Assignment
@ -48,8 +48,8 @@ array[X, 1..23] of var int: simple_decl = some_call(X);
---
(source_file
(declaration (base_type (primitive_type)) (identifier))
(declaration (array_type (base_type (identifier)) (base_type (infix_operator (integer_literal) (integer_literal))) (base_type (primitive_type))) (identifier) (call (identifier) (identifier))))
(declaration (type_base (primitive_type)) (identifier))
(declaration (array_type (type_base (identifier)) (type_base (infix_operator (integer_literal) (integer_literal))) (type_base (primitive_type))) (identifier) (call (identifier) (identifier))))
========
Function
@ -63,10 +63,10 @@ function X: with_named_args(X: x, bool: b) = something(b, x);
---
(source_file
(function_item (base_type (primitive_type)) (identifier))
(function_item (base_type (primitive_type)) (identifier) (call (identifier)))
(function_item (base_type (identifier)) (identifier) (base_type (primitive_type)) (base_type (primitive_type)))
(function_item (base_type (identifier)) (identifier) (base_type (identifier)) (identifier) (base_type (primitive_type)) (identifier) (call (identifier) (identifier) (identifier))))
(function_item (type_base (primitive_type)) (identifier))
(function_item (type_base (primitive_type)) (identifier) (call (identifier)))
(function_item (type_base (identifier)) (identifier) (type_base (primitive_type)) (type_base (primitive_type)))
(function_item (type_base (identifier)) (identifier) (type_base (identifier)) (identifier) (type_base (primitive_type)) (identifier) (call (identifier) (identifier) (identifier))))
====
Goal
@ -118,4 +118,4 @@ predicate with_args(1..10: x, var bool: b) = pred();
(source_file
(predicate (identifier))
(predicate (identifier) (call (identifier)))
(predicate (identifier) (base_type (infix_operator (integer_literal) (integer_literal))) (identifier) (base_type (primitive_type)) (identifier) (call (identifier))))
(predicate (identifier) (type_base (infix_operator (integer_literal) (integer_literal))) (identifier) (type_base (primitive_type)) (identifier) (call (identifier))))

View File

@ -10,10 +10,10 @@ array[1..10] of int: expr_index;
---
(source_file
(declaration (array_type (base_type (primitive_type)) (base_type (primitive_type))) (identifier))
(declaration (array_type (base_type (primitive_type)) (base_type (primitive_type)) (base_type (primitive_type))) (identifier))
(declaration (array_type (base_type (identifier)) (base_type (primitive_type))) (identifier))
(declaration (array_type (base_type (infix_operator (integer_literal) (integer_literal))) (base_type (primitive_type))) (identifier)))
(declaration (array_type (type_base (primitive_type)) (type_base (primitive_type))) (identifier))
(declaration (array_type (type_base (primitive_type)) (type_base (primitive_type)) (type_base (primitive_type))) (identifier))
(declaration (array_type (type_base (identifier)) (type_base (primitive_type))) (identifier))
(declaration (array_type (type_base (infix_operator (integer_literal) (integer_literal))) (type_base (primitive_type))) (identifier)))
==========
Identifier
@ -26,9 +26,9 @@ integer: i;
---
(source_file
(declaration (base_type (identifier)) (identifier))
(declaration (base_type (identifier)) (identifier))
(declaration (base_type (identifier)) (identifier)))
(declaration (type_base (identifier)) (identifier))
(declaration (type_base (identifier)) (identifier))
(declaration (type_base (identifier)) (identifier)))
==========
Expression
@ -40,8 +40,8 @@ Expression
---
(source_file
(declaration (base_type (infix_operator (integer_literal) (integer_literal))) (identifier))
(declaration (base_type (infix_operator (prefix_operator (integer_literal)) (call (identifier) (identifier)))) (identifier)))
(declaration (type_base (infix_operator (integer_literal) (integer_literal))) (identifier))
(declaration (type_base (infix_operator (prefix_operator (integer_literal)) (call (identifier) (identifier)))) (identifier)))
========
Optional
@ -54,9 +54,9 @@ par opt int: poi;
---
(source_file
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier)))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier)))
=======
Par/Var
@ -70,10 +70,10 @@ par 1..10: expr_domain;
---
(source_file
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (identifier)) (identifier))
(declaration (base_type (infix_operator (integer_literal) (integer_literal))) (identifier)))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (identifier)) (identifier))
(declaration (type_base (infix_operator (integer_literal) (integer_literal))) (identifier)))
=========
Primitive
@ -88,11 +88,11 @@ string: s;
---
(source_file
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier))
(declaration (base_type (primitive_type)) (identifier)))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier))
(declaration (type_base (primitive_type)) (identifier)))
===
Set
@ -106,7 +106,7 @@ set of 1..10: expr_type_set;
---
(source_file
(declaration (set_type (base_type (primitive_type))) (identifier))
(declaration (set_type (base_type (primitive_type))) (identifier))
(declaration (set_type (base_type (identifier))) (identifier))
(declaration (set_type (base_type (infix_operator (integer_literal) (integer_literal)))) (identifier)))
(declaration (set_type (type_base (primitive_type))) (identifier))
(declaration (set_type (type_base (primitive_type))) (identifier))
(declaration (set_type (type_base (identifier))) (identifier))
(declaration (set_type (type_base (infix_operator (integer_literal) (integer_literal)))) (identifier)))

View File

@ -260,17 +260,17 @@ module.exports = grammar({
'"'
),
_type: ($) => choice($.array_type, $.base_type, $.set_type),
_type: ($) => choice($.array_type, $.type_base, $.set_type),
array_type: ($) =>
seq("array", "[", sepBy1(",", $.base_type), "]", "of", $.base_type),
base_type: ($) =>
seq("array", "[", sepBy1(",", $.type_base), "]", "of", $.type_base),
type_base: ($) =>
seq(
optional(field("var_par", choice("var", "par"))),
optional(field("opt", "opt")),
choice($.primitive_type, $._expression)
),
primitive_type: ($) => choice(...primitive_types),
set_type: ($) => seq("set", "of", $.base_type),
set_type: ($) => seq("set", "of", $.type_base),
_literal: ($) =>
choice(

12
src/grammar.json vendored
View File

@ -1841,7 +1841,7 @@
},
{
"type": "SYMBOL",
"name": "base_type"
"name": "type_base"
},
{
"type": "SYMBOL",
@ -1865,7 +1865,7 @@
"members": [
{
"type": "SYMBOL",
"name": "base_type"
"name": "type_base"
},
{
"type": "REPEAT",
@ -1878,7 +1878,7 @@
},
{
"type": "SYMBOL",
"name": "base_type"
"name": "type_base"
}
]
}
@ -1907,11 +1907,11 @@
},
{
"type": "SYMBOL",
"name": "base_type"
"name": "type_base"
}
]
},
"base_type": {
"type_base": {
"type": "SEQ",
"members": [
{
@ -2008,7 +2008,7 @@
},
{
"type": "SYMBOL",
"name": "base_type"
"name": "type_base"
}
]
},

96
src/node-types.json vendored
View File

@ -132,11 +132,11 @@
"named": true
},
{
"type": "base_type",
"type": "set_type",
"named": true
},
{
"type": "set_type",
"type": "type_base",
"named": true
}
]
@ -240,7 +240,7 @@
"required": true,
"types": [
{
"type": "base_type",
"type": "type_base",
"named": true
}
]
@ -272,50 +272,6 @@
}
}
},
{
"type": "base_type",
"named": true,
"fields": {
"opt": {
"multiple": false,
"required": false,
"types": [
{
"type": "opt",
"named": false
}
]
},
"var_par": {
"multiple": false,
"required": false,
"types": [
{
"type": "par",
"named": false
},
{
"type": "var",
"named": false
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "_expression",
"named": true
},
{
"type": "primitive_type",
"named": true
}
]
}
},
{
"type": "boolean_literal",
"named": true,
@ -1026,7 +982,7 @@
"required": true,
"types": [
{
"type": "base_type",
"type": "type_base",
"named": true
}
]
@ -1086,6 +1042,50 @@
"named": true,
"fields": {}
},
{
"type": "type_base",
"named": true,
"fields": {
"opt": {
"multiple": false,
"required": false,
"types": [
{
"type": "opt",
"named": false
}
]
},
"var_par": {
"multiple": false,
"required": false,
"types": [
{
"type": "par",
"named": false
},
{
"type": "var",
"named": false
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "_expression",
"named": true
},
{
"type": "primitive_type",
"named": true
}
]
}
},
{
"type": "!=",
"named": false

60
src/parser.c vendored
View File

@ -127,7 +127,7 @@ enum {
sym_string_interpolation = 109,
sym__type = 110,
sym_array_type = 111,
sym_base_type = 112,
sym_type_base = 112,
sym_primitive_type = 113,
sym_set_type = 114,
sym__literal = 115,
@ -262,7 +262,7 @@ static const char *ts_symbol_names[] = {
[sym_string_interpolation] = "string_interpolation",
[sym__type] = "_type",
[sym_array_type] = "array_type",
[sym_base_type] = "base_type",
[sym_type_base] = "type_base",
[sym_primitive_type] = "primitive_type",
[sym_set_type] = "set_type",
[sym__literal] = "_literal",
@ -397,7 +397,7 @@ static TSSymbol ts_symbol_map[] = {
[sym_string_interpolation] = sym_string_interpolation,
[sym__type] = sym__type,
[sym_array_type] = sym_array_type,
[sym_base_type] = sym_base_type,
[sym_type_base] = sym_type_base,
[sym_primitive_type] = sym_primitive_type,
[sym_set_type] = sym_set_type,
[sym__literal] = sym__literal,
@ -868,7 +868,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true,
.named = true,
},
[sym_base_type] = {
[sym_type_base] = {
.visible = true,
.named = true,
},
@ -2682,7 +2682,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_string_interpolation] = STATE(76),
[sym__type] = STATE(265),
[sym_array_type] = STATE(265),
[sym_base_type] = STATE(265),
[sym_type_base] = STATE(265),
[sym_primitive_type] = STATE(191),
[sym_set_type] = STATE(265),
[sym__literal] = STATE(76),
@ -2753,7 +2753,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_string_interpolation] = STATE(76),
[sym__type] = STATE(265),
[sym_array_type] = STATE(265),
[sym_base_type] = STATE(265),
[sym_type_base] = STATE(265),
[sym_primitive_type] = STATE(191),
[sym_set_type] = STATE(265),
[sym__literal] = STATE(76),
@ -2824,7 +2824,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[sym_string_interpolation] = STATE(76),
[sym__type] = STATE(265),
[sym_array_type] = STATE(265),
[sym_base_type] = STATE(265),
[sym_type_base] = STATE(265),
[sym_primitive_type] = STATE(191),
[sym_set_type] = STATE(265),
[sym__literal] = STATE(76),
@ -2927,7 +2927,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(265), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(45), 5,
anon_sym_ann,
@ -3007,7 +3007,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(265), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(176), 5,
anon_sym_ann,
@ -3087,7 +3087,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(265), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(45), 5,
anon_sym_ann,
@ -3162,7 +3162,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(220), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(45), 5,
anon_sym_ann,
@ -3237,7 +3237,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(224), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(45), 5,
anon_sym_ann,
@ -3312,7 +3312,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(225), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(235), 5,
anon_sym_ann,
@ -3383,7 +3383,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(254), 4,
sym__type,
sym_array_type,
sym_base_type,
sym_type_base,
sym_set_type,
ACTIONS(45), 5,
anon_sym_ann,
@ -6007,7 +6007,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(227), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6073,7 +6073,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(227), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6137,7 +6137,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(223), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6201,7 +6201,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(203), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6265,7 +6265,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(227), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6329,7 +6329,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(212), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6393,7 +6393,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(194), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -6457,7 +6457,7 @@ static uint16_t ts_small_parse_table[] = {
STATE(191), 1,
sym_primitive_type,
STATE(208), 1,
sym_base_type,
sym_type_base,
ACTIONS(3), 2,
sym_line_comment,
sym_block_comment,
@ -12979,8 +12979,8 @@ static TSParseActionEntry ts_parse_actions[] = {
[483] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_call_repeat1, 2), SHIFT_REPEAT(145),
[486] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_call_repeat1, 2), SHIFT_REPEAT(24),
[489] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_call_repeat1, 2), SHIFT_REPEAT(145),
[492] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_base_type, 2, .production_id = 4),
[494] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_base_type, 2, .production_id = 4),
[492] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_base, 2, .production_id = 4),
[494] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_base, 2, .production_id = 4),
[496] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_generator, 5),
[498] = {.entry = {.count = 1, .reusable = true}}, SHIFT(131),
[500] = {.entry = {.count = 1, .reusable = false}}, SHIFT(128),
@ -12989,13 +12989,13 @@ static TSParseActionEntry ts_parse_actions[] = {
[506] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13),
[508] = {.entry = {.count = 1, .reusable = true}}, SHIFT(102),
[510] = {.entry = {.count = 1, .reusable = false}}, SHIFT(102),
[512] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_base_type, 1),
[514] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_base_type, 1),
[516] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_base_type, 2, .production_id = 5),
[518] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_base_type, 2, .production_id = 5),
[512] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_base, 1),
[514] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_base, 1),
[516] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_base, 2, .production_id = 5),
[518] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_base, 2, .production_id = 5),
[520] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_constraint, 2),
[522] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_base_type, 3, .production_id = 10),
[524] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_base_type, 3, .production_id = 10),
[522] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_base, 3, .production_id = 10),
[524] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_base, 3, .production_id = 10),
[526] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_declaration, 5, .production_id = 25),
[528] = {.entry = {.count = 1, .reusable = true}}, SHIFT(149),
[530] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56),