|
Pages: [1]
|
 |
|
Author
|
Topic: why this rule always give "a" ? (Read 367 times)
|
parse
Guest
|
>> rules: ["a" (probe "a") | "ab" (probe "ab")] == ["a" (probe "a") | "ab" (probe "ab")] >> parse "a" rules "a" == true >> parse "ab" rules "a" == false >>
|
|
|
|
|
Logged
|
|
|
|
parse
Guest
|
Sorry I forgot end >> rules: ["a" end (probe "a") | "ab" end (probe "ab")] == ["a" end (probe "a") | "ab" end (probe "ab")] >> parse "ab" rules "ab" == true
=================
but the problem is rather when I want to copy text after "a" or "ab" it doesn't give me textab:
>> rules: ["a" copy text to end (probe "a") | "ab" copy text to end (probe "ab")] == ["a" copy text to end (probe "a") | "ab" copy text to end (probe "ab")] >> parse "ab" rules "a" == true >> parse "a texta" rules "a" == true >> text == " texta" >> parse "ab textab" rules "a" == true >>
|
|
|
|
|
Logged
|
|
|
|
|
CarlRead
|
The problem is it's finding an "a" in the "ab textab", so the first part of the rule is satisfied. Swap them around and it should work. ie... >> rules: ["ab" copy text to end (print [1 text ]) | "a" copy text to end (print [2 text])] == ["ab" copy text to end (print [1 text]) | "a" copy text to end (print [2 text])] >> parse "axyz" rules 2 xyz == true >> parse "abc" rules 1 c == true Hope that helps.
|
|
|
|
|
Logged
|
- Carl Read
|
|
|
parser
Guest
|
Thanks, it helps
|
|
|
|
|
Logged
|
|
|
|
Guest
Guest
|
Now this trick doesn't work in a special case when newline is involved : I can't get at the output
command1 command1 command2
but only command1 command1
--------------------------------------
list-commands: { command1
command1 < test1 >
command2 < test2 >
}
rules: [ [ copy command to "<" copy param to ">" (probe command) | copy command to newline (probe command) ] to end ]
parse list-commands rules
>> parse list-commands rules { command1
command1 } == true >>
|
|
|
|
|
Logged
|
|
|
|
parser
Guest
|
For the case above I really don't understand why it give "command1 <" instead of {command1 command1 command2}
rules: [
any [ [ some newline copy command to " " "<" copy param to ">" ">" some newline (probe command) ] | [ some newline copy Command to newline some newline (probe command) ] ] some newline to end ]
list-commands: { command1 < test1 >
command1
command2 < test2 >
}
parse/all list-commands rules
>> parse/all list-commands rules "command1 <" == false >>
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |