Skip to content

Commit

Permalink
Fix Paren_Close
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien-Chouteau committed Oct 23, 2020
1 parent f5c0e75 commit 319ca7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions src/spdx.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/spdx.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down

0 comments on commit 319ca7b

Please sign in to comment.