kthompson/glob

Unable to parse "."

dazinator opened this issue · 3 comments

So I attempted:

var glob = new Glob("/some/dir/folder/foo.*");
var match = glob.IsMatch("/some/dir/folder/foo.txt");
var match = glob.IsMatch("/some/dir/folder/foo.csv");

Expecting the glob to match them both.. ?

However this exception was raised by the Scanner:-

Unable to scan for next token. Stuck on '.'

The ScanToken() method doesn't know what to do when it encounters a ".".

Is this a bug or m I doing something wrong?

For now I am just going to add in the ability to include "." when parsing an Identifier token - as currently that only includes alphanumeric characters.

Ok so I changed this:

        private static bool IsAlphaNumeric(char? c)
        {
            return c != null && char.IsLetterOrDigit(c.Value);
        }

To:

        private static bool IsNonSpecialCharacter(char? c)
        {
            return (c != null && char.IsLetterOrDigit(c.Value)) || c == '.';
        }

And that seems to work for the time being ;-)

This should be fixed now in master.

Thanks!