summaryrefslogtreecommitdiff
path: root/lib/spack/spack/spec.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r--lib/spack/spack/spec.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 5fc8b69f07..7feebdd4e2 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -81,6 +81,7 @@ import itertools
import operator
import os
import re
+import sys
import warnings
import ruamel.yaml as yaml
@@ -145,6 +146,7 @@ __all__ = [
'SpecDeprecatedError',
]
+is_windows = sys.platform == 'win32'
#: Valid pattern for an identifier in Spack
identifier_re = r'\w[\w-]*'
@@ -4887,7 +4889,10 @@ class SpecLexer(spack.parse.Lexer):
# Filenames match before identifiers, so no initial filename
# component is parsed as a spec (e.g., in subdir/spec.yaml/json)
- (r'[/\w.-]*/[/\w/-]+\.(yaml|json)[^\b]*',
+ # posixpath on Windows here because this string will be fed through
+ # shlex
+ (r'[/\w.-]*/[/\w/-]+\.(yaml|json)[^\b]*' if not is_windows\
+ else r'([A-Za-z]:)*?[/\w.-]*/[/\w/-]+\.(yaml|json)[^\b]*',
lambda scanner, v: self.token(FILE, v)),
# Hash match after filename. No valid filename can be a hash