I need to parse some strings which contain paths to directories. The problem is that the contains escaped whitespaces and other escaped symbols. For example:
"/dir_1/dir_2/dir_3/dir/another/dest_dir\ P\&G/"
Note that there is a whitespace before P\&G/
.
Here is my treetop grammar(alpha_digit_special contains whitespace in the beginning)
rule alpha_digit_special
[ a-zA-Z0-9.+&\\]
end
rule path_without_quotes
([/] alpha_digit_special*)+
end
rule quot_mark
["]
end
rule path_with_quotes
quot_mark path_without_quotes quot_mark
end
rule path
path_with_quotes / path_without_quotes
end
I get nil
after parsing this string. So how can i specify the rule so that the string may contain escaped whitespaces?