can someone clarify when a space matters in rules in Perl 6 grammars? I study some of them by trial and error, but I can not find the actual rules in the documentation.
Example 1:
rule number { <pm> \d '.'? \d*[ <pm> \d* ]? } rule pm { [ '+' || '-' ]? }
Will correspond to the number 2.68156e+154 , and do not care about the spaces that are present in the rule number . However, if I add a space after \d* , it will fail. (i.e. <pm> \d '.'? \d* [ <pm> \d* ]? does not work).
Example 2: If I try to find literals in the middle of a word, it is important that they are around each other. I., in search of the Double_t Delta_phi_R_1_9_pTproj_13_dat_cent_fx3001[52] = {
grammar TOP { ^ .*? <word-to-find> .* ? } rule word-to-find { \w*?fx\w* }
Find the word. However, if the definition of the word-to-find rule is changed to: fx or \w* fx\w* or \w*fx \w* , then it will not match.
In addition, then the definition of '[52]' will match, but the definition of 'fx[52]' will not.
Thank you for understanding. A pointer to the correct point in the documentation would help a lot! Thanks,
source share