Repository: joshtemple/lkml

Issue:
Failure to parse sets with space-delimited leading hypens
lkml can't parse, this, which is valid lkml:

```lookml
fields: [- view.dimension_name]
```

The issue seems to be with the space between the hyphen and the field name.

Discussion:

Patch:
diff --git a/lkml/parser.py b/lkml/parser.py
index cbf25ca..3a69dbb 100644
--- a/lkml/parser.py
+++ b/lkml/parser.py
@@ -406,6 +406,13 @@ class Parser:
 
         if self.check(tokens.LiteralToken):
             token = self.consume()
+            # Handle special case where a hyphen can be preceded by whitspace
+            if token.value == "-" and self.consume_trivia():
+                if self.check(tokens.LiteralToken):
+                    token = self.consume()
+                    token.value = "-" + token.value
+                else:
+                    return None
             suffix = self.consume_trivia() if parse_suffix else ""
             if self.log_debug:
                 logger.debug("%sSuccessfully parsed value.", self.depth * DELIMITER)
diff --git a/setup.py b/setup.py
index 7b7726c..23e9bf8 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from pathlib import Path
 
 from setuptools import find_packages, setup
 
-__version__ = "1.3.3"
+__version__ = "1.3.4"
 
 here = Path(__file__).parent.resolve()
 


Test patch:
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 421b82d..bd63c89 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -703,6 +703,30 @@ def test_parse_list_with_only_comment():
     )
 
 
+def test_parse_list_with_space_delimited_hyphen():
+    stream = (
+        tokens.LiteralToken("fields", 1),
+        tokens.ValueToken(1),
+        tokens.WhitespaceToken(" ", 1),
+        tokens.ListStartToken(1),
+        tokens.WhitespaceToken(" ", 1),
+        tokens.LiteralToken("-", 1),
+        tokens.WhitespaceToken(" ", 1),
+        tokens.LiteralToken("view.dimension_name", 1),
+        tokens.ListEndToken(1),
+        tokens.StreamEndToken(1),
+    )
+    parser = lkml.parser.Parser(stream)
+    result = parser.parse_list()
+    assert result == ListNode(
+        type=SyntaxToken("fields", 1),
+        colon=Colon(line_number=1, suffix=" "),
+        left_bracket=LeftBracket(),
+        items=(SyntaxToken("-view.dimension_name", 1, prefix=" "),),
+        right_bracket=RightBracket(),
+    )
+
+
 def test_parse_block_with_no_expression():
     stream = (
         tokens.LiteralToken("dimension", 1),