mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 23:39:24 +02:00
codetools: added compiler mode pas2js
git-svn-id: trunk@54284 -
This commit is contained in:
parent
9a860927f8
commit
9a663cc51d
@ -157,6 +157,7 @@ var
|
|||||||
WordIsPredefinedDelphiIdentifier,
|
WordIsPredefinedDelphiIdentifier,
|
||||||
UnexpectedKeyWordInBeginBlock,
|
UnexpectedKeyWordInBeginBlock,
|
||||||
UnexpectedKeyWordInAsmBlock,
|
UnexpectedKeyWordInAsmBlock,
|
||||||
|
UnexpectedKeyWordInAsmPas2JSBlock,
|
||||||
UnexpectedKeyWordInBrackets
|
UnexpectedKeyWordInBrackets
|
||||||
: TKeyWordFunctionList;
|
: TKeyWordFunctionList;
|
||||||
UpChars: array[char] of char;
|
UpChars: array[char] of char;
|
||||||
@ -1419,6 +1420,16 @@ begin
|
|||||||
Add('VAR',{$ifdef FPC}@{$endif}AllwaysTrue);
|
Add('VAR',{$ifdef FPC}@{$endif}AllwaysTrue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
UnexpectedKeyWordInAsmPas2JSBlock:=TKeyWordFunctionList.Create('UnexpectedKeyWordInAsmPas2JSBlock');
|
||||||
|
KeyWordLists.Add(UnexpectedKeyWordInAsmPas2JSBlock);
|
||||||
|
with UnexpectedKeyWordInAsmBlock do begin
|
||||||
|
Add('ASSEMBLER',{$ifdef FPC}@{$endif}AllwaysTrue);
|
||||||
|
Add('BEGIN',{$ifdef FPC}@{$endif}AllwaysTrue);
|
||||||
|
Add('FINALIZATION',{$ifdef FPC}@{$endif}AllwaysTrue);
|
||||||
|
Add('INITIALIZATION',{$ifdef FPC}@{$endif}AllwaysTrue);
|
||||||
|
Add('PROCEDURE',{$ifdef FPC}@{$endif}AllwaysTrue);
|
||||||
|
end;
|
||||||
|
|
||||||
UnexpectedKeyWordInBrackets:=TKeyWordFunctionList.Create('UnexpectedKeyWordInBrackets');
|
UnexpectedKeyWordInBrackets:=TKeyWordFunctionList.Create('UnexpectedKeyWordInBrackets');
|
||||||
KeyWordLists.Add(UnexpectedKeyWordInBrackets);
|
KeyWordLists.Add(UnexpectedKeyWordInBrackets);
|
||||||
with UnexpectedKeyWordInBrackets do begin
|
with UnexpectedKeyWordInBrackets do begin
|
||||||
|
@ -157,7 +157,9 @@ type
|
|||||||
cmTP,
|
cmTP,
|
||||||
cmOBJFPC,
|
cmOBJFPC,
|
||||||
cmMacPas,
|
cmMacPas,
|
||||||
cmISO);
|
cmISO,
|
||||||
|
cmPas2Js
|
||||||
|
);
|
||||||
{ TCompilerModeSwitch - see fpc/compiler/globtype.pas tmodeswitch }
|
{ TCompilerModeSwitch - see fpc/compiler/globtype.pas tmodeswitch }
|
||||||
TCompilerModeSwitch = (
|
TCompilerModeSwitch = (
|
||||||
cmsAdd_pointer, { ? }
|
cmsAdd_pointer, { ? }
|
||||||
@ -228,7 +230,11 @@ const
|
|||||||
cmsISOLike_unary_minus,cmsDefault_inline],
|
cmsISOLike_unary_minus,cmsDefault_inline],
|
||||||
// cmISO
|
// cmISO
|
||||||
[cmsTp_procvar,cmsDuplicate_names,cmsNestedProcVars,cmsNonLocalGoto,
|
[cmsTp_procvar,cmsDuplicate_names,cmsNestedProcVars,cmsNonLocalGoto,
|
||||||
cmsISOLike_unary_minus]
|
cmsISOLike_unary_minus],
|
||||||
|
// cmPas2Js
|
||||||
|
[cmsNested_comment,cmsRepeat_forward,
|
||||||
|
cmsInitfinal,cmsHintdirective,cmsProperty,cmsDefault_inline,
|
||||||
|
cmsResult]
|
||||||
);
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -753,8 +759,16 @@ type
|
|||||||
const
|
const
|
||||||
// upper case
|
// upper case
|
||||||
CompilerModeNames: array[TCompilerMode] of shortstring=(
|
CompilerModeNames: array[TCompilerMode] of shortstring=(
|
||||||
'FPC', 'DELPHI', 'DELPHIUNICODE', 'GPC', 'TP', 'OBJFPC', 'MACPAS', 'ISO'
|
'FPC',
|
||||||
);
|
'DELPHI',
|
||||||
|
'DELPHIUNICODE',
|
||||||
|
'GPC',
|
||||||
|
'TP',
|
||||||
|
'OBJFPC',
|
||||||
|
'MACPAS',
|
||||||
|
'ISO',
|
||||||
|
'PAS2JS'
|
||||||
|
);
|
||||||
|
|
||||||
// upper case (see fpc/compiler/globtype.pas modeswitchstr )
|
// upper case (see fpc/compiler/globtype.pas modeswitchstr )
|
||||||
CompilerModeSwitchNames: array[TCompilerModeSwitch] of shortstring=(
|
CompilerModeSwitchNames: array[TCompilerModeSwitch] of shortstring=(
|
||||||
@ -3405,7 +3419,7 @@ begin
|
|||||||
FDirectives[FDirectivesCount-1].Kind:=lsdkMode;
|
FDirectives[FDirectivesCount-1].Kind:=lsdkMode;
|
||||||
ReadSpace;
|
ReadSpace;
|
||||||
ValStart:=SrcPos;
|
ValStart:=SrcPos;
|
||||||
while (SrcPos<=SrcLen) and (IsWordChar[Src[SrcPos]]) do
|
while (SrcPos<=SrcLen) and (IsIdentChar[Src[SrcPos]]) do
|
||||||
inc(SrcPos);
|
inc(SrcPos);
|
||||||
// undefine all mode macros
|
// undefine all mode macros
|
||||||
for AMode:=Low(TCompilerMode) to High(TCompilerMode) do
|
for AMode:=Low(TCompilerMode) to High(TCompilerMode) do
|
||||||
|
@ -2835,7 +2835,6 @@ begin
|
|||||||
BlockStartPos:=CurPos.StartPos;
|
BlockStartPos:=CurPos.StartPos;
|
||||||
repeat
|
repeat
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
//debugln(['TPascalParserTool.ReadTilBlockEnd next=',GetAtom]);
|
|
||||||
if (CurPos.StartPos>SrcLen) then
|
if (CurPos.StartPos>SrcLen) then
|
||||||
SaveRaiseExceptionWithBlockStartHint(ctsUnexpectedEndOfSource);
|
SaveRaiseExceptionWithBlockStartHint(ctsUnexpectedEndOfSource);
|
||||||
|
|
||||||
@ -2855,6 +2854,16 @@ begin
|
|||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
end else if BlockType=ebtAsm then begin
|
||||||
|
if (Src[CurPos.StartPos-1]='@') then begin
|
||||||
|
// allow anything behind @
|
||||||
|
end else if (CurPos.Flag=cafWord) then begin
|
||||||
|
if Scanner.CompilerMode=cmPas2Js then begin
|
||||||
|
if UnexpectedKeyWordInAsmPas2JSBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
||||||
|
SaveRaiseUnexpectedKeyWordInBeginEndBlock;
|
||||||
|
end else if UnexpectedKeyWordInAsmBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
||||||
|
SaveRaiseUnexpectedKeyWordInBeginEndBlock;
|
||||||
|
end;
|
||||||
end else if CurPos.Flag=cafSemicolon then begin
|
end else if CurPos.Flag=cafSemicolon then begin
|
||||||
// ;
|
// ;
|
||||||
if BlockType=ebtIf then begin
|
if BlockType=ebtIf then begin
|
||||||
@ -2863,13 +2872,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else if CurPos.Flag<>cafWord then begin
|
end else if CurPos.Flag<>cafWord then begin
|
||||||
continue;
|
continue;
|
||||||
end else if (BlockType=ebtAsm) and (Src[CurPos.StartPos-1]='@') then begin
|
|
||||||
// allow anything behind @
|
|
||||||
end else if BlockStatementStartKeyWordFuncList.DoIdentifier(@Src[CurPos.StartPos])
|
end else if BlockStatementStartKeyWordFuncList.DoIdentifier(@Src[CurPos.StartPos])
|
||||||
then begin
|
then begin
|
||||||
if BlockType=ebtAsm then begin
|
if (BlockType<>ebtRecord) then begin
|
||||||
SaveRaiseUnexpectedKeyWordInAsmBlock;
|
|
||||||
end else if (BlockType<>ebtRecord) then begin
|
|
||||||
ReadTilBlockEnd(false,CreateNodes);
|
ReadTilBlockEnd(false,CreateNodes);
|
||||||
if (BlockType=ebtIf) and (CurPos.Flag in [cafSemicolon]) then
|
if (BlockType=ebtIf) and (CurPos.Flag in [cafSemicolon]) then
|
||||||
break;
|
break;
|
||||||
@ -2918,15 +2923,9 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
// check for unexpected keywords
|
// check for unexpected keywords
|
||||||
case BlockType of
|
case BlockType of
|
||||||
|
|
||||||
ebtBegin,ebtTry,ebtIf,ebtCase,ebtRepeat:
|
ebtBegin,ebtTry,ebtIf,ebtCase,ebtRepeat:
|
||||||
if UnexpectedKeyWordInBeginBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
if UnexpectedKeyWordInBeginBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
||||||
SaveRaiseUnexpectedKeyWordInBeginEndBlock;
|
SaveRaiseUnexpectedKeyWordInBeginEndBlock;
|
||||||
|
|
||||||
ebtAsm:
|
|
||||||
if UnexpectedKeyWordInAsmBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
|
||||||
SaveRaiseUnexpectedKeyWordInBeginEndBlock;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
|
@ -34,12 +34,13 @@ implementation
|
|||||||
const
|
const
|
||||||
// CompilerMode names to be shown after -M...
|
// CompilerMode names to be shown after -M...
|
||||||
CompilerModesPretty: array[TCompilerMode] of shortstring = (
|
CompilerModesPretty: array[TCompilerMode] of shortstring = (
|
||||||
'fpc', 'Delphi', 'DelphiUnicode', 'gpc', 'tp', 'ObjFPC', 'MacPas', 'iso'
|
'fpc', 'Delphi', 'DelphiUnicode', 'gpc', 'tp', 'ObjFPC', 'MacPas', 'iso', 'pas2js'
|
||||||
);
|
);
|
||||||
// CompilerMode descriptions.
|
// CompilerMode descriptions.
|
||||||
CompilerModesDescr: array[TCompilerMode] of shortstring = (
|
CompilerModesDescr: array[TCompilerMode] of shortstring = (
|
||||||
'Free Pascal', 'Delphi', 'Delphi Unicode', 'GNU Pascal', 'Turbo Pascal',
|
'Free Pascal', 'Delphi', 'Delphi Unicode', 'GNU Pascal', 'Turbo Pascal',
|
||||||
'Object Pascal', 'Mac Pascal', 'ISO/IEC 7185 Pascal'
|
'Object Pascal', 'Mac Pascal', 'ISO/IEC 7185 Pascal',
|
||||||
|
'Pas2JS - Pascal to JavaScript transpiler'
|
||||||
);
|
);
|
||||||
|
|
||||||
function SyntaxModeToCaption(const ModeStr: string): string;
|
function SyntaxModeToCaption(const ModeStr: string): string;
|
||||||
|
Loading…
Reference in New Issue
Block a user