File tree Expand file tree Collapse file tree 2 files changed +3
-30
lines changed Expand file tree Collapse file tree 2 files changed +3
-30
lines changed Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ will always be the number for the currently parsed C<digit> digits.
299
299
= head2 Methods in grammars
300
300
301
301
It's fine to use methods instead of rules or tokens in a grammar, as long
302
- as they return a L < Cursor |/type/Cursor > :
302
+ as they return a L < Match |/type/Match > :
303
303
304
304
grammar DigitMatcher {
305
305
method TOP (:$full-unicode) {
@@ -372,8 +372,8 @@ say GrammarAdvice.subparse("use regexes for significant whitespace by default")
372
372
Attributes may be defined in grammars. However, they can only be accessed by
373
373
methods; in effect, grammars are classes, so these attributes behave in much the
374
374
same way as object attributes. Attempting to use them from within a token will
375
- throw an exception because tokens are methods of L < Cursor |/type/Cursor > , not of
376
- the grammar itself; C < Cursor > s, in effect, behave as instances of the class that
375
+ throw an exception because tokens are methods of L < Match |/type/Match > , not of
376
+ the grammar itself; C < Match > s, in effect, behave as instances of the class that
377
377
is the grammar. Note that mutating an attribute from within a method called in a
378
378
token will I < only modify the attribute for that token's own match object > !
379
379
Grammar attributes can be accessed in the match returned after parsing if made
Original file line number Diff line number Diff line change 9
9
Initially, it was used to keep track of initial position in regex matches. In
10
10
current versions, it's an alias for L < C < Match > |/type/Match> .
11
11
12
- = head1 Methods
13
-
14
- = head2 method actions
15
-
16
- method actions(Cursor:D: --> Mu)
17
-
18
- Returns the currently active actions object (or L < Mu|/type/Mu > if none is set).
19
-
20
- = head2 method orig
21
-
22
- method orig(Cursor:D: --> Any)
23
-
24
- Returns the object against which the regex matches.
25
-
26
- = head2 method target
27
-
28
- method target(Cursor:D: --> Str:D)
29
-
30
- Returns a string representation of the object against which the regex matches.
31
- This is the value that the regex engine works with internally.
32
-
33
- = head2 method pos
34
-
35
- method pos(Cursor:D: --> Int:D)
36
-
37
- Returns the current position as a string index into C < Cursor.target > .
38
-
39
12
= end pod
40
13
41
14
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
You can’t perform that action at this time.
0 commit comments