Browse Source

* Fix parsing of mozilla ID

Michaël Van Canneyt 1 year ago
parent
commit
d7b8e1c351
1 changed files with 12 additions and 14 deletions
  1. 12 14
      packages/webidl/src/webidlparser.pp

+ 12 - 14
packages/webidl/src/webidlparser.pp

@@ -399,7 +399,7 @@ Const
   OtherTokens = [tkNumberInteger,tkNumberFloat,tkIdentifier,tkString, {tkOther, tkMinus,}tkNegInfinity,
   OtherTokens = [tkNumberInteger,tkNumberFloat,tkIdentifier,tkString, {tkOther, tkMinus,}tkNegInfinity,
                  tkDot,tkEllipsis,tkColon,tkSemicolon,tkLess,tkEqual,tkLarger,tkQuestionmark,tkStar,tkByteString,
                  tkDot,tkEllipsis,tkColon,tkSemicolon,tkLess,tkEqual,tkLarger,tkQuestionmark,tkStar,tkByteString,
                  tkDOMString,tkInfinity,tkNan,tkUSVString,tkAny,tkboolean,tkbyte,tkDouble,tkFalse,tkFloat,tkComma,
                  tkDOMString,tkInfinity,tkNan,tkUSVString,tkAny,tkboolean,tkbyte,tkDouble,tkFalse,tkFloat,tkComma,
-                 tkLong,tkNull,tkObject,tkOctet,tkOr,tkOptional,tkSequence,tkShort,tkTrue,tkUnsigned,tkVoid];
+                 tkLong,tkNull,tkObject,tkOctet,tkOr,tkOptional,tkUnrestricted, tkSequence,tkShort,tkTrue,tkUnsigned,tkVoid];
 
 
 Var
 Var
   tk : TIDLToken;
   tk : TIDLToken;
@@ -413,7 +413,7 @@ begin
     ValidTokens:=ValidTokens + [tkInherit,tkGetter];
     ValidTokens:=ValidTokens + [tkInherit,tkGetter];
   tk:=GetToken;
   tk:=GetToken;
   S:='';
   S:='';
-  While Not (tk=aTerminator) do
+  While Not (tk in [tkEof,aTerminator]) do
     begin
     begin
     WasSub:=True;
     WasSub:=True;
     Case tk of
     Case tk of
@@ -427,14 +427,12 @@ begin
         S:=S+AddSub(tkCurlyBraceClose);
         S:=S+AddSub(tkCurlyBraceClose);
       else
       else
         WasSub:=False;
         WasSub:=False;
-        // Check
-        While (tk in ValidTokens) do
-          begin
-          AddToCurrent(S,CurrentTokenString);
-          if tk=tkComma then
-            AddToList(S);
-          tk:=GetToken;
-          end;
+        // We don't do a check any more, too many possible cases
+        if tk<>tkComma then
+          AddToCurrent(S,CurrentTokenString)
+        else
+          AddToList(S);
+        tk:=GetToken;
       end;
       end;
     if WasSub then
     if WasSub then
       tk:=GetToken;
       tk:=GetToken;
@@ -554,7 +552,7 @@ Var
 begin
 begin
   CheckCurrentToken(tkBracketOpen);
   CheckCurrentToken(tkBracketOpen);
   GetToken;
   GetToken;
-  While (CurrentToken<>tkBracketClose) do
+  While not (CurrentToken in [tkEOF,tkBracketClose]) do
     begin
     begin
     A:=ParseArgument(aParent);
     A:=ParseArgument(aParent);
     ExpectTokens([tkEqual,tkComma,tkBracketClose]);
     ExpectTokens([tkEqual,tkComma,tkBracketClose]);
@@ -1032,7 +1030,7 @@ begin
       end;
       end;
     CheckCurrentToken(tkCurlyBraceOpen);
     CheckCurrentToken(tkCurlyBraceOpen);
     tk:=GetToken;
     tk:=GetToken;
-    While (tk<>tkCurlyBraceClose) do
+    While not (tk in [tkCurlyBraceClose,tkEof]) do
       begin
       begin
       SemicolonSeen:=False;
       SemicolonSeen:=False;
       Attrs:=nil;
       Attrs:=nil;
@@ -1219,7 +1217,7 @@ begin
 end;
 end;
 
 
 function TWebIDLParser.ParseDictionary(aParent : TIDLBaseObject; AllowInheritance : Boolean = True): TIDLDictionaryDefinition;
 function TWebIDLParser.ParseDictionary(aParent : TIDLBaseObject; AllowInheritance : Boolean = True): TIDLDictionaryDefinition;
-(* On entry, we're on dictionary, on eexit, we're on { *)
+(* On entry, we're on dictionary, on eexit, we're on } *)
 
 
 Var
 Var
   Name,ParentName : UTF8String;
   Name,ParentName : UTF8String;
@@ -1241,7 +1239,7 @@ begin
   Result:=TIDLDictionaryDefinition(AddDefinition(aParent,TIDLDictionaryDefinition,Name));
   Result:=TIDLDictionaryDefinition(AddDefinition(aParent,TIDLDictionaryDefinition,Name));
   Result.ParentName:=ParentName;
   Result.ParentName:=ParentName;
   GetToken;
   GetToken;
-  While (CurrentToken<>tkCurlyBraceClose) do
+  While not (CurrentToken in [tkCurlyBraceClose,tkEOF]) do
      begin
      begin
      ParseDictionaryMember(Result.Members);
      ParseDictionaryMember(Result.Members);
      CheckCurrentTokens([tkSemicolon,tkCurlyBraceClose]);
      CheckCurrentTokens([tkSemicolon,tkCurlyBraceClose]);