biome_js_parser 0.5.7

Biome's JavaScript parser
Documentation
JsModule {
    bom_token: missing (optional),
    interpreter_token: missing (optional),
    directives: JsDirectiveList [],
    items: JsModuleItemList [
        JsFunctionDeclaration {
            async_token: missing (optional),
            function_token: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")],
            star_token: missing (optional),
            id: JsIdentifierBinding {
                name_token: IDENT@9..12 "foo" [] [],
            },
            type_parameters: missing (optional),
            parameters: JsParameters {
                l_paren_token: L_PAREN@12..13 "(" [] [],
                items: JsParameterList [],
                r_paren_token: R_PAREN@13..15 ")" [] [Whitespace(" ")],
            },
            return_type_annotation: missing (optional),
            body: JsFunctionBody {
                l_curly_token: L_CURLY@15..17 "{" [] [Whitespace(" ")],
                directives: JsDirectiveList [],
                statements: JsStatementList [
                    JsBogusStatement {
                        items: [
                            BREAK_KW@17..22 "break" [] [],
                            SEMICOLON@22..24 ";" [] [Whitespace(" ")],
                        ],
                    },
                ],
                r_curly_token: R_CURLY@24..25 "}" [] [],
            },
        },
        JsWhileStatement {
            while_token: WHILE_KW@25..32 "while" [Newline("\n")] [Whitespace(" ")],
            l_paren_token: L_PAREN@32..33 "(" [] [],
            test: JsBooleanLiteralExpression {
                value_token: TRUE_KW@33..37 "true" [] [],
            },
            r_paren_token: R_PAREN@37..39 ")" [] [Whitespace(" ")],
            body: JsBlockStatement {
                l_curly_token: L_CURLY@39..40 "{" [] [],
                statements: JsStatementList [
                    JsBogusStatement {
                        items: [
                            BREAK_KW@40..49 "break" [Newline("\n"), Whitespace("  ")] [Whitespace(" ")],
                            JsLabel {
                                value_token: IDENT@49..52 "foo" [] [],
                            },
                            SEMICOLON@52..53 ";" [] [],
                        ],
                    },
                ],
                r_curly_token: R_CURLY@53..55 "}" [Newline("\n")] [],
            },
        },
    ],
    eof_token: EOF@55..56 "" [Newline("\n")] [],
}

0: JS_MODULE@0..56
  0: (empty)
  1: (empty)
  2: JS_DIRECTIVE_LIST@0..0
  3: JS_MODULE_ITEM_LIST@0..55
    0: JS_FUNCTION_DECLARATION@0..25
      0: (empty)
      1: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")]
      2: (empty)
      3: JS_IDENTIFIER_BINDING@9..12
        0: IDENT@9..12 "foo" [] []
      4: (empty)
      5: JS_PARAMETERS@12..15
        0: L_PAREN@12..13 "(" [] []
        1: JS_PARAMETER_LIST@13..13
        2: R_PAREN@13..15 ")" [] [Whitespace(" ")]
      6: (empty)
      7: JS_FUNCTION_BODY@15..25
        0: L_CURLY@15..17 "{" [] [Whitespace(" ")]
        1: JS_DIRECTIVE_LIST@17..17
        2: JS_STATEMENT_LIST@17..24
          0: JS_BOGUS_STATEMENT@17..24
            0: BREAK_KW@17..22 "break" [] []
            1: SEMICOLON@22..24 ";" [] [Whitespace(" ")]
        3: R_CURLY@24..25 "}" [] []
    1: JS_WHILE_STATEMENT@25..55
      0: WHILE_KW@25..32 "while" [Newline("\n")] [Whitespace(" ")]
      1: L_PAREN@32..33 "(" [] []
      2: JS_BOOLEAN_LITERAL_EXPRESSION@33..37
        0: TRUE_KW@33..37 "true" [] []
      3: R_PAREN@37..39 ")" [] [Whitespace(" ")]
      4: JS_BLOCK_STATEMENT@39..55
        0: L_CURLY@39..40 "{" [] []
        1: JS_STATEMENT_LIST@40..53
          0: JS_BOGUS_STATEMENT@40..53
            0: BREAK_KW@40..49 "break" [Newline("\n"), Whitespace("  ")] [Whitespace(" ")]
            1: JS_LABEL@49..52
              0: IDENT@49..52 "foo" [] []
            2: SEMICOLON@52..53 ";" [] []
        2: R_CURLY@53..55 "}" [Newline("\n")] []
  4: EOF@55..56 "" [Newline("\n")] []
--
break_stmt.js:1:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × A `break` statement can only be used within an enclosing iteration or switch statement.
  
  > 1 │ function foo() { break; }
      │                  ^^^^^
    2 │ while (true) {
    3 │   break foo;
  
--
break_stmt.js:3:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Use of undefined statement label `foo`
  
    1 │ function foo() { break; }
    2 │ while (true) {
  > 3 │   break foo;
      │         ^^^
    4 │ }
    5 │ 
  
  i This label is used, but it is never defined
  
--
function foo() { break; }
while (true) {
  break foo;
}