diff --git a/src/spdx.adb b/src/spdx.adb index 094c304..570de54 100644 --- a/src/spdx.adb +++ b/src/spdx.adb @@ -77,16 +77,15 @@ package body SPDX is return; end if; - if This.Tokens.Is_Empty - or else - This.Tokens.First_Element.Kind /= Paren_Close - then + if This.Tokens.Is_Empty then This.Error := Paren_Close_Expected; - This.Err_Loc := This.Tokens.First_Element.Loc; + This.Err_Loc := (This.Str'Last, This.Str'Last); return; end if; - if This.Tokens.Is_Empty then + if This.Tokens.First_Element.Kind /= Paren_Close then + This.Error := Paren_Close_Expected; + This.Err_Loc := This.Tokens.First_Element.Loc; return; end if; diff --git a/src/spdx.ads b/src/spdx.ads index ccc9799..a0c9912 100644 --- a/src/spdx.ads +++ b/src/spdx.ads @@ -18,15 +18,15 @@ package SPDX is with Pre => Valid (This); -- Return the string representation of a valid SPDX expression - subtype Id_String is String - with Dynamic_Predicate => (for all C of Id_String => C in Id_Characters); - private subtype Id_Characters is Character with Dynamic_Predicate => Id_Characters in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '.'; + subtype Id_String is String + with Dynamic_Predicate => (for all C of Id_String => C in Id_Characters); + subtype Whitespace_Characters is Character with Dynamic_Predicate => Whitespace_Characters in ' ' | ASCII.HT; diff --git a/tests/src/main.adb b/tests/src/main.adb index 136c4cb..be2ae1a 100644 --- a/tests/src/main.adb +++ b/tests/src/main.adb @@ -80,7 +80,7 @@ begin Test ("MIT OR", "Empty license expression at (6:6)"); Test ("MIT MIT", "Unexpected token at (5:7)"); - Test ("(MIT", "Missing closing parentheses ')' at (2:4)"); + Test ("(MIT", "Missing closing parentheses ')' at (4:4)"); Test ("MIT)", "Unexpected token at (4:4)"); Test ("(MIT AND (MIT OR MIT)", "Missing closing parentheses ')' at (21:21)"); Test ("MIT AND (MIT OR MIT))", "Unexpected token at (21:21)");