mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-06 00:29:41 +00:00
Use "declarator expected" error messages when appropriate.
Previously, some of these cases would report "identifier expected."
This commit is contained in:
parent
99e268e3b9
commit
a864954353
26
Parser.pas
26
Parser.pas
@ -2750,15 +2750,15 @@ end; {DoStaticAssert}
|
|||||||
|
|
||||||
|
|
||||||
procedure DeclarationSpecifiers (var declSpecifiers: declSpecifiersRecord;
|
procedure DeclarationSpecifiers (var declSpecifiers: declSpecifiersRecord;
|
||||||
allowedTokens: tokenSet; expectedNext: tokenEnum);
|
allowedTokens: tokenSet; badNextTokenError: integer);
|
||||||
|
|
||||||
{ handle declaration specifiers or a specifier-qualifier list }
|
{ handle declaration specifiers or a specifier-qualifier list }
|
||||||
{ }
|
{ }
|
||||||
{ parameters: }
|
{ parameters: }
|
||||||
{ declSpecifiers - record to hold result type & specifiers}
|
{ declSpecifiers - record to hold result type & specifiers}
|
||||||
{ allowedTokens - specifiers/qualifiers that can be used }
|
{ allowedTokens - specifiers/qualifiers that can be used }
|
||||||
{ expectedNext - token usually expected after declaration }
|
{ badNextTokenError - error code for an unexpected token }
|
||||||
{ specifiers (used for error messages only) }
|
{ following the declaration specifiers }
|
||||||
{ }
|
{ }
|
||||||
{ outputs: }
|
{ outputs: }
|
||||||
{ isForwardDeclared - is the field list component }
|
{ isForwardDeclared - is the field list component }
|
||||||
@ -2866,7 +2866,7 @@ var
|
|||||||
DoStaticAssert;
|
DoStaticAssert;
|
||||||
goto 1;
|
goto 1;
|
||||||
end; {if}
|
end; {if}
|
||||||
DeclarationSpecifiers(fieldDeclSpecifiers, specifierQualifierListElement, ident);
|
DeclarationSpecifiers(fieldDeclSpecifiers, specifierQualifierListElement, 176);
|
||||||
repeat {declare the variables...}
|
repeat {declare the variables...}
|
||||||
if didFlexibleArray then
|
if didFlexibleArray then
|
||||||
Error(118);
|
Error(118);
|
||||||
@ -3091,7 +3091,7 @@ var
|
|||||||
myTypeSpec := boolPtr;
|
myTypeSpec := boolPtr;
|
||||||
end {else if}
|
end {else if}
|
||||||
else
|
else
|
||||||
UnexpectedTokenError(expectedNext);
|
Error(badNextTokenError);
|
||||||
end; {ResolveType}
|
end; {ResolveType}
|
||||||
|
|
||||||
|
|
||||||
@ -3112,7 +3112,7 @@ while token.kind in allowedTokens do begin
|
|||||||
myDeclarationModifiers := myDeclarationModifiers + [token.kind];
|
myDeclarationModifiers := myDeclarationModifiers + [token.kind];
|
||||||
if myStorageClass <> ident then begin
|
if myStorageClass <> ident then begin
|
||||||
if typeDone or (typeSpecifiers <> []) then
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
UnexpectedTokenError(expectedNext)
|
Error(badNextTokenError)
|
||||||
else
|
else
|
||||||
Error(26);
|
Error(26);
|
||||||
end; {if}
|
end; {if}
|
||||||
@ -3181,7 +3181,7 @@ while token.kind in allowedTokens do begin
|
|||||||
if token.kind = lparench then begin
|
if token.kind = lparench then begin
|
||||||
{_Atomic(typename) as type specifier}
|
{_Atomic(typename) as type specifier}
|
||||||
if typeDone or (typeSpecifiers <> []) then
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
UnexpectedTokenError(expectedNext);
|
Error(badNextTokenError);
|
||||||
NextToken;
|
NextToken;
|
||||||
myTypeSpec := TypeName;
|
myTypeSpec := TypeName;
|
||||||
Match(rparench, 12);
|
Match(rparench, 12);
|
||||||
@ -3193,7 +3193,7 @@ while token.kind in allowedTokens do begin
|
|||||||
unsignedsy,signedsy,intsy,longsy,charsy,shortsy,floatsy,doublesy,voidsy,
|
unsignedsy,signedsy,intsy,longsy,charsy,shortsy,floatsy,doublesy,voidsy,
|
||||||
compsy,extendedsy,_Boolsy: begin
|
compsy,extendedsy,_Boolsy: begin
|
||||||
if typeDone then
|
if typeDone then
|
||||||
UnexpectedTokenError(expectedNext)
|
Error(badNextTokenError)
|
||||||
else if token.kind in typeSpecifiers then begin
|
else if token.kind in typeSpecifiers then begin
|
||||||
if (token.kind = longsy) and
|
if (token.kind = longsy) and
|
||||||
((myTypeSpec = longPtr) or (myTypeSpec = uLongPtr)) then begin
|
((myTypeSpec = longPtr) or (myTypeSpec = uLongPtr)) then begin
|
||||||
@ -3201,7 +3201,7 @@ while token.kind in allowedTokens do begin
|
|||||||
ResolveType;
|
ResolveType;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
UnexpectedTokenError(expectedNext);
|
Error(badNextTokenError);
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
if restrictsy in myDeclarationModifiers then begin
|
if restrictsy in myDeclarationModifiers then begin
|
||||||
@ -3221,7 +3221,7 @@ while token.kind in allowedTokens do begin
|
|||||||
|
|
||||||
enumsy: begin {enum}
|
enumsy: begin {enum}
|
||||||
if typeDone or (typeSpecifiers <> []) then
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
UnexpectedTokenError(expectedNext)
|
Error(badNextTokenError)
|
||||||
else if restrictsy in myDeclarationModifiers then
|
else if restrictsy in myDeclarationModifiers then
|
||||||
Error(143);
|
Error(143);
|
||||||
NextToken; {skip the 'enum' token}
|
NextToken; {skip the 'enum' token}
|
||||||
@ -3313,7 +3313,7 @@ while token.kind in allowedTokens do begin
|
|||||||
structsy, {struct}
|
structsy, {struct}
|
||||||
unionsy: begin {union}
|
unionsy: begin {union}
|
||||||
if typeDone or (typeSpecifiers <> []) then
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
UnexpectedTokenError(expectedNext)
|
Error(badNextTokenError)
|
||||||
else if restrictsy in myDeclarationModifiers then
|
else if restrictsy in myDeclarationModifiers then
|
||||||
Error(143);
|
Error(143);
|
||||||
globalStruct := false; {we didn't make it global}
|
globalStruct := false; {we didn't make it global}
|
||||||
@ -3717,7 +3717,7 @@ lUseGlobalPool := useGlobalPool;
|
|||||||
{handle a TypeSpecifier/declarator}
|
{handle a TypeSpecifier/declarator}
|
||||||
typeFound := token.kind in declarationSpecifiersElement;
|
typeFound := token.kind in declarationSpecifiersElement;
|
||||||
declaredTagOrEnumConst := false;
|
declaredTagOrEnumConst := false;
|
||||||
DeclarationSpecifiers(declSpecifiers, declarationSpecifiersElement, ident);
|
DeclarationSpecifiers(declSpecifiers, declarationSpecifiersElement, 176);
|
||||||
isPascal := pascalsy in declSpecifiers.declarationModifiers;
|
isPascal := pascalsy in declSpecifiers.declarationModifiers;
|
||||||
isAsm := asmsy in declSpecifiers.declarationModifiers;
|
isAsm := asmsy in declSpecifiers.declarationModifiers;
|
||||||
isInline := inlinesy in declSpecifiers.declarationModifiers;
|
isInline := inlinesy in declSpecifiers.declarationModifiers;
|
||||||
@ -4273,7 +4273,7 @@ var
|
|||||||
|
|
||||||
begin {TypeName}
|
begin {TypeName}
|
||||||
{read and process the type specifier}
|
{read and process the type specifier}
|
||||||
DeclarationSpecifiers(declSpecifiers, specifierQualifierListElement, rparench);
|
DeclarationSpecifiers(declSpecifiers, specifierQualifierListElement, 12);
|
||||||
|
|
||||||
{_Alignas is not allowed in most uses of type names. }
|
{_Alignas is not allowed in most uses of type names. }
|
||||||
{TODO: _Alignas should be allowed in compound literals. }
|
{TODO: _Alignas should be allowed in compound literals. }
|
||||||
|
34
Scanner.pas
34
Scanner.pas
@ -119,13 +119,6 @@ procedure Error (err: integer);
|
|||||||
{ err - error number }
|
{ err - error number }
|
||||||
|
|
||||||
|
|
||||||
procedure UnexpectedTokenError (expectedToken: tokenEnum);
|
|
||||||
|
|
||||||
{ flag an error for an unexpected token }
|
|
||||||
{ }
|
|
||||||
{ expectedToken - what was expected }
|
|
||||||
|
|
||||||
|
|
||||||
procedure InitScanner (start, endPtr: ptr);
|
procedure InitScanner (start, endPtr: ptr);
|
||||||
|
|
||||||
{ initialize the scanner }
|
{ initialize the scanner }
|
||||||
@ -3551,33 +3544,6 @@ Error(err);
|
|||||||
end; {Error2}
|
end; {Error2}
|
||||||
|
|
||||||
|
|
||||||
procedure UnexpectedTokenError {expectedToken: tokenEnum};
|
|
||||||
|
|
||||||
{ flag an error for an unexpected token }
|
|
||||||
{ }
|
|
||||||
{ expectedToken - what was expected }
|
|
||||||
|
|
||||||
begin {UnexpectedTokenError}
|
|
||||||
case expectedToken of
|
|
||||||
ident: Error(9);
|
|
||||||
rparench: Error(12);
|
|
||||||
lparench: Error(13);
|
|
||||||
gtch: Error(15);
|
|
||||||
intconst: Error(18);
|
|
||||||
semicolonch: Error(22);
|
|
||||||
rbracech: Error(23);
|
|
||||||
rbrackch: Error(24);
|
|
||||||
lbracech: Error(27);
|
|
||||||
colonch: Error(29);
|
|
||||||
whilesy: Error(30);
|
|
||||||
stringconst: Error(83);
|
|
||||||
commach: Error(86);
|
|
||||||
dotch: Error(89);
|
|
||||||
otherwise: Error(140);
|
|
||||||
end; {case}
|
|
||||||
end; {UnexpectedTokenError}
|
|
||||||
|
|
||||||
|
|
||||||
procedure DoNumber {scanWork: boolean};
|
procedure DoNumber {scanWork: boolean};
|
||||||
|
|
||||||
{ The current character starts a number - scan it }
|
{ The current character starts a number - scan it }
|
||||||
|
Loading…
Reference in New Issue
Block a user