Fixed 'raw strings backslash issue'

Fixed 'library type name dot issue'
Worked on 'type cast issue' (unfinished)
pull/185/head
Ben Sobel 2020-07-19 18:28:26 +07:00
parent b32eff2dc8
commit 321d95d794
9 changed files with 72491 additions and 67379 deletions

@ -4,20 +4,24 @@
const DIGITS = token(sep1(/[0-9]+/, /_+/))
const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, '_'))
//Everything above RelationalTypeCast was incremented from its original value
//This was to get type casting issues finally fixed.
const DART_PREC = {
IMPORT_EXPORT: 18,
TYPE_IDENTIFIER: 17, //was: 17
DOT_IDENTIFIER: 18, //was: 18
UNARY_POSTFIX: 16,
UNARY_PREFIX: 15,
Multiplicative: 14, // *, /, ˜/, % Left
Additive: 13, // +, - Left
Shift: 12, // <<, >>, >>> Left
TYPE_ARGUMENTS: 12,
Bitwise_AND: 11, // & Left
Bitwise_XOR: 10, // ˆ Left
Bitwise_Or: 9, // | Left
Relational: 8, // <, >, <=, >=, as, is, is! None 8
IMPORT_EXPORT: 19,
TYPE_IDENTIFIER: 18, //was: 17
DOT_IDENTIFIER: 19, //was: 18
UNARY_POSTFIX: 17,
UNARY_PREFIX: 16,
Multiplicative: 15, // *, /, ˜/, % Left
Additive: 14, // +, - Left
Shift: 13, // <<, >>, >>> Left
TYPE_ARGUMENTS: 13,
Bitwise_AND: 12, // & Left
Bitwise_XOR: 11, // ˆ Left
Bitwise_Or: 10, // | Left
Relational: 9, // <, >, <=, >=, as, is, is! None 8
RelationalTypeCast: 8, // <, >, <=, >=, as, is, is! None 8
Equality: 7, // ==, != None 7
Logical_AND: 6, // AND && Left
Logical_OR: 5, // Or || Left
@ -57,6 +61,7 @@ module.exports = grammar({
$._template_chars_single,
$._template_chars_double_single,
$._template_chars_single_single,
$._template_chars_raw_slash
],
extras: $ => [
@ -83,8 +88,8 @@ module.exports = grammar({
conflicts: $ => [
[$.block, $.set_or_map_literal],
[$._primary, $.function_signature],
[$._primary, $.function_signature, $._type_name],
[$._primary, $._type_name],
[$._type_name, $._primary, $.function_signature],
[$._type_name, $._primary],
[$.variable_declaration, $.initialized_variable_definition, ],
[$._final_const_var_or_type, $.function_signature, ],
[$._primary, $._function_formal_parameter],
@ -123,12 +128,18 @@ module.exports = grammar({
[$.assignable_selector_part, $.postfix_expression],
[$._primary, $.assignable_expression],
[$._simple_formal_parameter, $.assignable_expression],
[$.assignable_expression, $._primary, $._type_name],
[$._type_name, $._primary, $.assignable_expression],
[$.assignable_expression, $.postfix_expression],
[$.assignable_expression, $._postfix_expression],
[$.assignable_expression, $._type_name],
[$._type_name, $.assignable_expression],
[$._type_name, $.function_signature],
[$._type_name, $._function_formal_parameter],
[$._type_name],
// [$.assignment_expression, $._expression],
[$.assignable_expression],
// [$.type_cast_expression],
[$._real_expression, $._below_relational_type_cast_expression],
[$._below_relational_expression, $._below_relational_type_cast_expression],
[$._function_type_tail]
],
@ -200,8 +211,15 @@ module.exports = grammar({
$.static_final_declaration_list,
$._semicolon
),
seq(
$._late_builtin,
$._final_builtin,
optional($._type),
$.initialized_identifier_list,
$._semicolon
),
seq(
optional($._late_builtin),
choice($._type, 'var'),
$.initialized_identifier_list,
$._semicolon
@ -344,8 +362,10 @@ module.exports = grammar({
'r"',
repeat(choice(
$._template_chars_double_single,
// /[^\n"]*/,
'\'',
'\\',
$._template_chars_raw_slash,
// '\\',
$._unused_escape_sequence,
$._sub_string_test,
'$'
@ -356,8 +376,10 @@ module.exports = grammar({
'r\'',
repeat(choice(
$._template_chars_single_single,
// /[^\n']/,
'"',
'\\',
$._template_chars_raw_slash,
// '\\',
$._unused_escape_sequence,
$._sub_string_test,
'$'
@ -367,33 +389,41 @@ module.exports = grammar({
_raw_string_literal_double_quotes_multiple: $ => prec.left(
seq(
'r"""',
// $._triple_double_quote_end,
repeat(choice(
$._template_chars_double,
'\'',
'\\',
// '\\',
$._template_chars_raw_slash,
'"',
$._unused_escape_sequence,
$._sub_string_test,
'$'
)),
'"""'
// $._triple_double_quote_end
),
),
_raw_string_literal_single_quotes_multiple: $ => prec.left(
seq(
'r\'\'\'',
// $._triple_quote_end,
repeat(choice(
$._template_chars_single,
'"',
'\'',
'\\',
// '\\',
$._template_chars_raw_slash,
$._unused_escape_sequence,
$._sub_string_test,
'$'
)),
'\'\'\''
// $._triple_quote_end
),
),
_triple_quote_end: $ => token('\'\'\''),
_triple_double_quote_end: $ => token('"""'),
template_substitution: $ => seq(
'$',
choice(
@ -498,6 +528,7 @@ module.exports = grammar({
$.bitwise_or_expression,
$.bitwise_xor_expression,
$.shift_expression,
// $.type_cast_expression,
$._unary_expression
),
@ -510,6 +541,7 @@ module.exports = grammar({
// Bitwise_AND: 11, // & Left
// Bitwise_XOR: 10, // ˆ Left
// Bitwise_Or: 9 , // | Left
// $.type_cast_expression,
$._unary_expression,
$.multiplicative_expression,
$.additive_expression,
@ -519,6 +551,26 @@ module.exports = grammar({
$.bitwise_xor_expression,
),
_below_relational_type_cast_expression: $ => choice(
// UNARY_POSTFIX: 16,
// UNARY_PREFIX: 15,
// Multiplicative: 14, // *, /, ˜/, % Left
// Additive: 13, // +, - Left
// Shift: 12, // <<, >>, >>> Left
// Bitwise_AND: 11, // & Left
// Bitwise_XOR: 10, // ˆ Left
// Bitwise_Or: 9 , // | Left
$._unary_expression,
$.multiplicative_expression,
$.additive_expression,
$.shift_expression,
$.bitwise_and_expression,
$.bitwise_or_expression,
$.bitwise_xor_expression,
),
throw_expression: $ => seq(
'throw',
$._expression
@ -712,29 +764,63 @@ module.exports = grammar({
'!='
)
),
// type_cast_expression: $ => prec(
// DART_PREC.RelationalTypeCast,
// seq(
// $._below_relational_type_cast_expression,
// $.type_cast,
// )
// ),
relational_expression: $ => prec( // neither
DART_PREC.Relational,
choice(
seq(
$._below_relational_type_cast_expression,
$.type_cast,
),
seq(
// $.bitwise_or_expression,
$._below_relational_expression,
$._below_relational_type_cast_expression,
// TODO: The spec says optional but it breaks tests, and I'm not sure in a good way.
// optional(
choice(
seq(
$.relational_operator,
$._below_relational_expression
),
$.type_test,
$.type_cast,
),
// Modified to account for type casts being compared relationally!
// I am not certain this is what designers intended. (see other comments on github)
// optional(
choice(
$.type_test,
seq(
$.relational_operator,
$._below_relational_type_cast_expression
)
)
// ),
),
seq(
// $.bitwise_or_expression,
$._below_relational_type_cast_expression,
$.type_cast,
$.relational_operator,
$._below_relational_type_cast_expression
),
seq(
// $.bitwise_or_expression,
$._below_relational_type_cast_expression,
$.relational_operator,
$._below_relational_type_cast_expression,
$.type_cast,
),
seq(
// $.bitwise_or_expression,
$._below_relational_type_cast_expression,
$.type_cast,
$.relational_operator,
$._below_relational_type_cast_expression,
$.type_cast,
),
seq(
$.super,
$.relational_operator,
$._below_relational_expression
$._real_expression
),
)
),
@ -752,7 +838,7 @@ module.exports = grammar({
bitwise_and_expression: $ => binaryRunLeft($._real_expression, '&', $.super, DART_PREC.Bitwise_AND),
shift_expression: $ => binaryRunLeft($._real_expression, $.shift_operator, $.super, DART_PREC.Shift),
additive_expression: $ => binaryRunLeft($._real_expression, $.additive_operator, $.super, DART_PREC.Additive),
multiplicative_expression: $ => binaryRunLeft($._real_expression, $.multiplicative_operator, $.super, DART_PREC.Multiplicative),
multiplicative_expression: $ => binaryRunLeft($._unary_expression, $.multiplicative_operator, $.super, DART_PREC.Multiplicative),
bitwise_operator: $ => $._bitwise_operator,
_bitwise_operator: $ => choice(
'&',
@ -780,9 +866,12 @@ module.exports = grammar({
'~/'
),
_unary_expression: $ => choice(
$._postfix_expression,
$.unary_expression,
_unary_expression: $ => prec(
DART_PREC.UNARY_PREFIX,
choice(
$._postfix_expression,
$.unary_expression,
)
),
unary_expression: $ => prec( //neither
@ -883,10 +972,7 @@ module.exports = grammar({
$._type_not_void
),
as_operator: $ => prec(
DART_PREC.BUILTIN,
'as',
),
as_operator: $ => token('as'),
new_expression: $ => seq(
$._new_builtin,
@ -1001,11 +1087,14 @@ module.exports = grammar({
seq('[', $._expression, ']'),
$.identifier
),
argument_part: $ => choice(
seq(
$.type_arguments,
$.arguments
argument_part: $ => seq(
optional(
$.type_arguments
),
// seq(
// $.type_arguments,
// $.arguments
// ),
$.arguments
),
@ -1842,11 +1931,15 @@ module.exports = grammar({
// Types
_final_const_var_or_type: $ => choice(
seq($._final_builtin, optional($._type)),
seq($._const_builtin, optional($._type)),
seq($._late_builtin, optional($._final_builtin), optional($._type)),
$.inferred_type,
$._type
seq(optional($._late_builtin), $._final_builtin, optional($._type)),
seq($._const_builtin, optional(
$._type
)),
seq(optional($._late_builtin),
choice(
$.inferred_type,
$._type
))
),
_type: $ => choice(
@ -1941,8 +2034,7 @@ module.exports = grammar({
$._type_not_void
),
_type_name: $ => prec.left(
seq(
_type_name: $ => seq(
alias(
$.identifier,
$.type_identifier
@ -1951,11 +2043,10 @@ module.exports = grammar({
$._type_dot_identifier
),
optional($._nullable_type),
)
),
),
_type_dot_identifier: $ => prec.dynamic(
DART_PREC.TYPE_IDENTIFIER,
_type_dot_identifier: $ => prec.right(
DART_PREC.IMPORT_EXPORT,
seq(
'.',
alias(

@ -301,6 +301,51 @@
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_late_builtin"
},
{
"type": "SYMBOL",
"name": "_final_builtin"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_type"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "initialized_identifier_list"
},
{
"type": "SYMBOL",
"name": "_semicolon"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_late_builtin"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
@ -1148,8 +1193,8 @@
"value": "'"
},
{
"type": "STRING",
"value": "\\"
"type": "SYMBOL",
"name": "_template_chars_raw_slash"
},
{
"type": "SYMBOL",
@ -1193,8 +1238,8 @@
"value": "\""
},
{
"type": "STRING",
"value": "\\"
"type": "SYMBOL",
"name": "_template_chars_raw_slash"
},
{
"type": "SYMBOL",
@ -1241,8 +1286,8 @@
"value": "'"
},
{
"type": "STRING",
"value": "\\"
"type": "SYMBOL",
"name": "_template_chars_raw_slash"
},
{
"type": "STRING",
@ -1298,8 +1343,8 @@
"value": "'"
},
{
"type": "STRING",
"value": "\\"
"type": "SYMBOL",
"name": "_template_chars_raw_slash"
},
{
"type": "SYMBOL",
@ -1323,6 +1368,20 @@
]
}
},
"_triple_quote_end": {
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "'''"
}
},
"_triple_double_quote_end": {
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "\"\"\""
}
},
"template_substitution": {
"type": "SEQ",
"members": [
@ -1774,6 +1833,39 @@
}
]
},
"_below_relational_type_cast_expression": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_unary_expression"
},
{
"type": "SYMBOL",
"name": "multiplicative_expression"
},
{
"type": "SYMBOL",
"name": "additive_expression"
},
{
"type": "SYMBOL",
"name": "shift_expression"
},
{
"type": "SYMBOL",
"name": "bitwise_and_expression"
},
{
"type": "SYMBOL",
"name": "bitwise_or_expression"
},
{
"type": "SYMBOL",
"name": "bitwise_xor_expression"
}
]
},
"throw_expression": {
"type": "SEQ",
"members": [
@ -2255,7 +2347,7 @@
},
"relational_expression": {
"type": "PREC",
"value": 8,
"value": 9,
"content": {
"type": "CHOICE",
"members": [
@ -2264,11 +2356,28 @@
"members": [
{
"type": "SYMBOL",
"name": "_below_relational_expression"
"name": "_below_relational_type_cast_expression"
},
{
"type": "SYMBOL",
"name": "type_cast"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "type_test"
},
{
"type": "SEQ",
"members": [
@ -2278,22 +2387,81 @@
},
{
"type": "SYMBOL",
"name": "_below_relational_expression"
"name": "_below_relational_type_cast_expression"
}
]
},
{
"type": "SYMBOL",
"name": "type_test"
},
{
"type": "SYMBOL",
"name": "type_cast"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
},
{
"type": "SYMBOL",
"name": "type_cast"
},
{
"type": "SYMBOL",
"name": "relational_operator"
},
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
},
{
"type": "SYMBOL",
"name": "relational_operator"
},
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
},
{
"type": "SYMBOL",
"name": "type_cast"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
},
{
"type": "SYMBOL",
"name": "type_cast"
},
{
"type": "SYMBOL",
"name": "relational_operator"
},
{
"type": "SYMBOL",
"name": "_below_relational_type_cast_expression"
},
{
"type": "SYMBOL",
"name": "type_cast"
}
]
},
{
"type": "SEQ",
"members": [
@ -2307,7 +2475,7 @@
},
{
"type": "SYMBOL",
"name": "_below_relational_expression"
"name": "_real_expression"
}
]
}
@ -2315,29 +2483,32 @@
}
},
"relational_operator": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "<"
},
{
"type": "STRING",
"value": ">"
},
{
"type": "STRING",
"value": ">="
},
{
"type": "STRING",
"value": "<="
}
]
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "<"
},
{
"type": "STRING",
"value": ">"
},
{
"type": "STRING",
"value": ">="
},
{
"type": "STRING",
"value": "<="
}
]
}
},
"bitwise_or_expression": {
"type": "PREC_LEFT",
"value": 9,
"value": 10,
"content": {
"type": "CHOICE",
"members": [
@ -2396,7 +2567,7 @@
},
"bitwise_xor_expression": {
"type": "PREC_LEFT",
"value": 10,
"value": 11,
"content": {
"type": "CHOICE",
"members": [
@ -2455,7 +2626,7 @@
},
"bitwise_and_expression": {
"type": "PREC_LEFT",
"value": 11,
"value": 12,
"content": {
"type": "CHOICE",
"members": [
@ -2514,7 +2685,7 @@
},
"shift_expression": {
"type": "PREC_LEFT",
"value": 12,
"value": 13,
"content": {
"type": "CHOICE",
"members": [
@ -2573,7 +2744,7 @@
},
"additive_expression": {
"type": "PREC_LEFT",
"value": 13,
"value": 14,
"content": {
"type": "CHOICE",
"members": [
@ -2632,7 +2803,7 @@
},
"multiplicative_expression": {
"type": "PREC_LEFT",
"value": 14,
"value": 15,
"content": {
"type": "CHOICE",
"members": [
@ -2641,7 +2812,7 @@
"members": [
{
"type": "SYMBOL",
"name": "_real_expression"
"name": "_unary_expression"
},
{
"type": "REPEAT1",
@ -2654,7 +2825,7 @@
},
{
"type": "SYMBOL",
"name": "_real_expression"
"name": "_unary_expression"
}
]
}
@ -2679,7 +2850,7 @@
},
{
"type": "SYMBOL",
"name": "_real_expression"
"name": "_unary_expression"
}
]
}
@ -2777,21 +2948,25 @@
]
},
"_unary_expression": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_postfix_expression"
},
{
"type": "SYMBOL",
"name": "unary_expression"
}
]
"type": "PREC",
"value": 16,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_postfix_expression"
},
{
"type": "SYMBOL",
"name": "unary_expression"
}
]
}
},
"unary_expression": {
"type": "PREC",
"value": 15,
"value": 16,
"content": {
"type": "CHOICE",
"members": [
@ -3065,8 +3240,7 @@
]
},
"as_operator": {
"type": "PREC",
"value": 0,
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "as"
@ -3103,7 +3277,7 @@
},
"_dot_identifier": {
"type": "PREC_DYNAMIC",
"value": 18,
"value": 19,
"content": {
"type": "SEQ",
"members": [
@ -3512,18 +3686,17 @@
]
},
"argument_part": {
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "type_arguments"
},
{
"type": "SYMBOL",
"name": "arguments"
"type": "BLANK"
}
]
},
@ -4933,7 +5106,7 @@
},
"import_or_export": {
"type": "PREC",
"value": 18,
"value": 19,
"content": {
"type": "CHOICE",
"members": [
@ -7415,6 +7588,18 @@
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_late_builtin"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_final_builtin"
@ -7457,16 +7642,12 @@
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_late_builtin"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_final_builtin"
"name": "_late_builtin"
},
{
"type": "BLANK"
@ -7478,22 +7659,15 @@
"members": [
{
"type": "SYMBOL",
"name": "_type"
"name": "inferred_type"
},
{
"type": "BLANK"
"type": "SYMBOL",
"name": "_type"
}
]
}
]
},
{
"type": "SYMBOL",
"name": "inferred_type"
},
{
"type": "SYMBOL",
"name": "_type"
}
]
},
@ -7946,50 +8120,46 @@
]
},
"_type_name": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "type_identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
"name": "_type_dot_identifier"
},
"named": true,
"value": "type_identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_type_dot_identifier"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_nullable_type"
},
{
"type": "BLANK"
}
]
}
]
}
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_nullable_type"
},
{
"type": "BLANK"
}
]
}
]
},
"_type_dot_identifier": {
"type": "PREC_DYNAMIC",
"value": 17,
"type": "PREC_RIGHT",
"value": 19,
"content": {
"type": "SEQ",
"members": [
@ -9404,13 +9574,13 @@
"function_signature"
],
[
"_type_name",
"_primary",
"function_signature",
"_type_name"
"function_signature"
],
[
"_primary",
"_type_name"
"_type_name",
"_primary"
],
[
"variable_declaration",
@ -9556,9 +9726,9 @@
"assignable_expression"
],
[
"assignable_expression",
"_type_name",
"_primary",
"_type_name"
"assignable_expression"
],
[
"assignable_expression",
@ -9569,12 +9739,31 @@
"_postfix_expression"
],
[
"assignable_expression",
"_type_name",
"assignable_expression"
],
[
"_type_name",
"function_signature"
],
[
"_type_name",
"_function_formal_parameter"
],
[
"_type_name"
],
[
"assignable_expression"
],
[
"_real_expression",
"_below_relational_type_cast_expression"
],
[
"_below_relational_expression",
"_below_relational_type_cast_expression"
],
[
"_function_type_tail"
]
@ -9599,6 +9788,10 @@
{
"type": "SYMBOL",
"name": "_template_chars_single_single"
},
{
"type": "SYMBOL",
"name": "_template_chars_raw_slash"
}
],
"inline": [

@ -8111,11 +8111,6 @@
]
}
},
{
"type": "relational_operator",
"named": true,
"fields": {}
},
{
"type": "return_statement",
"named": true,
@ -10363,10 +10358,6 @@
"type": "<<",
"named": false
},
{
"type": "<=",
"named": false
},
{
"type": "=",
"named": false
@ -10383,10 +10374,6 @@
"type": ">",
"named": false
},
{
"type": ">=",
"named": false
},
{
"type": ">>",
"named": false
@ -10427,10 +10414,6 @@
"type": "[]=",
"named": false
},
{
"type": "\\",
"named": false
},
{
"type": "]",
"named": false
@ -10671,6 +10654,10 @@
"type": "r'''",
"named": false
},
{
"type": "relational_operator",
"named": true
},
{
"type": "required",
"named": false

File diff suppressed because it is too large Load Diff

@ -5,8 +5,9 @@ enum TokenType {
AUTOMATIC_SEMICOLON,
TEMPLATE_CHARS_SINGLE,
TEMPLATE_CHARS_DOUBLE,
TEMPLATE_CHARS_SINGLE_SINGLE,
TEMPLATE_CHARS_DOUBLE_SINGLE
TEMPLATE_CHARS_SINGLE_SINGLE,
TEMPLATE_CHARS_DOUBLE_SINGLE,
TEMPLATE_CHARS_RAW_SLASH
};
void *tree_sitter_dart_external_scanner_create() { return NULL; }
@ -87,7 +88,13 @@ bool tree_sitter_dart_external_scanner_scan(void *payload, TSLexer *lexer,
// break;
return has_content;
case '\\':
return has_content;
if (valid_symbols[TEMPLATE_CHARS_RAW_SLASH]) {
lexer->result_symbol = TEMPLATE_CHARS_RAW_SLASH;
advance(lexer);
} else {
return false;
}
break;
default:
advance(lexer);
}

@ -55,7 +55,7 @@ dart string literals raw
=========================================
get a => "";
get a => r"\"";
get a => r"\";
get a => """This' is a string $mystring""";
get a => '''This" is a $
string mystring''';
@ -335,4 +335,3 @@ class MyClass {
(formal_parameter_list (formal_parameter (type_identifier) (identifier)))))
(function_body (block (expression_statement (assignment_expression (assignable_expression (identifier)) (identifier))))))))

@ -475,3 +475,56 @@ Type with Library Prefix
const my.MyType newMyType = my.MyType();
---
(program
(type_identifier) (type_identifier)
(static_final_declaration_list
(static_final_declaration
(identifier)
(identifier) (selector
(assignable_selector (unconditional_assignable_selector (identifier)))
)
(selector (argument_part (arguments)))
)
)
)
==================================
Type with Library Prefix Plus
==================================
const my.MyType newMyType;
const my.MyType newMytype;
---
(program
(local_variable_declaration (initialized_variable_definition (type_identifier) (type_identifier) (identifier)))
(local_variable_declaration (initialized_variable_definition (type_identifier) (type_identifier) (identifier)))
)
==================================
Type with Library Prefix Plus Final
==================================
final my.MyType newMyType = my.MyType();
final my.MyType newMytype;
if (blah) {
const my.myType newMyType = ggg;
const mytype = 2;
}
---
(program
(local_variable_declaration (initialized_variable_definition (type_identifier) (type_identifier) (identifier) (identifier) (selector
(assignable_selector (unconditional_assignable_selector (identifier)))) (selector (argument_part (arguments)))))
(local_variable_declaration (initialized_variable_definition (type_identifier) (type_identifier) (identifier)))
(if_statement (parenthesized_expression (identifier))
(block
(local_variable_declaration (initialized_variable_definition (type_identifier) (type_identifier) (identifier) (identifier)))
(local_variable_declaration (initialized_variable_definition (identifier) (decimal_integer_literal)))
)
)
)

@ -371,7 +371,53 @@ if (data['frame_count'] as int < 5) {
---
(program )
(program
(if_statement
(parenthesized_expression
(relational_expression
(relational_expression
(identifier) (selector
(assignable_selector (unconditional_assignable_selector (string_literal)))
)
(type_cast (as_operator) (type_identifier))
)
(relational_operator)
(decimal_integer_literal)
)
)
(block)
)
)
===========================
Type cast in if statement parenthesized
===========================
if ((data['frame_count'] as int) < 5) {
}
---
(program
(if_statement
(parenthesized_expression
(relational_expression
(relational_expression
(identifier) (selector
(assignable_selector (unconditional_assignable_selector (string_literal)))
)
(type_cast (as_operator) (type_identifier))
)
(relational_operator)
(decimal_integer_literal)
)
)
(block)
)
)
==========================
@ -472,3 +518,52 @@ Complex type cast in function call
printStream(args['json'] as bool ? '' : 'hi');
---
(program
(expression_statement
(identifier)
(selector
(argument_part
(arguments
(conditional_expression
(relational_expression (identifier)
(selector (assignable_selector (unconditional_assignable_selector (string_literal))))
(type_cast (as_operator) (type_identifier))
)
(string_literal)
(string_literal)
)
)
)
)
)
)
============================
Complex (parenthesized) type cast in function call
============================
printStream((args['json'] as bool) ? '' : 'hi');
---
(program
(expression_statement
(identifier)
(selector
(argument_part
(arguments
(conditional_expression
(relational_expression (identifier)
(selector (assignable_selector (unconditional_assignable_selector (string_literal))))
(type_cast (as_operator) (type_identifier))
)
(string_literal)
(string_literal)
)
)
)
)
)
)

@ -153,12 +153,28 @@ complex string interpolation
=============
raw strings with backslashes
raw strings single
=============
r'\';
r'''\''';
---
(program
(expression_statement (string_literal))
(expression_statement (string_literal))
)
=============
raw strings double
=============
r"\";
r"""\""";
---
(program
(expression_statement (string_literal))
(expression_statement (string_literal))
)