classLocation
final class Location
Public API: explicitly declared with
@visibility public.A position in a grammar file, counted from one.
Lemon reports line numbers; the column is added so that a tool can point at the exact character. Lines blanked by the preprocessor keep their newlines, so positions in the tree are positions in the original file.
$file = (new \LemonParser\Parser())->parse("%token_prefix TK_\nexpr ::= expr PLUS expr.\n");
(string) $file->rules()[0]->location // => "2:1"Properties§
public int $linepublic int $columnMethods§
public function __construct(public int $line, public int $column)Parameters
$line | int | Line number, counted from one |
$column | int | Column number, counted from one |
public function __toString(): stringWrites the position as line:column.
Returns
string The positionTest cases 89§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Other tests reaching this symbol 88
CodeBlockTest::testCodecallsDeclarationTest::testLocationcallsDestructorTest::testLocationcallsDirectiveTest::testLocationcallsFallbackTest::testFallbackcallsFallbackTest::testLocationcallsFallbackTest::testTokenscallsPrecedenceDeclarationTest::testLocationcallsTokenClassTest::testLocationcallsTokenDeclarationTest::testLocationcallsTypeDeclarationTest::testLocationcallsWildcardTest::testLocationcallsGrammarFileTest::testDeclarationscallsGrammarFileTest::testRulescallsRhsItemTest::testIsMultiTerminalcallsRhsItemTest::testLocationcallsRuleTest::testSymbolscallsRuleTest::testWithCodecallsRuleTest::testWithNeverReducecallsRuleTest::testWithPrecedencecallsSymbolTest::testIsNonterminalcallsSymbolTest::testIsTerminalcallsLemonGrammarCompilerTestcallsLemonGrammarReaderTest::testNamescallsParserTestcallsConditionTest::testErrorcallsConditionTest::testEvaluatecallsConditionTest::testEvaluateReadsLeftToRightWithoutPrecedencecallsConditionTest::testEvaluateRejectsAnAndWithoutALeftSidecallsConditionTest::testEvaluateRejectsANegationAfterATermcallsConditionTest::testEvaluateRejectsAnOperatorWithoutALeftSidecallsConditionTest::testEvaluateRejectsASingleAmpersandcallsConditionTest::testEvaluateRejectsASingleBarcallsConditionTest::testEvaluateRejectsTwoTermsInARowcallsConditionTest::testGuardcallsConditionTest::testTermcallsConditionTest::testTermRejectsANameStartingWithADigitcallsConditionTest::testTermRejectsAnUnclosedGroupcallsPreprocessorTest::testOpenscallsPreprocessorTest::testSettlecallsPreprocessorTest::testSettleNestsInsideAnExcludedRegioncallsDeclarationPrinterTest::testListcallsDeclarationPrinterTest::testPrintcallsPrinterTest::testPrintcallsRulePrinterTest::testItemcallsRulePrinterTest::testPrintcallsCodeReaderTestcallsCursorTestcallsScannerTestcallsTokenTest::testIscallsTokenTest::testIsAlphaWordcallsTokenTest::testIsLowerWordcallsTokenTest::testIsPunctuationcallsTokenTest::testIsUpperWordcallsDeclarationReaderTest::testArgumentcallsDeclarationReaderTest::testArgumentRejectsPunctuationcallsDeclarationReaderTest::testReadcallsDeclarationReaderTest::testReadDestructorcallsDeclarationReaderTest::testReadDestructorRejectsAMissingSymbolcallsDeclarationReaderTest::testReadRejectsAKeywordThatIsNotAWordcallsDeclarationReaderTest::testReadRejectsAnUnknownKeywordcallsDeclarationReaderTest::testReadTokenClasscallsDeclarationReaderTest::testReadTokenClassRejectsAKnownNamecallsDeclarationReaderTest::testReadTokenClassRejectsATerminalNamecallsDeclarationReaderTest::testReadTypecallsDeclarationReaderTest::testReadTypeRejectsAMissingSymbolcallsDeclarationReaderTest::testReadTypeRejectsASecondTypecallsGrammarReaderTest::testCodecallsGrammarReaderTest::testCodeRejectsAMissingRulecallsGrammarReaderTest::testCodeRejectsASecondBlockcallsGrammarReaderTest::testPrecedencecallsGrammarReaderTest::testPrecedenceRejectsAMissingClosercallsGrammarReaderTest::testPrecedenceRejectsASecondMarkcallsRuleReaderTest::testAliascallsRuleReaderTest::testAliasRejectsABadNamecallsRuleReaderTest::testAliasRejectsAMissingClosercallsRuleReaderTest::testCompoundcallsRuleReaderTest::testCompoundRejectsANonterminalcallsSymbolListReaderTestcallsSymbolRegistryTest::testFallBackcallsSymbolRegistryTest::testIsKnowncallsSymbolRegistryTest::testRankcallsSymbolRegistryTest::testTypecallsSymbolRegistryTest::testWildcardcallsTokenStreamTest::testEofcallsTokenStreamTest::testNextcallsTokenStreamTest::testPeekcallsSyntaxExceptionTest::testGetMessagecalls
Relations§
Instantiated in 3
- new LemonParser\Preprocessor\Preprocessor::preprocess() packages/lemon-parser/src/Preprocessor/Preprocessor.php:54
- new LemonParser\Preprocessor\Preprocessor::preprocess() packages/lemon-parser/src/Preprocessor/Preprocessor.php:58
- new LemonParser\Scanner\Cursor::location() packages/lemon-parser/src/Scanner/Cursor.php:68
Type declarations 38
- type LemonParser\Ast\CodeBlock packages/lemon-parser/src/Ast/CodeBlock.php:27
- type LemonParser\Ast\Declaration\Declaration packages/lemon-parser/src/Ast/Declaration/Declaration.php:25
- type LemonParser\Ast\Declaration\Destructor packages/lemon-parser/src/Ast/Declaration/Destructor.php:32
- type LemonParser\Ast\Declaration\Destructor packages/lemon-parser/src/Ast/Declaration/Destructor.php:39
- type LemonParser\Ast\Declaration\Directive packages/lemon-parser/src/Ast/Declaration/Directive.php:34
- type LemonParser\Ast\Declaration\Directive packages/lemon-parser/src/Ast/Declaration/Directive.php:41
- type LemonParser\Ast\Declaration\Fallback packages/lemon-parser/src/Ast/Declaration/Fallback.php:30
- type LemonParser\Ast\Declaration\Fallback packages/lemon-parser/src/Ast/Declaration/Fallback.php:57
- type LemonParser\Ast\Declaration\PrecedenceDeclaration packages/lemon-parser/src/Ast/Declaration/PrecedenceDeclaration.php:33
- type LemonParser\Ast\Declaration\PrecedenceDeclaration packages/lemon-parser/src/Ast/Declaration/PrecedenceDeclaration.php:40
- type LemonParser\Ast\Declaration\TokenClass packages/lemon-parser/src/Ast/Declaration/TokenClass.php:30
- type LemonParser\Ast\Declaration\TokenClass packages/lemon-parser/src/Ast/Declaration/TokenClass.php:37
- type LemonParser\Ast\Declaration\TokenDeclaration packages/lemon-parser/src/Ast/Declaration/TokenDeclaration.php:27
- type LemonParser\Ast\Declaration\TokenDeclaration packages/lemon-parser/src/Ast/Declaration/TokenDeclaration.php:34
- type LemonParser\Ast\Declaration\TypeDeclaration packages/lemon-parser/src/Ast/Declaration/TypeDeclaration.php:32
- type LemonParser\Ast\Declaration\TypeDeclaration packages/lemon-parser/src/Ast/Declaration/TypeDeclaration.php:39
- type LemonParser\Ast\Declaration\Wildcard packages/lemon-parser/src/Ast/Declaration/Wildcard.php:27
- type LemonParser\Ast\Declaration\Wildcard packages/lemon-parser/src/Ast/Declaration/Wildcard.php:34
- type LemonParser\Ast\RhsItem packages/lemon-parser/src/Ast/RhsItem.php:48
- type LemonParser\Ast\Rule packages/lemon-parser/src/Ast/Rule.php:39
- type LemonParser\Ast\Symbol packages/lemon-parser/src/Ast/Symbol.php:28
- type LemonParser\Preprocessor\Condition packages/lemon-parser/src/Preprocessor/Condition.php:38
- type LemonParser\Preprocessor\Condition packages/lemon-parser/src/Preprocessor/Condition.php:93
- type LemonParser\Preprocessor\Condition packages/lemon-parser/src/Preprocessor/Condition.php:123
- type LemonParser\Preprocessor\Condition packages/lemon-parser/src/Preprocessor/Condition.php:139
- type LemonParser\Preprocessor\Preprocessor packages/lemon-parser/src/Preprocessor/Preprocessor.php:76
- type LemonParser\Preprocessor\Preprocessor packages/lemon-parser/src/Preprocessor/Preprocessor.php:137
- type LemonParser\Scanner\Cursor packages/lemon-parser/src/Scanner/Cursor.php:66
- type LemonParser\Scanner\Token packages/lemon-parser/src/Scanner/Token.php:29
- type LemonParser\Syntax\DeclarationReader packages/lemon-parser/src/Syntax/DeclarationReader.php:50
- type LemonParser\Syntax\DeclarationReader packages/lemon-parser/src/Syntax/DeclarationReader.php:115
- type LemonParser\Syntax\DeclarationReader packages/lemon-parser/src/Syntax/DeclarationReader.php:138
- type LemonParser\Syntax\DeclarationReader packages/lemon-parser/src/Syntax/DeclarationReader.php:161
- type LemonParser\Syntax\SymbolRegistry packages/lemon-parser/src/Syntax/SymbolRegistry.php:73
- type LemonParser\Syntax\SymbolRegistry packages/lemon-parser/src/Syntax/SymbolRegistry.php:90
- type LemonParser\Syntax\SymbolRegistry packages/lemon-parser/src/Syntax/SymbolRegistry.php:107
- type LemonParser\Syntax\SymbolRegistry packages/lemon-parser/src/Syntax/SymbolRegistry.php:124
- type LemonParser\SyntaxException packages/lemon-parser/src/SyntaxException.php:28