[llvm] [YAMLParser] Improve plain scalar spec compliance (PR #68946)

Scott Linder via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 15:52:28 PDT 2023


================
@@ -1848,13 +1869,15 @@ bool Scanner::fetchMoreTokens() {
   if (*Current == ',')
     return scanFlowEntry();
 
-  if (*Current == '-' && isBlankOrBreak(Current + 1))
+  if (*Current == '-' && (isBlankOrBreak(Current + 1) || Current + 1 == End))
     return scanBlockEntry();
 
-  if (*Current == '?' && (FlowLevel || isBlankOrBreak(Current + 1)))
+  if (*Current == '?' && (Current + 1 == End || isBlankOrBreak(Current + 1)))
     return scanKey();
 
-  if (*Current == ':' && (FlowLevel || isBlankOrBreak(Current + 1)))
+  if (*Current == ':' && ((FlowLevel && (IsAdjacentValueAllowed ||
----------------
slinder1 wrote:

Isn't checking `FlowLevel` here redundant assuming `IsAdjacentValueAllowed` is set correctly?

I'm also confused about the condition `!isPlainSafeNonBlank`. Shouldn't we always parse a (possibly empty) value following the `:` when an adjacent value is allowed?

I also think the order should make the "normal" case of a blank/break following the indicator come first; all together is the following still correct, or am I missing something?

```
if (*Current == ':' && (isBlankOrBreak(Current + 1) || IsAdjacentValueAllowed))
```

https://github.com/llvm/llvm-project/pull/68946


More information about the llvm-commits mailing list