1403 lines
65 KiB
ObjectPascal
1403 lines
65 KiB
ObjectPascal
unit dpglib.types;
|
|
|
|
interface
|
|
uses
|
|
System.Classes,
|
|
System.Contnrs,
|
|
Generics.Collections,
|
|
System.SysUtils,
|
|
dpgrtl.types,
|
|
dpgrtl.token;
|
|
|
|
|
|
const
|
|
NONDETERMINISTIC = MaxInt;
|
|
LOOKAHEAD_DEPTH_INIT = -1;
|
|
|
|
type
|
|
IAlternative = interface;
|
|
IRuleBlock = interface;
|
|
IRuleRefElem = interface;
|
|
IExceptionSpec = interface;
|
|
ITool = interface;
|
|
ILookahead = interface;
|
|
|
|
IGrammar = interface;
|
|
ILexerGrammar = interface;
|
|
ICodeGenerator = interface;
|
|
|
|
TLookaheadArray = array of ILookahead;
|
|
EdpgNoViable = class( Exception) end;
|
|
|
|
TTokenIdMap = TObjectDictionary<AnsiString,integer>;
|
|
|
|
|
|
// =========================================================================
|
|
// IDelphiCharFormatter
|
|
// =========================================================================
|
|
ICharFormatter = interface
|
|
['{F8B49B48-29B9-4C5A-A9A1-7600C683F44D}']
|
|
|
|
function EscapeChar( pChar : integer;
|
|
pForCharLiteral : boolean) : AnsiString;
|
|
function EscapeString( pString : AnsiString) : AnsiString;
|
|
function LiteralChar( pChar : integer) : AnsiString;
|
|
function LiteralString( pString : AnsiString) : AnsiString;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IGrammarSymbol
|
|
// =========================================================================
|
|
IGrammarSymbol = interface
|
|
['{C78B6BF5-4E55-4E7D-8CAB-11AAF3DE1CBD}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetID: AnsiString;
|
|
procedure SetID( pID: AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property ID: AnsiString read GetID write SetID;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITokenSymbol
|
|
// =========================================================================
|
|
ITokenSymbol = interface( IGrammarSymbol)
|
|
['{68D34FAC-810F-460D-ACB7-AB52F4A5BFC8}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetTokenType : integer;
|
|
function GetParaphrase : AnsiString;
|
|
function GetASTNodeType : AnsiString;
|
|
|
|
procedure SetTokenType( pTokenType : integer);
|
|
procedure SetParaphrase( pParaphrase : AnsiString);
|
|
procedure SetASTNodeType( pASTNodeType : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
function Clone : ITokenSymbol;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property TokenType : integer read GetTokenType write SetTokenType;
|
|
property Paraphrase : AnsiString read GetParaphrase write SetParaphrase;
|
|
property ASTNodeType : AnsiString read GetASTNodeType write SetASTNodeType;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IStringSymbol
|
|
// =========================================================================
|
|
IStringSymbol = interface( ITokenSymbol)
|
|
['{8C7FDC02-1C10-4178-880A-0CC2BF04A658}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetLabel: AnsiString;
|
|
procedure SetLabel( pLabel: AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Lbl : AnsiString read GetLabel write SetLabel;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IRuleSymbol
|
|
// =========================================================================
|
|
IRuleSymbol = interface( IGrammarSymbol)
|
|
['{B9E4397C-8245-4F8E-9EA3-CEAA3ABA7C9C}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetBlock : IRuleBlock;
|
|
function GetDefined : boolean;
|
|
function GetReferences : TInterfaceList;
|
|
function GetAccess : AnsiString;
|
|
function GetComment : AnsiString;
|
|
function GetReference(i: integer) : IRuleRefElem;
|
|
|
|
procedure SetBlock( pBlock : IRuleBlock);
|
|
procedure SetDefined( pDefined : boolean);
|
|
procedure SetAccess( pAccess : AnsiString);
|
|
procedure SetComment( pComment : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure AddReference( pReference : IRuleRefElem);
|
|
function ReferenceCount: integer;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Block : IRuleBlock read GetBlock write SetBlock;
|
|
property Defined : boolean read GetDefined write SetDefined;
|
|
property Access : AnsiString read GetAccess write SetAccess;
|
|
property Comment : AnsiString read GetComment write SetComment;
|
|
property References : TInterfaceList read GetReferences;
|
|
|
|
// ------------------------------------------------------------
|
|
// Property arrays
|
|
// ------------------------------------------------------------
|
|
property Reference[i: integer]: IRuleRefElem read GetReference;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITokenManager
|
|
// =========================================================================
|
|
ITokenManager = interface
|
|
['{44F4CE9E-6465-4F37-B64C-91A96C6FCFB6}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetName : AnsiString;
|
|
function GetReadOnly : boolean;
|
|
function GetMaxTokenType : byte;
|
|
function GetNextTokenType : byte;
|
|
function GetVocabulary : TTokenIdMap;
|
|
|
|
function GetTokenStringAt( i : integer) : AnsiString;
|
|
function GetTokenSymbolByType( t : integer) : ITokenSymbol;
|
|
function GetTokenSymbolAt( i : integer) : ITokenSymbol;
|
|
function GetTokenSymbol( pName : AnsiString) : ITokenSymbol;
|
|
function GetTokenDefined( pName : AnsiString) : boolean;
|
|
|
|
procedure SetName( Name : AnsiString);
|
|
procedure SetReadOnly( ReadOnly : boolean);
|
|
procedure SetMaxTokenType( TokenType : byte);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
function Clone : ITokenManager;
|
|
|
|
function TokenSymbolKeys : TStringList;
|
|
function TokenSymbolElems : TInterfaceList;
|
|
|
|
procedure MapToTokenSymbol( pName : AnsiString; pTS: ITokenSymbol);
|
|
procedure Define( pTS: ITokenSymbol);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property ReadOnly : boolean read GetReadOnly write SetReadOnly;
|
|
property Name : AnsiString read GetName write SetName;
|
|
property MaxTokenType : byte read GetMaxTokenType write SetMaxTokenType;
|
|
property NextTokenType : byte read GetNextTokenType;
|
|
property Vocabulary : TTokenIdMap read GetVocabulary;
|
|
|
|
// ------------------------------------------------------------
|
|
// Property arrays
|
|
// ------------------------------------------------------------
|
|
property TokenStringAt [i: integer] : AnsiString read GetTokenStringAt;
|
|
property TokenSymbolAt [i: integer] : ITokenSymbol read GetTokenSymbolAt;
|
|
property TokenSymbol [s: AnsiString] : ITokenSymbol read GetTokenSymbol;
|
|
property TokenSymbolByType [i: integer] : ITokenSymbol read GetTokenSymbolByType;
|
|
property TokenDefined [s: AnsiString] : boolean read GetTokenDefined;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ILookahead
|
|
// =========================================================================
|
|
ILookahead = interface
|
|
['{CCC4893F-321A-400A-BFA2-4945ECE26985}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetLaSet : TByteSet;
|
|
function GetEpsilon : TByteSet;
|
|
function GetHasEpsilon : boolean;
|
|
function GetCycle : AnsiString;
|
|
|
|
procedure SetLaSet( LaSet : TByteSet);
|
|
procedure SetEpsilon( Epsilon : TByteSet);
|
|
procedure SetHasEpsilon( HasEpsilon : boolean);
|
|
procedure SetCycle( Cycle : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
function Intersection( LA : ILookahead) : ILookahead;
|
|
|
|
procedure CombineWith( LA : ILookahead); overload;
|
|
procedure CombineWith( LA : TByteSet); overload;
|
|
|
|
function IsNil: boolean;
|
|
function Clone: ILookahead;
|
|
function AsString( TM: ITokenManager=nil) : AnsiString;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property LaSet : TByteSet read GetLaSet write SetLaSet;
|
|
property Epsilon : TByteSet read GetEpsilon write SetEpsilon;
|
|
property HasEpsilon : boolean read GetHasEpsilon write SetHasEpsilon;
|
|
property Cycle : AnsiString read GetCycle write SetCycle;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IGrammarElem
|
|
// =========================================================================
|
|
IGrammarElem = interface
|
|
['{610659C4-9CA1-4E5F-B9BF-EFAB36E193B6}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetLine : integer;
|
|
function GetColumn : integer;
|
|
|
|
procedure SetLine( pLine : integer);
|
|
procedure SetColumn( pColumn : integer);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure Generate;
|
|
function Look( pK: integer): ILookahead;
|
|
function AsString : AnsiString;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Line : integer read GetLine write SetLine;
|
|
property Column : integer read GetColumn write SetColumn;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IAlternativeElem
|
|
// =========================================================================
|
|
IAlternativeElem = interface( IGrammarElem)
|
|
['{A4223F57-F869-4BBA-951B-71CC7A3B4423}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetAutoGenType : integer;
|
|
function GetLabel : AnsiString;
|
|
function GetEnclosingRule : AnsiString;
|
|
function GetNext : IAlternativeElem;
|
|
|
|
procedure SetLabel( Lbl : AnsiString);
|
|
procedure SetEnclosingRule( Rule : AnsiString);
|
|
procedure SetNext( Next : IAlternativeElem);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property AutoGenType : integer read GetAutoGenType;
|
|
|
|
property Lbl : AnsiString read GetLabel
|
|
write SetLabel;
|
|
|
|
property Next : IAlternativeElem read GetNext
|
|
write SetNext;
|
|
|
|
property EnclosingRule: AnsiString read GetEnclosingRule
|
|
write SetEnclosingRule;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IAlternativeBlock
|
|
// =========================================================================
|
|
IAlternativeBlock = interface( IAlternativeElem)
|
|
['{64EB220E-B7AA-407C-8AB9-0AFD7631705C}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetID : integer;
|
|
function GetInitAction : AnsiString;
|
|
function GetAutoGen : boolean;
|
|
function GetNot : boolean;
|
|
function GetHasASynPred : boolean;
|
|
function GetHasAnAction : boolean;
|
|
function GetWarnFollowAmbig : boolean;
|
|
function GetGenAmbigWarnings : boolean;
|
|
function GetGreedy : boolean;
|
|
function GetGreedySet : boolean;
|
|
function GetAnalyzisAlt : integer;
|
|
function GetAltI : integer;
|
|
function GetAltJ : integer;
|
|
|
|
function GetAlternatives : TInterfaceList;
|
|
function GetAlternative( i: integer) : IAlternative;
|
|
|
|
procedure SetInitAction( pAction : AnsiString);
|
|
procedure SetAutoGen( pAutoGen : boolean);
|
|
procedure SetNot( pNot : boolean);
|
|
procedure SetHasASynPred( pSynPred : boolean);
|
|
procedure SetHasAnAction( pAction : boolean);
|
|
procedure SetWarnFollowAmbig( pWarn : boolean);
|
|
procedure SetGenAmbigWarnings(pGen : boolean);
|
|
procedure SetGreedy( pGreedy : boolean);
|
|
procedure SetGreedySet( pGreedySet : boolean);
|
|
procedure SetAnalyzisAlt( pAlt : integer);
|
|
procedure SetAltI( pAltI : integer);
|
|
procedure SetAltJ( pAltJ : integer);
|
|
|
|
procedure SetAlternatives( pAlts : TInterfaceList);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure AddAlternative( pAlt: IAlternative);
|
|
procedure SetOption( pKey: IToken; pValue: IToken);
|
|
procedure PrepareForAnalysis;
|
|
procedure RemoveTracking( pGrammar: IGrammar);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property InitAction : AnsiString read GetInitAction
|
|
write SetInitAction;
|
|
property AutoGen : boolean read GetAutoGen
|
|
write SetAutoGen;
|
|
property Alternatives : TInterfaceList read GetAlternatives
|
|
write SetAlternatives;
|
|
property IsNot : boolean read GetNot
|
|
write SetNot;
|
|
property HasASynPred : boolean read GetHasASynPred
|
|
write SetHasASynPred;
|
|
property HasAnAction : boolean read GetHasAnAction
|
|
write SetHasAnAction;
|
|
property WarnFollowAmbig: boolean read GetWarnFollowAmbig
|
|
write SetWarnFollowAmbig;
|
|
property GenAmbigWarnings:boolean read GetGenAmbigWarnings
|
|
write SetGenAmbigWarnings;
|
|
property Greedy : boolean read GetGreedy
|
|
write SetGreedy;
|
|
property GreedySet : boolean read GetGreedySet
|
|
write SetGreedySet;
|
|
property AnalyzisAlt : integer read GetAnalyzisAlt
|
|
write SetAnalyzisAlt;
|
|
property AltI : integer read GetAltI
|
|
write SetAltI;
|
|
property AltJ : integer read GetAltJ
|
|
write SetAltJ;
|
|
property ID : integer read GetID;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties arrays
|
|
// ------------------------------------------------------------
|
|
property Alternative[ i: integer]: IAlternative read GetAlternative;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IActionElem
|
|
// =========================================================================
|
|
IActionElem = interface( IAlternativeElem)
|
|
['{64BA1E8B-4A55-4B30-9B3E-BC1A67B56FC0}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetActionText : AnsiString;
|
|
function GetSemPred : boolean;
|
|
|
|
procedure SetSempred( pSemPred: boolean);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property ActionText : AnsiString read GetActionText;
|
|
property IsSemPred : boolean read GetSemPred
|
|
write SetSempred;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IBlockEndElem
|
|
// =========================================================================
|
|
IBlockEndElem = interface( IAlternativeElem)
|
|
['{0604D7BD-BB3B-4D55-AC2A-4B94A38411F5}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetBlock: IAlternativeBlock;
|
|
function GetLock( i: integer): boolean;
|
|
|
|
procedure SetBlock( pBlock: IAlternativeBlock);
|
|
procedure SetLock( i: integer; pLock: boolean);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Block : IAlternativeBlock read GetBlock write SetBlock;
|
|
property Lock[i: integer] : boolean read GetLock write SetLock;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IRuleEndElem
|
|
// =========================================================================
|
|
IRuleEndElem = interface( IBlockEndElem)
|
|
['{75E2BBD5-DD35-4213-9754-E918A2FE019D}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetnoFOLLOW: boolean;
|
|
function GetCache(i: integer): ILookahead;
|
|
|
|
procedure SetnoFOLLOW( pnoFOLLOW: boolean);
|
|
procedure SetCache(i:integer; pCache : ILookahead);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property noFOLLOW: boolean read GetnoFOLLOW write SetnoFOLLOW;
|
|
property Cache[i:integer]: ILookahead read GetCache write SetCache;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IRuleRefElem
|
|
// =========================================================================
|
|
IRuleRefElem = interface( IAlternativeElem)
|
|
['{442F7CB0-E5B6-49A8-9323-3240F6D433DA}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetTargetRule : AnsiString;
|
|
function GetIdAssign : AnsiString;
|
|
function GetArgs : AnsiString;
|
|
|
|
procedure SetTargetRule( pTargetRule : AnsiString);
|
|
procedure SetIdAssign( pIdAssign : AnsiString);
|
|
procedure SetArgs( pArgs : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property TargetRule : AnsiString read GetTargetRule write SetTargetRule;
|
|
property IdAssign : AnsiString read GetIdAssign write SetIdAssign;
|
|
property Args : AnsiString read GetArgs write SetArgs;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ICharRangeElem
|
|
// =========================================================================
|
|
ICharRangeElem = interface( IAlternativeElem)
|
|
['{B9EF3E2A-3605-4F84-899F-6205BA8AC3CE}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetBeginChar : ansichar;
|
|
function GetEndChar : ansichar;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property BeginChar : ansichar read GetBeginChar;
|
|
property EndChar : ansichar read GetEndChar;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITokenRangeElem
|
|
// =========================================================================
|
|
ITokenRangeElem = interface( IAlternativeElem)
|
|
['{E13E3468-4A4E-4EE1-B904-6A350659FC6D}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetBeginToken : integer;
|
|
function GetEndToken : integer;
|
|
function GetBeginText : AnsiString;
|
|
function GetEndText : AnsiString;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property BeginToken : integer read GetBeginToken;
|
|
property EndToken : integer read GetEndToken;
|
|
property BeginText : AnsiString read GetBeginText;
|
|
property EndText : AnsiString read GetEndText;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IGrammarAtom
|
|
// =========================================================================
|
|
IGrammarAtom = interface( IAlternativeElem)
|
|
['{6C0D8223-1397-445C-8A29-B4342646AE9C}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetAtomText : AnsiString;
|
|
function GetASTNodeType: AnsiString;
|
|
function GetTokenType : integer;
|
|
function GetIsNot : boolean;
|
|
|
|
procedure SetASTNodeType( pASTNodeType : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure SetOption( pKey: IToken; pValue: IToken);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property AtomText : AnsiString read GetAtomText;
|
|
property TokenType : integer read GetTokenType;
|
|
property IsNot : boolean read GetIsNot;
|
|
property ASTNodeType : AnsiString read GetASTNodeType
|
|
write SetASTNodeType;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ICharLiteralElem
|
|
// =========================================================================
|
|
ICharLiteralElem = interface( IGrammarAtom)
|
|
['{48DAC974-AAAB-4414-B082-975E92764766}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IStringLiteralElem
|
|
// =========================================================================
|
|
IStringLiteralElem = interface( IGrammarAtom)
|
|
['{BBB9C32B-6C7A-4C5F-A9A0-68144DE0D972}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetProcessedAtomText: AnsiString;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property ProcessedAtomText: AnsiString read GetProcessedAtomText;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITokenRefElem
|
|
// =========================================================================
|
|
ITokenRefElem = interface( IGrammarAtom)
|
|
['{A1C07916-8D97-4303-A6BC-0F0DA89FA978}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IWildcardElem
|
|
// =========================================================================
|
|
IWildcardElem = interface( IGrammarAtom)
|
|
['{BF7795F2-3B59-4FAF-9B49-E69EBF612D5B}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IRuleBlock
|
|
// =========================================================================
|
|
IRuleBlock = interface( IAlternativeBlock)
|
|
['{39336114-1512-4BD2-872B-C916755331AB}']
|
|
|
|
function GetRuleName : AnsiString;
|
|
function GetArguments : AnsiString;
|
|
function GetReturnAction : AnsiString;
|
|
function GetLocals : AnsiString;
|
|
function GetEndNode : IRuleEndElem;
|
|
|
|
function GetTestLiterals : boolean;
|
|
function GetLabeledElems : TInterfaceList;
|
|
|
|
function GetIgnoreRule : AnsiString;
|
|
function GetExHandlerType : AnsiString;
|
|
function GetExHandlerCode : AnsiString;
|
|
|
|
function GetDefErrorHandler : boolean;
|
|
function GetOneOrMoreBlocks : TInterfaceList;
|
|
function GetNMBlocks : TInterfaceList;
|
|
function GetSynPredBlocks : TInterfaceList;
|
|
function GetLock( i: integer): boolean;
|
|
function GetCache(i: integer): ILookahead;
|
|
|
|
procedure SetRuleName( pRuleName : AnsiString);
|
|
procedure SetArguments( pArguments : AnsiString);
|
|
procedure SetReturnAction( pAction : AnsiString);
|
|
procedure SetLocals( pLocals : AnsiString);
|
|
procedure SetEndNode( pNode : IRuleEndElem);
|
|
|
|
procedure SetTestLiterals( pTestLiterals : boolean);
|
|
procedure SetLabeledElems( pLabeledElems : TInterfaceList);
|
|
|
|
procedure SetExHandlerType( pExType : AnsiString);
|
|
procedure SetExHandlerCode( pExCode : AnsiString);
|
|
|
|
procedure SetDefErrorHandler( pErrorHandler : boolean);
|
|
procedure SetIgnoreRule( pRule : AnsiString);
|
|
procedure SetLock( i:integer; pLock : boolean);
|
|
procedure SetCache(i:integer; pCache : ILookahead);
|
|
|
|
procedure SetOption( pKey, pValue : IToken);
|
|
function IsLexerAutoGenRule: boolean;
|
|
// function FindExceptionSpec( pLabel : string): IExceptionSpec;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property RuleName : AnsiString read GetRuleName
|
|
write SetRuleName;
|
|
property LabeledElems : TInterfaceList read GetLabeledElems
|
|
write SetLabeledElems;
|
|
|
|
property DefaultErrorHandler : boolean read GetDefErrorHandler
|
|
write SetDefErrorHandler;
|
|
property EndElem : IRuleEndElem read GetEndNode
|
|
write SetEndNode;
|
|
|
|
property Arguments : AnsiString read GetArguments
|
|
write SetArguments;
|
|
|
|
property IgnoreRule : AnsiString read GetIgnoreRule
|
|
write SetIgnoreRule;
|
|
property ReturnAction: AnsiString read GetReturnAction
|
|
write SetReturnAction;
|
|
property Locals : AnsiString read GetLocals
|
|
write SetLocals;
|
|
property TestLiterals: boolean read GetTestLiterals
|
|
write SetTestLiterals;
|
|
|
|
property OneOrMoreBlocks: TInterfaceList read GetOneOrMoreBlocks;
|
|
property NMBlocks : TInterfaceList read GetNMBlocks;
|
|
property SynPredBlocks : TInterfaceList read GetSynPredBlocks;
|
|
|
|
property ExHandlerType : AnsiString read GetExHandlerType
|
|
write SetExHandlerType;
|
|
property ExHandlerCode : AnsiString read GetExHandlerCode
|
|
write SetExHandlerCode;
|
|
|
|
// ------------------------------------------------------------
|
|
// Property arrays
|
|
// ------------------------------------------------------------
|
|
property Lock[ i: integer]: boolean read GetLock
|
|
write SetLock;
|
|
|
|
property Cache[i: integer]: ILookahead read GetCache
|
|
write SetCache;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ISynPredBlock
|
|
// =========================================================================
|
|
ISynPredBlock = interface( IAlternativeBlock)
|
|
['{5E6EF230-0B1B-4A20-95C7-EFE8D9A710CB}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITreeElem
|
|
// =========================================================================
|
|
ITreeElem = interface( IAlternativeBlock)
|
|
['{E522A79A-3825-4346-A449-4588D4858D5B}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetRoot: IGrammarAtom;
|
|
procedure SetRoot( pRoot: IGrammarAtom);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Root: IGrammarAtom read GetRoot write SetRoot;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IBlockWithImpliedExitPath
|
|
// =========================================================================
|
|
IBlockWithImpliedExitPath = interface( IAlternativeBlock)
|
|
['{1D4DAE7A-230E-4699-ADB1-5872665A7B90}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetExitDepth: integer;
|
|
function GetExitCache( i: integer) : ILookahead;
|
|
|
|
procedure SetExitDepth( pDepth: integer);
|
|
procedure SetExitCache( i: integer; pExitCache: ILookahead);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property ExitCache[i:integer]: ILookahead read GetExitCache
|
|
write SetExitCache;
|
|
property ExitDepth: integer read GetExitDepth
|
|
write SetExitDepth;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IZeroOrMoreBlock
|
|
// =========================================================================
|
|
IZeroOrMoreBlock = interface( IBlockWithImpliedExitPath)
|
|
['{BED0D2F1-FF2F-47C5-846A-DBCE97551C3F}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IOneOrMoreBlock
|
|
// =========================================================================
|
|
IOneOrMoreBlock = interface( IBlockWithImpliedExitPath)
|
|
['{0BD0A437-3376-42EA-BA77-8FF0E49EEC65}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// INMBlock
|
|
// =========================================================================
|
|
INMBlock = interface( IBlockWithImpliedExitPath)
|
|
['{0BD0A437-3376-42EA-BA77-8FF0E49EEC65}']
|
|
function GetLow : integer;
|
|
function GetHigh : integer;
|
|
|
|
procedure SetLow( Value: integer);
|
|
procedure SetHigh(Value: integer);
|
|
|
|
property Low : integer read GetLow write SetLow;
|
|
property High : integer read GetHigh write SetHigh;
|
|
end;
|
|
|
|
|
|
// =========================================================================
|
|
// IExceptionHandler
|
|
// =========================================================================
|
|
IExceptionHandler = interface
|
|
['{B7AC1616-FE56-461F-8E92-A8666A077D55}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetTypeAndName : IToken;
|
|
function GetAction : IToken;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property TypeAndName : IToken read GetTypeAndName;
|
|
property Action : IToken read GetAction;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IExceptionSpec
|
|
// =========================================================================
|
|
IExceptionSpec = interface
|
|
['{D83D6221-E5DE-432C-BDCE-1E9EDAF72FDE}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetLabel : IToken;
|
|
function GetHandlers: TInterfaceList;
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure AddHandler( pHandler: IExceptionHandler);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Lbl : IToken read GetLabel;
|
|
property Handlers : TInterfaceList read GetHandlers;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IAlternative
|
|
// =========================================================================
|
|
IAlternative = interface
|
|
['{54C18FB4-CD6D-483C-A03B-0D0F467D9A90}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetHead : IAlternativeElem;
|
|
function GetTail : IAlternativeElem;
|
|
function GetSynPredBlock : ISynPredBlock;
|
|
function GetSemPred : AnsiString;
|
|
|
|
function GetCacheSize : integer;
|
|
function GetLookaheadDepth : integer;
|
|
function GetTreeSpecifier : IToken;
|
|
function GetDoAutoGen : boolean;
|
|
|
|
function GetExHandlerType : AnsiString;
|
|
function GetExHandlerCode : AnsiString;
|
|
|
|
procedure SetHead( pHead : IAlternativeElem);
|
|
procedure SetTail( pTail : IAlternativeElem);
|
|
|
|
procedure SetSynPredBlock( pBlock : ISynPredBlock);
|
|
procedure SetSemPred( pSemPred : AnsiString);
|
|
|
|
procedure SetCacheSize( pSize : integer);
|
|
procedure SetLookaheadDepth( pDepth : integer);
|
|
procedure SetTreeSpecifier( pTreeSpecifier : IToken);
|
|
procedure SetDoAutoGen( pDoAutoGen : boolean);
|
|
|
|
procedure SetExHandlerType( pType : AnsiString);
|
|
procedure SetExHandlerCode( pCode : AnsiString);
|
|
|
|
function GetCache( i:integer): ILookahead;
|
|
procedure SetCache( i: integer; pLookahead: ILookahead);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure AddElem( pElem: IAlternativeElem);
|
|
function AtStart: boolean;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Head : IAlternativeElem read GetHead
|
|
write SetHead;
|
|
property Tail : IAlternativeElem read GetTail
|
|
write SetTail;
|
|
property SynPred : ISynPredBlock read GetSynPredBlock
|
|
write SetSynPredBlock;
|
|
property SemPred : AnsiString read GetSemPred
|
|
write SetSemPred;
|
|
|
|
property ExHandlerType : AnsiString read GetExHandlerType
|
|
write SetExHandlerType;
|
|
|
|
property ExHandlerCode : AnsiString read GetExHandlerCode
|
|
write SetExHandlerCode;
|
|
|
|
property CacheSize : integer read GetCacheSize
|
|
write SetCacheSize;
|
|
property LookaheadDepth : integer read GetLookaheadDepth
|
|
write SetLookaheadDepth;
|
|
property TreeSpecifier : IToken read GetTreeSpecifier
|
|
write SetTreeSpecifier;
|
|
property DoAutoGen : boolean read GetDoAutoGen
|
|
write SetDoAutoGen;
|
|
property Cache[i: integer]: ILookahead read GetCache
|
|
write SetCache;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IBlockContext
|
|
// =========================================================================
|
|
IBlockContext = interface
|
|
['{97FD1C1E-8443-4B28-9B04-5E90CD99055C}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetBlock : IAlternativeBlock;
|
|
function GetBlockEnd : IBlockEndElem;
|
|
function GetAltNum : integer;
|
|
|
|
procedure SetBlock( pBlock : IAlternativeBlock);
|
|
procedure SetBlockEnd( pBlockEnd : IBlockEndElem);
|
|
procedure SetAltNum( pAltNum : integer);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure AddAlternativeElem( pElem: IAlternativeElem);
|
|
function CurrentAlt : IAlternative;
|
|
function CurrentElem : IAlternativeElem;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property Block : IAlternativeBlock read GetBlock write SetBlock;
|
|
property BlockEnd : IBlockEndElem read GetBlockEnd write SetBlockEnd;
|
|
property AltNum : integer read GetAltNum write SetAltNum;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITreeBlockContext
|
|
// =========================================================================
|
|
ITreeBlockContext = interface( IBlockContext)
|
|
['{04963303-C0B7-487D-9D24-6E5C56337EE3}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
// function GetNextElemIsRoot: boolean;
|
|
// procedure SetNextElemIsRoot( pRoot: boolean);
|
|
//
|
|
// property NextElemIsRoot: boolean read GetNextElemIsRoot
|
|
// write SetNextElemIsRoot;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ICodeGenerator
|
|
// =========================================================================
|
|
ICodeGenerator = interface
|
|
procedure Gen(pGrammar: IGrammar); overload;
|
|
// procedure Gen(pGrammar: ILexerGrammar); overload;
|
|
procedure Gen(pElem : IActionElem); overload;
|
|
procedure Gen(pElem : IAlternativeBlock); overload;
|
|
procedure Gen(pElem : IBlockEndElem); overload;
|
|
procedure Gen(pElem : ICharLiteralElem); overload;
|
|
procedure Gen(pElem : ICharRangeElem); overload;
|
|
procedure Gen(pElem : IGrammarAtom); overload;
|
|
procedure Gen(pElem : IOneOrMoreBlock); overload;
|
|
procedure Gen(pElem : INMBlock); overload;
|
|
procedure Gen(pElem : IRuleBlock); overload;
|
|
procedure Gen(pElem : IRuleEndElem); overload;
|
|
procedure Gen(pElem : IRuleRefElem); overload;
|
|
procedure Gen(pElem : IStringLiteralElem); overload;
|
|
procedure Gen(pElem : ISynPredBlock); overload;
|
|
procedure Gen(pElem : ITokenRangeElem); overload;
|
|
procedure Gen(pElem : ITreeElem); overload;
|
|
procedure Gen(pElem : IWildCardElem); overload;
|
|
procedure Gen(pElem : IZeroOrMoreBlock); overload;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IGrammarAnalyzer
|
|
// =========================================================================
|
|
IGrammarAnalyzer = interface
|
|
['{7690F384-E2A3-477F-93A7-E4FDE800582A}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ILLkAnalyzer
|
|
// =========================================================================
|
|
ILLkAnalyzer = interface( IGrammarAnalyzer)
|
|
['{719F8B79-C3D3-436E-941A-AEF12E6D5477}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
procedure SetGrammar( pGrammar: IGrammar);
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
function Deterministic( pBlk: IAlternativeBlock): boolean; overload;
|
|
function Deterministic( pBlk: IOneOrMoreBlock) : boolean; overload;
|
|
function Deterministic( pBlk: IZeroOrMoreBlock) : boolean; overload;
|
|
|
|
function Look( k: integer; pElem: IActionElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IAlternativeBlock) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IBlockEndElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: ICharLiteralElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: ICharRangeElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IGrammarAtom) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IOneOrMoreBlock) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IRuleBlock) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IRuleEndElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IRuleRefElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IStringLiteralElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: ISynPredBlock) : ILookahead; overload;
|
|
function Look( k: integer; pElem: ITokenRangeElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: ITreeElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IWildCardElem) : ILookahead; overload;
|
|
function Look( k: integer; pElem: IZeroOrMoreBlock) : ILookahead; overload;
|
|
function Look( k: integer; pElem: AnsiString) : ILookahead; overload;
|
|
|
|
function FOLLOW( k: integer; pElem: IRuleEndElem) : ILookahead;
|
|
|
|
function SubRuleCanBeInverted( pBlock : IAlternativeBlock;
|
|
pIsLexer : boolean): boolean;
|
|
|
|
property Grammar : IGrammar write SetGrammar;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IToolErrorHandler interface
|
|
// =========================================================================
|
|
IToolErrorHandler = interface
|
|
procedure Warning( pMessage: string; FileName:string=''; Line:integer=0; Column:integer=0);
|
|
procedure Error( pMessage: string; FileName:string=''; Line:integer=0; Column:integer=0);
|
|
procedure Panic( pMessage: string; FileName:string=''; Line:integer=0; Column:integer=0);
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ITool
|
|
// =========================================================================
|
|
ITool = interface
|
|
['{6925CCC7-A72C-4731-9172-D762BFA668E4}']
|
|
|
|
// ------------------------------------------------------------
|
|
// property handling
|
|
// ------------------------------------------------------------
|
|
function GetWarningCount : integer;
|
|
function GetErrorCount : integer;
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure Go;
|
|
|
|
// ------------------------------------------------------------
|
|
// Debug methods
|
|
// ------------------------------------------------------------
|
|
procedure Debug( pMessage : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Standard diagnostic methods
|
|
// ------------------------------------------------------------
|
|
procedure Error( pMessage : AnsiString;
|
|
pFileName: AnsiString = '';
|
|
pLine : integer = 0;
|
|
pColumn : integer = 0);
|
|
|
|
procedure Warning( pMessage : AnsiString;
|
|
pFileName: AnsiString = '';
|
|
pLine : integer = 0;
|
|
pColumn : integer = 0);
|
|
|
|
procedure Panic( pMessage : AnsiString);
|
|
|
|
// ------------------------------------------------------------
|
|
// Special diagnostic methods
|
|
// ------------------------------------------------------------
|
|
procedure WarnAltAmbiguity( pGrammar : IGrammar;
|
|
pBlock : IAlternativeBlock;
|
|
pLexical : boolean;
|
|
pDepth : integer;
|
|
pSets : TInterfaceList;
|
|
pAltIdx1 : integer;
|
|
pAltIdx2 : integer);
|
|
|
|
procedure WarnAltExitAmbiguity( pGrammar : IGrammar;
|
|
pBlock : IBlockWithImpliedExitPath;
|
|
pLexical : boolean;
|
|
pDepth : integer;
|
|
pSets : TInterfaceList;
|
|
pAltIdx : integer);
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property WarningCount : integer read GetWarningCount;
|
|
property ErrorCount : integer read GetErrorCount;
|
|
end;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// IGrammar interface
|
|
// -------------------------------------------------------------------------
|
|
IGrammar = interface
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetTool : ITool;
|
|
function GetCodeGenerator : ICodeGenerator;
|
|
function GetAnalyzer : ILLkAnalyzer;
|
|
function GetTokenManager : ITokenManager;
|
|
|
|
function GetGrammarName : AnsiString;
|
|
function GetFileName : AnsiString;
|
|
function GetUnitName : AnsiString;
|
|
function GetGrammarFile : AnsiString;
|
|
|
|
function GetImportVocab : IToken;
|
|
function GetExportVocab : AnsiString;
|
|
|
|
function GetDefErrorHandler: boolean;
|
|
function GetHasSynPred : boolean;
|
|
function GetMemberAction : IToken;
|
|
function GetMemberDecl : AnsiString;
|
|
function GetMemberDef : AnsiString;
|
|
function GetCharVocabulary: TByteSet;
|
|
function GetSymbol( pRule: AnsiString): ITokenSymbol;
|
|
function GetRules : TInterfaceList;
|
|
function GetUsesList : TStringList;
|
|
function GetUsesList2 : TStringList;
|
|
function GetConstAction : IToken;
|
|
function GetTypeAction : IToken;
|
|
|
|
function GetMaxK : integer;
|
|
|
|
procedure SetAnalyzer( pAnalyzer: ILLkAnalyzer);
|
|
procedure SetUnitName( pUnit : AnsiString);
|
|
procedure SetImportVocab( pVocab : IToken);
|
|
procedure SetExportVocab( pVocab : AnsiString);
|
|
procedure SetDefErrorHandler( pHandler : boolean);
|
|
procedure SetHasSynPred( pSynPred : boolean);
|
|
procedure SetMemberAction( pAction : IToken);
|
|
procedure SetMemberDecl( pDecl : AnsiString);
|
|
procedure SetMemberDef( pDef : AnsiString);
|
|
procedure SetCharVocabulary( pVocab : TByteSet);
|
|
procedure SetCodeGenerator( pGenerator : ICodeGenerator);
|
|
procedure SetConstAction( pConst : IToken);
|
|
procedure SetTypeAction( pType : IToken);
|
|
procedure SetGrammarFile( pFile : AnsiString);
|
|
|
|
|
|
// ------------------------------------------------------------
|
|
// Methods
|
|
// ------------------------------------------------------------
|
|
procedure Generate;
|
|
function GetClassName: AnsiString;
|
|
function Defined( pID: AnsiString): boolean;
|
|
procedure Define( pSymbol: IRuleSymbol);
|
|
function SetOption( pOption, pValue: IToken): boolean;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property LLkAnalyzer : ILLkAnalyzer read GetAnalyzer write SetAnalyzer;
|
|
property Generator : ICodeGenerator read GetCodeGenerator
|
|
write SetCodeGenerator;
|
|
property MaxK: integer read GetMaxK;
|
|
property Tool : ITool read GetTool;
|
|
property FileName : AnsiString read GetFileName;
|
|
property TokenManager: ITokenManager read GetTokenManager;
|
|
property Symbol[s: AnsiString]: ITokenSymbol read GetSymbol;
|
|
property HasSynPred : boolean read GetHasSynPred
|
|
write SetHasSynPred;
|
|
|
|
property ImportVocab: IToken write SetImportVocab;
|
|
|
|
property ExportVocab: AnsiString read GetExportVocab
|
|
write SetExportVocab;
|
|
|
|
property DefaultErrorHandler : boolean read GetDefErrorHandler
|
|
write SetDefErrorHandler;
|
|
property MemberAction : IToken read GetMemberAction
|
|
write SetMemberAction;
|
|
property CharVocabulary: TByteSet read GetCharVocabulary
|
|
write SetCharVocabulary;
|
|
|
|
property GrammarName : AnsiString read GetGrammarName;
|
|
property UnitName : AnsiString read GetUnitName
|
|
write SetUnitName;
|
|
|
|
property Rules : TInterfaceList read GetRules;
|
|
property UsesList : TStringList read GetUsesList;
|
|
property UsesList2 : TStringList read GetUsesList2;
|
|
|
|
property MemberDecl : AnsiString read GetMemberDecl
|
|
write SetMemberDecl;
|
|
property MemberDef : AnsiString read GetMemberDef
|
|
write SetMemberDef;
|
|
|
|
// property ImportVocabulary: string read GetImportVocab
|
|
// write SetImportVocab;
|
|
// property ExportVocabulary: string read GetExportVocab
|
|
// write SetExportVocab;
|
|
property ConstAction: IToken read GetConstAction
|
|
write SetConstAction;
|
|
property TypeAction: IToken read GetTypeAction
|
|
write SetTypeAction;
|
|
property GrammarFile: AnsiString read GetGrammarFile
|
|
write SetGrammarFile;
|
|
end;
|
|
|
|
// =========================================================================
|
|
// ILexerGrammar interface
|
|
// =========================================================================
|
|
ILexerGrammar = interface( IGrammar)
|
|
['{99C98AC7-5808-4B46-A353-58C95AFFDF6A}']
|
|
|
|
// ------------------------------------------------------------
|
|
// Property handling
|
|
// ------------------------------------------------------------
|
|
function GetTestLiterals : boolean;
|
|
function GetCaseSensitive : boolean;
|
|
function GetFilterMode : boolean;
|
|
function GetFilterRule : AnsiString;
|
|
|
|
// ------------------------------------------------------------
|
|
// Properties
|
|
// ------------------------------------------------------------
|
|
property TestLiterals : boolean read GetTestLiterals;
|
|
property CaseSensitive : boolean read GetCaseSensitive;
|
|
property FilterMode : boolean read GetFilterMode;
|
|
property FilterRule : AnsiString read GetFilterRule;
|
|
end;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// IParserGrammar interface
|
|
// -------------------------------------------------------------------------
|
|
IParserGrammar = interface( IGrammar)
|
|
['{BD8E9F0F-0FDE-448D-95B8-27CD15408BD0}']
|
|
|
|
function GetBuildAST: boolean;
|
|
procedure SetBuildAST( Value: boolean);
|
|
|
|
property BuildAST : boolean read GetBuildAST write SetBuildAST;
|
|
end;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// ITreeWalkerGrammar interface
|
|
// -------------------------------------------------------------------------
|
|
ITreeWalkerGrammar = interface( IGrammar)
|
|
['{BD09EF54-5842-4CA0-ACE7-12ACA18EF0AF}']
|
|
end;
|
|
|
|
// =========================================================================
|
|
// IGrammarBehavior
|
|
// =========================================================================
|
|
IGrammarBehavior = interface
|
|
['{1D8177D4-CDB4-44AF-915E-2388FF389A69}']
|
|
|
|
function Grammar: IGrammar;
|
|
|
|
procedure AbortGrammar;
|
|
|
|
procedure BeginAlt( pDoAST: boolean);
|
|
procedure BeginExceptionGroup;
|
|
procedure BeginExceptionSpec( pLabel : IToken);
|
|
procedure BeginSubRule( pLabel : IToken;
|
|
pStart : IToken;
|
|
pNot : boolean);
|
|
|
|
procedure BeginTree( pStart : IToken);
|
|
procedure BeginChildList;
|
|
|
|
procedure DefineGrammarUnit( pUnit : AnsiString);
|
|
procedure DefineRuleName( pRule : IToken;
|
|
pAccess : AnsiString;
|
|
pRuleAST : boolean;
|
|
pDocComment : AnsiString);
|
|
|
|
procedure DefineToken( pTokenName : IToken;
|
|
pTokenLiteral : IToken);
|
|
|
|
procedure DefineUses( pUses : AnsiString);
|
|
|
|
procedure EndAlt;
|
|
procedure EndExceptionGroup;
|
|
procedure EndExceptionSpec;
|
|
procedure EndGrammar;
|
|
procedure EndOptions;
|
|
procedure EndRule( pRuleName : AnsiString);
|
|
procedure EndSubRule;
|
|
procedure EndTree;
|
|
procedure EndChildList;
|
|
|
|
procedure HasError;
|
|
|
|
procedure NoASTSubRule;
|
|
procedure OneOrMoreSubRule;
|
|
procedure NMSubrule;
|
|
procedure OptionalSubRule;
|
|
|
|
procedure refRangeLow( M : integer);
|
|
procedure refRangeHigh( N : integer);
|
|
|
|
|
|
procedure RefAction( pAction : IToken);
|
|
procedure RefArgAction( pAction : IToken);
|
|
|
|
procedure RefCharLiteral( pLiteral : IToken;
|
|
pLabel : IToken;
|
|
pInverted : boolean;
|
|
pAutoGenType : integer;
|
|
pLastInRule : boolean);
|
|
|
|
procedure RefCharRange( pToken1 : IToken;
|
|
pToken2 : IToken;
|
|
pLabel : IToken;
|
|
pAutoGenType : integer;
|
|
pLastInRule : boolean);
|
|
|
|
procedure RefConstAction( pConstAction : IToken);
|
|
procedure RefTypeAction( pTypeAction : IToken);
|
|
|
|
procedure RefElemOption( pOption : IToken;
|
|
pValue : IToken);
|
|
|
|
procedure RefTokenSpecElemOption( pToken : IToken;
|
|
pOption : IToken;
|
|
pValue : IToken);
|
|
|
|
procedure RefExceptionHandler( pTypeAndName : IToken;
|
|
pAction : IToken);
|
|
|
|
procedure RefInitAction( pAction : IToken);
|
|
procedure RefRuleLocals( pLocals : IToken);
|
|
procedure RefMemberDecl( pDecl : IToken);
|
|
procedure RefMemberDef( pDef : IToken);
|
|
procedure RefReturnAction( pAction : IToken);
|
|
|
|
procedure RefRule( pAssignId : IToken;
|
|
pRuleName : IToken;
|
|
pLabel : IToken;
|
|
pArguments : IToken;
|
|
pAutoGenType : integer);
|
|
|
|
procedure RefRuleExHandler( pExHandlerType : IToken;
|
|
pExHandlerCode : IToken);
|
|
|
|
procedure RefAltExHandler( pExHandlerType : IToken;
|
|
pExHandlerCode : IToken);
|
|
|
|
procedure RefSemPred( pSemPred : IToken);
|
|
|
|
procedure RefStringLiteral( pLiteral : IToken;
|
|
pLabel : IToken;
|
|
pAutoGenType : integer;
|
|
pLastInRule : boolean);
|
|
|
|
procedure RefToken( pAssignId : IToken;
|
|
pToken : IToken;
|
|
pLabel : IToken;
|
|
pArguments : IToken;
|
|
pInverted : boolean;
|
|
pAutoGenType : integer;
|
|
pLAstInRule : boolean);
|
|
|
|
procedure RefTokenRange( pToken1 : IToken;
|
|
pToken2 : IToken;
|
|
pLabel : IToken;
|
|
pAutoGenType : integer;
|
|
pLastInRule : boolean);
|
|
|
|
procedure RefWildCard( pToken : IToken;
|
|
pLabel : IToken;
|
|
pAutoGenType : integer);
|
|
|
|
procedure Reset;
|
|
|
|
procedure SetArgOfRuleRef( pArguments : IToken);
|
|
procedure SetCharVocabulary( pVocabulary : TByteSet);
|
|
|
|
procedure SetFileOption( pOption : IToken;
|
|
pValue : IToken;
|
|
pFileName : AnsiString);
|
|
|
|
procedure SetGrammarOption( pOption : IToken;
|
|
pValue : IToken);
|
|
|
|
procedure SetRuleOption( pOption : IToken;
|
|
pValue : IToken);
|
|
|
|
procedure SetSubRuleOption( pOption : IToken;
|
|
pValue : IToken);
|
|
|
|
procedure SetUserExceptions( pException : AnsiString);
|
|
|
|
procedure StartLexer( pFileName : AnsiString;
|
|
pLexerName : IToken;
|
|
pSuperClass : IToken);
|
|
|
|
procedure StartParser( pFileName : AnsiString;
|
|
pLexerName : IToken;
|
|
pSuperClass : IToken);
|
|
|
|
|
|
procedure StartTreeWalker( pFileName : AnsiString;
|
|
pLexerName : IToken;
|
|
pSuperClass : IToken);
|
|
|
|
procedure SynPred;
|
|
procedure ZeroOrMoreSubRule;
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
end.
|
|
|