Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Source/SimpleParser/SimpleParser.Lexer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
interface

uses
SysUtils, Classes, Character,
SysUtils, Classes, Character,
{$IFDEF FPC}
Generics.Collections,
Generics.Collections,
{$ENDIF}
SimpleParser.Lexer.Types;

Expand Down Expand Up @@ -122,7 +122,7 @@ TmwBasePasLex = class(TObject)
FScopedEnums: Boolean;
FIncludeHandler: IIncludeHandler;
FOnComment: TCommentEvent;

function KeyHash: Integer;
function KeyComp(const aKey: string): Boolean;
function Func9: tptTokenKind;
Expand Down Expand Up @@ -1626,7 +1626,7 @@ procedure TmwBasePasLex.BraceOpenProc;
PtScopedEnumsDirect:
begin
UpdateScopedEnums;
end;
end;
PtUndefDirect:
begin
if FUseDefines and (FDefineStack = 0) then
Expand Down Expand Up @@ -1937,8 +1937,11 @@ procedure TmwBasePasLex.NumberProc;
'.':
if FBuffer.Buf[FBuffer.Run + 1] = '.' then
Break
else
else if CharInSet(FBuffer.Buf[FBuffer.Run + 1], ['0'..'9']) then
FTokenID := ptFloat
else
Break;

end;
Inc(FBuffer.Run);
end;
Expand Down Expand Up @@ -2181,7 +2184,7 @@ procedure TmwBasePasLex.RoundOpenProc;
PtScopedEnumsDirect:
begin
UpdateScopedEnums;
end;
end;
PtUndefDirect:
begin
if Assigned(FOnUnDefDirect) then
Expand Down Expand Up @@ -2462,7 +2465,7 @@ function TmwBasePasLex.GetDirectiveKind: TptTokenKind;
134:
if KeyComp('SCOPEDENUMS') then
Result := ptScopedEnumsDirect else
Result := ptCompDirect;
Result := ptCompDirect;
else Result := ptCompDirect;
end;
FTokenPos := TempPos;
Expand Down
33 changes: 21 additions & 12 deletions Source/SimpleParser/SimpleParser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
-----------------------------------------------------------------------------}
unit SimpleParser;

{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}

interface

Expand Down Expand Up @@ -268,7 +268,7 @@ TmwSimplePasPar = class(TObject)
procedure ClassMethodResolution; virtual;
procedure ClassProcedureHeading; virtual;
procedure ClassClass; virtual;
procedure ClassConstraint; virtual;
procedure ClassConstraint; virtual;
procedure ClassMethod; virtual;
procedure ClassProperty; virtual;
procedure ClassReferenceType; virtual;
Expand All @@ -285,7 +285,7 @@ TmwSimplePasPar = class(TObject)
procedure ConstantValue; virtual;
procedure ConstantValueTyped; virtual;
procedure ConstParameter; virtual;
procedure ConstructorConstraint; virtual;
procedure ConstructorConstraint; virtual;
procedure ConstructorHeading; virtual;
procedure ConstructorName; virtual;
procedure ConstSection; virtual;
Expand Down Expand Up @@ -434,7 +434,7 @@ TmwSimplePasPar = class(TObject)
procedure RealIdentifier; virtual;
procedure RealType; virtual;
procedure RecordConstant; virtual;
procedure RecordConstraint; virtual;
procedure RecordConstraint; virtual;
procedure RecordFieldConstant; virtual;
procedure RecordType; virtual;
procedure RecordVariant; virtual;
Expand Down Expand Up @@ -1840,7 +1840,7 @@ procedure TmwSimplePasPar.DirectiveBinding;
ptAbstract:
begin
NextToken;
end;
end;
ptVirtual:
begin
NextToken;
Expand Down Expand Up @@ -2024,7 +2024,7 @@ procedure TmwSimplePasPar.ParameterName;

procedure TmwSimplePasPar.FormalParameterType;
begin
if TokenID = ptArray then
if TokenID = ptArray then
StructuredType
else
TypeID;
Expand All @@ -2048,7 +2048,7 @@ procedure TmwSimplePasPar.FunctionMethodDeclaration;
else
begin
Expected(ptColon);
ReturnType;
ReturnType;
FunctionProcedureBlock;
end;
end;
Expand Down Expand Up @@ -2119,7 +2119,7 @@ procedure TmwSimplePasPar.FunctionProcedureBlock;
end;

if HasBlock then
begin
begin
case TokenID of
ptAsm:
begin
Expand Down Expand Up @@ -2542,7 +2542,7 @@ procedure TmwSimplePasPar.Statements;
while TokenID in [ptAddressOp, ptAsm, ptBegin, ptCase, ptDoubleAddressOp,
ptFor, ptGoTo, ptIdentifier, ptIf, ptInherited, ptInline, ptIntegerConst,
ptPointerSymbol, ptRaise, ptRoundOpen, ptRepeat, ptSemiColon, ptString,
ptTry, ptWhile, ptWith] do
ptStringConst, ptTry, ptWhile, ptWith] do
begin
Statement;
Semicolon;
Expand Down Expand Up @@ -2621,6 +2621,10 @@ procedure TmwSimplePasPar.Statement;
begin
LabeledStatement;
end;
ptPoint:
begin
Expression;
end
else
begin
SynError(InvalidLabeledStatement);
Expand All @@ -2640,6 +2644,11 @@ procedure TmwSimplePasPar.Statement;
begin
EmptyStatement;
end;
ptStringConst:
begin
FLexer.InitAhead;
Expression;
end;
ptTry:
begin
TryStatement;
Expand Down Expand Up @@ -3703,7 +3712,7 @@ procedure TmwSimplePasPar.ClassVisibility;
IsStrict := ExID = ptStrict;
if IsStrict then
ExpectedEx(ptStrict);

while ExID in [ptAutomated, ptPrivate, ptProtected, ptPublic, ptPublished] do
begin
Lexer.InitAhead;
Expand Down Expand Up @@ -4412,7 +4421,7 @@ procedure TmwSimplePasPar.ExplicitType;
end;

procedure TmwSimplePasPar.TypeKind;
begin
begin
case TokenID of
ptAsciiChar, ptFloat, ptIntegerConst, ptMinus, ptNil, ptPlus, ptStringConst, ptConst:
begin
Expand Down Expand Up @@ -4678,7 +4687,7 @@ procedure TmwSimplePasPar.ProcedureDeclarationSection;
else
begin
SynError(InvalidProcedureDeclarationSection);
end;
end;
end;
end;

Expand Down