classActionScanner
final class ActionScanner
implements BisonScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Consumes a brace-delimited semantic action.
The body is host-language code, so the closing brace cannot be found by counting braces alone: a brace inside a comment or a string literal does not nest. This scanner therefore walks the body with the same comment and quote rules the lexer uses elsewhere, and only braces it meets outside those change the depth. An action left open by a truncated grammar ends at the end of the file rather than swallowing the parse.
Methods§
public function __construct(BisonTrivia|null $trivia = null)Parameters
$trivia | BisonTrivia|null | Recognises comments met inside the action body |
Test cases 10
ActionScannerTest::testHandlesClaimsOnlyAnOpeningBracecoversActionScannerTest::testScanExcludesTheOuterBracesFromTheBodycoversActionScannerTest::testScanIgnoresABraceInsideABlockCommentcoversActionScannerTest::testScanIgnoresABraceInsideACharacterLiteralcoversActionScannerTest::testScanIgnoresABraceInsideALineCommentcoversActionScannerTest::testScanIgnoresABraceInsideAStringcoversActionScannerTest::testScanKeepsNestedBracesInTheBodycoversActionScannerTest::testScanReadsALoneSlashAsBodyTextcoversActionScannerTest::testScanReadsAnEmptyActionAsAnEmptyBodycoversActionScannerTest::testScanRunsAnUnclosedActionToTheEndOfTheFilecovers
Calls 1
- new BisonTrivia line 31
public function handles(string $character): boolReports whether an action can start here.
Parameters
$character | string | A single character; never the empty string |
Returns
bool True for an opening braceTest cases 1
ActionScannerTest::testHandlesClaimsOnlyAnOpeningBracecovers and calls
public function scan(SourceCursor $cursor): BisonTokenConsumes the action and everything nested inside it.
Parameters
$cursor | SourceCursor | Cursor positioned on the opening brace |
Returns
BisonToken The action and its body, without the outer bracesTest cases 9
ActionScannerTest::testScanExcludesTheOuterBracesFromTheBodycovers and callsActionScannerTest::testScanIgnoresABraceInsideABlockCommentcovers and callsActionScannerTest::testScanIgnoresABraceInsideACharacterLiteralcovers and callsActionScannerTest::testScanIgnoresABraceInsideALineCommentcovers and callsActionScannerTest::testScanIgnoresABraceInsideAStringcovers and callsActionScannerTest::testScanKeepsNestedBracesInTheBodycovers and callsActionScannerTest::testScanReadsALoneSlashAsBodyTextcovers and callsActionScannerTest::testScanReadsAnEmptyActionAsAnEmptyBodycovers and callsActionScannerTest::testScanRunsAnUnclosedActionToTheEndOfTheFilecovers and calls
Calls 9
- method-call SourceCursor::offset() line 57
- method-call SourceCursor::atEnd() line 62
- method-call SourceCursor::current() line 63
- method-call BisonTrivia::skipCommentAt() line 65
- method-call SourceCursor::takeQuoted() line 70
- method-call SourceCursor::advance() line 76
- new BisonToken line 95
- class-const BisonLexeme::Action() line 95
- method-call SourceCursor::textBetween() line 95
Private surface 1§
Implementation details, listed for orientation only.
private BisonTrivia $triviaTest cases 27§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
ActionScannerTest::testHandlesClaimsOnlyAnOpeningBracecovers and callsActionScannerTest::testScanExcludesTheOuterBracesFromTheBodycovers and callsActionScannerTest::testScanIgnoresABraceInsideABlockCommentcovers and callsActionScannerTest::testScanIgnoresABraceInsideACharacterLiteralcovers and callsActionScannerTest::testScanIgnoresABraceInsideALineCommentcovers and callsActionScannerTest::testScanIgnoresABraceInsideAStringcovers and callsActionScannerTest::testScanKeepsNestedBracesInTheBodycovers and callsActionScannerTest::testScanReadsALoneSlashAsBodyTextcovers and callsActionScannerTest::testScanReadsAnEmptyActionAsAnEmptyBodycovers and callsActionScannerTest::testScanRunsAnUnclosedActionToTheEndOfTheFilecovers and calls
Other tests reaching this symbol 17
BisonParserTestcallsBisonPreambleReaderTestcallsBisonDirectiveReaderChainTestcallsDefineDirectiveReaderTestcallsExpectDirectiveReaderTestcallsParamDirectiveReaderTestcallsPrecedenceDirectiveReaderTestcallsStartDirectiveReaderTestcallsTokenDirectiveReaderTestcallsTypeDirectiveReaderTestcallsUnknownDirectiveReaderTestcallsBisonLexerTestcallsBisonScannerChainTest::providerClaimedCharactercallsBisonScannerTest::providerScannercallsBisonTokenStreamTestcallsBisonAlternativeReaderTestcallsBisonRuleReaderTestcalls