24.8 ActionEvents
327
//Fired whena debugemit isexecuted.
eventDebugEmitHandlerOnDebugEmit;
//Fired whena debughalt isexecuted.
eventDebugHaltHandlerOnDebugHalt;
//Fired whena debughighlightis executed.
eventDebugHighlightHandler OnDebugHighlight;
Aspecialkindofsequencebasedeventsarethegraphchangeevents,redwhenprocessing
entersasubgraphorleavesasubgraph(redwhenthesubgraphusagestackisaltered):
//Fired whengraphprocessing (rule andsequenceexecution) is switched to a
(sub)graph.
// (Notfiredwhen themain graphis replaced byanothermaingraph,or initialized.)
eventSwitchToSubgraphHandlerOnSwitchingToSubgraph;
//Fired whengraphprocessingisreturningbackafter aswitch.
// (Tothe maingraph,or a subgraph previouslyswitched to.)
eventReturnFromSubgraphHandlerOnReturnedFromSubgraph;
Thesequence basedevents declaredby the IGraphProcessingEnvironment extending
theISubactionAndOutputAdditionEnvironmentare:
//Fired whena sequenceis entered.
eventEnterSequenceHandlerOnEntereringSequence;
//Fired whena sequenceis left.
eventExitSequenceHandlerOnExitingSequence;
//Fired whena sequenceiterationis ended.
eventEndOfIterationHandler OnEndOfIteration;
Batch pdf to jpg online - Convert PDF to JPEG images in C#.net, ASP.NET MVC, WinForms, WPF project
How to convert PDF to JPEG using C#.NET PDF to JPEG conversion / converter library control SDK
convert pdf to jpg 100 dpi; conversion of pdf to jpg
Batch pdf to jpg online - VB.NET PDF Convert to Jpeg SDK: Convert PDF to JPEG images in vb.net, ASP.NET MVC, WinForms, WPF project
Online Tutorial for PDF to JPEG (JPG) Conversion in VB.NET Image Application
advanced pdf to jpg converter; pdf to jpg
328
ApplicationProgrammingInterface
JPEG to PDF Converter | Convert JPEG to PDF, Convert PDF to JPEG
software; Support a batch conversion of JPG to PDF with amazingly high speed; Get a compressed PDF file after conversion; Support
batch pdf to jpg converter; convert pdf to jpg
JPG to GIF Converter | Convert JPEG to GIF, Convert GIF to JPG
speed JPEG to GIF Converter, faster than other JPG Converters; when you convert the files in batch; Storing conversion so the user who is not online still can
convert pdf to jpg for online; convert pdf file to jpg
CHAPTER 25
EXTENSIONS
ThischapterexplainshowtocustomizeGrGen.NETwithexternalcode,orhowtotightly
integrateGrGen.NETwithexternalcode. Itliststhewayshowyoucaninteractwiththe
externalworldoutsideofGrGen.NET.Theprimarymeansavailableare:externalattribute
typesandtheirmethods,externalfunctions andprocedures,matchlters,andexternalse-
quences; the e secondary y helpers s available are annotations, , command line e parameters, , and
externalshellcommands.
Youtypicallywanttousethemforintegratingfunctionalityoutsideofgraphrepresenta-
tionprocessing,subtasksGrGen.NETwasnotbuiltfor;youmaybewanttousethemfor
performancereasonstoimplementlinkedlistsortreesmoreecientlythanwiththenodes
andedgessuppliedbyGrGen.NET.
ThelanguagesofGrGen.NETshieldyoufromthedetailsoftheruntimeandtheframe-
workbelowit;youcancombinetheirconstructsfreely.Butwhenyouplugintotheexisting
framework withyour code,youmustobeytheexpectations ofthatframework. . Whenyou
extendGrGen.NET,youmustplayaccordingtotherulesoftheGrGen.NET-components.
Thatsaid,thereareplentyofpossibilitiestoextendtheframeworkwithyourownfunction-
ality.
25.1 ExternalAttributeTypes
ExternalClassDeclaration
-
external
-
class
-
IdentDecl
-
extends
-
ExternalClassType
,
-
;
-
f
-
ExternalFunctionDeclaration
-
ExternalProcedureDeclaration
-
g
-
Registers anew attributetypewithGrGen.NET.Youmay declarethebasetypesofthe
type, and d you may specify external function methods or r procedure methods. . Attributes
can’t be specied. . The e attribute type (and the declaredmethods) must be implemented
externally,see24.5;forGrGen.NETthetypeisopaque,onlyexternalfunctions/procedures
orthefunction/proceduremethodscancarryoutcomputationsonit.
329
JPG to DICOM Converter | Convert JPEG to DICOM, Convert DICOM to
Open JPEG to DICOM Converter first; Load JPG images from local folders in "File" in toolbar Windows Explorer; Select "Batch Conversion" & Choose "DICOM" in
convert pdf file into jpg; bulk pdf to jpg converter online
JPG to JBIG2 Converter | Convert JPEG to JBIG2, Convert JBIG2 to
Ability to preserve original images without any affecting; Ability to convert image swiftly between JPG & JBIG2 in single and batch mode;
best pdf to jpg converter online; change from pdf to jpg on
330
Extensions
YoumayextendGrGen.NETwithexternalattributetypesifthebuilt-inattributetypes
(cf.6.1)areinsucientforyourneeds(becauseyouneedfunctionalitynotrelatedtograph-
rewriting, or r because you u want t toimplement lists or r trees s more eciently than n withthe
nodeandedgetypesbuiltforgeneral-purposegraphrewriting). (Theexternaltypescanbe
explicitlycastedto objectbut arenotimplicitly casted.) ) The e methodsmay registerown
undoitemswiththetransactionmanagertorealizerollbackbehaviourforexternalattributes
(cf.140).
25.2 ExternalFunctionTypes
ExternalFunctionDeclaration
-
external
-
function
-
IdentDecl
-
(
-
Type
,
-
)
-
:
-
Type
-
;
-
RegistersanexternalfunctionwithGrGen.NETtobeusedinattributecomputations.An
externalfunctiondeclarationspecies the expectedinputtypesandthe outputtype. . The
functionmustbeimplementedexternally,see24.5. Anexternalfunctioncall(cf. 6.8)may
receiveandreturnvaluesofthebuilt-in(attribute)typesaswellasoftheexternalattribute
types;therealargumentsonthe callsites aretype-checkedagainstthedeclaredsignature
followingthe subtypinghierarchyof the built-inas wellasof the externalattributetypes.
YoumayextendGrGen.NETwithexternalfunctionsifthebuilt-inattributecomputation
capabilities(cf.6.2)orgraphqueryingcapabilitiesareinsucientforyourneeds.
25.3 ExternalProcedureTypes
ExternalProcedureDeclaration
-
external
-
procedure
-
IdentDecl
-
(
-
Type
,
-
)

-
:
-
(
-
Type
,
-
)
-
;
-
RegistersanexternalprocedurewithGrGen.NETtobeusedinattributecomputations.An
externalproceduredeclarationspeciestheexpectedinputtypesandtheoutputtypes. The
proceduremustbeimplementedexternally,see24.5.Anexternalprocedurecall(cf.6.8)may
receiveandreturnvaluesofthebuilt-in(attribute)typesaswellasoftheexternalattribute
types;therealargumentsonthe callsites aretype-checkedagainstthedeclaredsignature
followingthe subtypinghierarchyof the built-inas wellasof the externalattributetypes.
YoumayextendGrGen.NETwithexternalproceduresifthebuilt-inattributecomputation
capabilities(cf.6.2)orgraphmanipulationcapabilitiesareinsucientforyourneeds.
JPG to Word Converter | Convert JPEG to Word, Convert Word to JPG
Open JPEG to Word Converter first; Load JPG images from local folders in "File" in toolbar Windows Explorer; Select "Batch Conversion" & Choose "Word" in
pdf to jpeg; .pdf to jpg converter online
JPG to JPEG2000 Converter | Convert JPEG to JPEG2000, Convert
Open JPEG to JPEG2000 Converter first; ad JPG images from local folders in "File" in toolbar Windows Explorer; Select "Batch Conversion" & Choose "JPEG2000" in
convert pdf images to jpg; changing file from pdf to jpg
25.4 ExternalFilterFunctions
331
25.4 ExternalFilterFunctions
FilterFunctionDenition
-
external
-
filter
-
FilterIdent
-
<
-
RuleIdent
-
>
-
Parameters
-
;
-
TheFilterFunctionDenition prependedwithanexternalanddeprivedofitsbody(cf.
15formoreonlters),registers anexternallterfunctionwithGrGen.NET T fortherule
(or test)speciedinangles. . Itcanthenbeusedfromapplications s ofthatrule(cf. . Filter-
Calls in9.1). . Alterfunctionname{irrespectivewhetherexternalorinternal{must t be
globallyunique(incontrasttothepredenedlters,eachrulemayoeronewiththesame
name).Thematchlterfunctionmustbeimplementedexternally,see24.6.Youmayextend
GrGen.NETwithmatchltersifyouneedtoinspectthematchesfoundforaruleinorder
todecidewhichtoapply(seenote59)orifyoujustneedapost-matchhookwhichinforms
youaboutthefoundmatches.
Matchobject
For a rule or r subpattern r GrGen n generates a a match interface IMatch
r extending g the
generic IMatch interface from m the libGr. . The e basic c constituents, i.e. . nodes, , edges s and
variables are e mapped directly to members of their r name e andtype, , containing g the graph
elementmatchedorthevaluecomputed. Foralternativesnestedinsidethepatternacom-
monbaseinterfaceIMatch
r
altNameisgenerated,plusforeachalternativecaseaninterface
IMatch
r
altName
altCaseName. Whenyouwalkthematchestreeusingthetypeexactin-
terface(whichisrecommended),youmusttypeswitchonthematchobjectinthealternative
variable,todeterminethecasewhichwasnallymatched,andcasttoitsmatchtype. For
iteratedsnestedinsidethepattern,inthepatternmatchobjectaniteratedvariableoftype
IMatchesExact<IMatch
r
iteratedName> is s created; the e IMatchesExact allows youtoit-
erate over thepatterns nally found. . Asubpatternusageismappeddirectlytoavariable
inthematchobjecttypedwiththematchinterfaceofthesubpattern. Thesameholdsfor
independentpatterns;negativepatternsdonotappearinthematchobjects,fortheyprevent
thematchingandthusthebuildingofamatchobjectintherstplace.
25.5 ExternalSequences
ExternalSequenceDeclaration
-
external
-
sequence
-
RewriteSequenceSignature
-
;
-
Registers anexternalsequence similar toa denedsequence (cf. 18.1) but incontrast to
thatitmustorcanbeimplementedoutsideinC#code. Anexternalsequencedeclaration
speciestheexpectedinputtypesandtheoutputtypes.Thesequencemustbeimplemented
externally,see24.6. YoumayextendGrGen.NETwithexternalsequencesifyouwantto
callintoexternalcodetointerfacewithlibrariesfromoutsidethedomainofgraphrewriting,
oriftheGrGen.NET-languagesarenotwellsuitedforpartsofthetaskathand.
25.6 ExternalEmittingandParsing
EmitParseDeclaration
-
external
-
emit
-
graph
-
class
-
;
-
JPG to PNG Converter | Convert JPEG to PNG, Convert PNG to JPG
Open JPEG to PNG Converter first; Load JPG images from local folders in "File" in toolbar Windows Explorer; Select "Batch Conversion" & Choose "PNG" in "Output
convert multi page pdf to single jpg; change pdf file to jpg
VB.NET Image: PDF to Image Converter, Convert Batch PDF Pages to
VB.NET > Convert PDF to Image. "This online guide content end users to convert PDF and PDF/A documents used commonly in daily life (like tiff, jpg, png, bitmap
best way to convert pdf to jpg; to jpeg
332
Extensions
TellsGrGen.NETthatthedeveloperwantstoextendgrsimportingandexporting,aswell
asemittinganddebuggerdisplay,sothattheycanhandleexternaltypes,orthetypeobject.
Thisallowsforatightintegrationofexternaltypeswiththebuilt-infunctionality;itallows
toinspecttypesnotdenedinGrGen.NETinthedebugger(incl. yComp),anditallows
toserialize/deserializeofgraphsincludingtypesnotdenedinGrGen.NET.See24.4for
anexplanationonwhatneedstobeimplementedinthiscase.
25.7 ExternalCloningandComparison
CopyCompareDeclaration
-
external
-
copy
-
=
-
=
-
<
-
class
-
;
-
TellsGrGen.NETthatthedeveloperwantstoextendgraphelementcopyingorattribute
typecomparison(withequality esp. . beingusedfor r graphisomorphy comparison),sothat
theycanhandle externaltypes,orthetypeobject. . This s allows foratightintegrationof
externaltypes withthebuilt-infunctionality,andallows toimplement valuesemanticsfor
objectsthatarenormallycomparedbycheckingreferenceidentityandclonedbycopyingthe
reference.See24.4foranexplanationonwhatneedstobeimplementedinthiscase.
25.8 ShellCommands
-
!
-
CommandLine
-
CommandLineisexecutedas-isbytheshelloftheoperatingsystem.
-
external
-
CommandLine
-
AnExternalmethodyoumustsupplyiscalledwiththeCommandLine.Thishappenswhen
external emit classwasspecied,see 25.6above. . See24.4foranexplanationonwhat
needstobeimplementedinthiscase.
25.9 ShellandCompilerParameters
WhenexecutingtheGrGen.NETgenerator/compilerGrGen.exe,thefollwingparameters
areadmissible:
[mono] GrGen.exe e [-keep p [<dest-dir>]] [-debug][-lazynic] [-noinline][-r <assembly-path>]
Theassemblyassembly-path islinkedasreferencetothecompilationresultwiththe-r
parameter.
ThesecompilerparameterscanbeconguredintheGrShelltobeused,too:
-
new
-
add
-
reference
-
Filename
-
Congures a reference to an n external assembly y Filename e to o be linkedinto the e generated
assemblies,mapstothe-roptionof grgen.exe(cf.2.2.1).
25.10 Annotations
333
-
new
-
set
-
keepdebug
-
lazynic
-
noinline
-
on
-
off
-
Congures thecompilation n of thegeneratedassemblies s to keepthe generatedles and d to
adddebug symbols, or congures the generationof thematchers toexecutenegatives, in-
dependents,andconditions onlyat theendofmatching(normallyasap),orconguresthe
generationofthematcherstoneverinlinesubpatterns. Mapstothe-keepandthe-debug
optionsortothe-lazynicortothe-noinlineoptionofgrgen.exe.
25.10 Annotations
Identierdenitionscanbeannotatedbypragmas.Annotationsarekey-valuepairs.
IdentDecl
-
Ident
-
[
-
Ident
-
=
-
Constant
,
-
]
-
Youcanuseanykey-valuepairsbetweenthebrackets. ForGrGen.NETonlytheidentiers
prio,containment,andparallelizehaveaneect.Butyoumayusetheannotationstotransmit
informationfromthespecicationlestoAPIlevelwheretheycanbequeried/enumerated.
Key
ValueType Appliesto
Meaning
prio
int
node,edge
Changesthe rankingof agraph ele-
ment for r search h plans. . The e default
is prio=1000. . Graphelementswith
highvaluesarelikelytoappearprior
tographelementswithlowvaluesin
searchplans.
containment boolean
edgetype
Used for r XMI I export; ; typically y de-
nedbytheecore(/XMI)import.De-
clares an edge type to be an edge
typedeningacontainmentrelation,
whichcauses XMLelement contain-
mentintheexportedXMI.Defaultis
containment=false.
parallelize int
actions(rule,test) Causesparallelizationofthepattern
matcheroftheaction;thevaluespec-
iesthenumberofthreadstouse.
Table25.1:Annotations
334
Extensions
EXAMPLE(141)
Wesearchthe patternv:NodeTypeA A -e:EdgeType-> w:NodeTypeB.Wehave e ahost graph
with about t 100 nodes s of f NodeTypeA, , 1,000 nodes of f NodeTypeB B and 10,000 0 edges of
EdgeType. Furthermore e we know w that t between n each h pair of f NodeTypeA A and NodeTypeB
there exists at most one edge of f EdgeType. . GrGen.NET T can use this s information n to
improve the initial search h plan if f we adjust the pattern like e v[prio=10000]:NodeTypeA
-e[prio=5000]:EdgeType-> w:NodeTypeB.
CHAPTER 26
UNDERSTANDING AND EXTENDING GRGEN.NET
ThischapterdescribestheinnerworkingsofGrGen.NETtoallowexternaldevelopers
 tounderstandhowGrGen.NETworks
 esp.inordertoextenditwithnewfeatures
1
ItstartswithasectionondescribinghowtobuildGrGen.NET,followedbyasectiongiving
anintroductionintothegeneratedcode,thenanintroductionintothemechanismofsearch
planning,endingwithasectiongivingsomedetailsofthestructureof,andthedata owin
theGrGen.NET-codegenerator. Herewerepeatsomecontentfromchapter22,reningit
withmoredetail.
26.1 HowtoBuild
In case e you u want to o build d GrGen.NET on your own you should recall the system m lay-
out2.1. ThegraphrewritegeneratorconsistsofafrontendwritteninJavaandabackend
writteninC#. Thefrontendwas s extendedandchangedsinceitsrstversion,butnot re-
placed.Incontrasttothebackend,whichhasseenmultipleenginesandversions:aMySQL
database based version, , a a PSQL database e based d version, a C C version n executing a search
plan with a a virtual l machine, , a a C# engine executing g code e generated from m a a search plan
andnally the current C#engine version2 capable of matching nestedandsubpatterns.
Thefrontendisavailableinthefrontendsubdirectoryofthepublicmercurialrepositoryat
https://bitbucket.org/eja/grgen. ItcanbebuiltwiththeincludedMakefileonLinux
ortheMakefile
Cygwin onWindowswith h the cygwinenvironmentyieldingagrgen.jar.
Alternatively you u may y add the e de e subfolder and d the jars s in the jars subfolder to your
favouriteIDE,butthenyoumusttakecareoftheANTLRparsergenerationpre-build-step
onyour own. . The e backendis available in the engine-net-2 subdirectory. . It t contains s a
VisualStudio2008solutionlecontainingprojects for the libGr,thelgspBackend(libGr-
Search-Plan-Backend)andtheGrShell.Beforeyoucanbuildthesolutionyoumustexecute
./src/libGr/genparser.bat and ./src/GrShell/genparser.bat to o get t the e CSharpCC
parsers for r the rewrite sequences s and the e shell l generated. . Under r LINUX X you may use
make
linux.shtogetacompletebuild.TogettheAPIexamplesgeneratedyoumustexecute
./genlibs.bat.Thedocsubdirectorycontainsthesourcesoftheusermanual,forbuilding
say./build
cygwin.sh grgenonWindowsincygwin-bashor./build d grgenonLinuxin
bash.Thesyntaxhighlightingsubdirectorycontainssyntaxhighlightingspecicationsfor
theGrGen-lesforNotepad++,vim,andEmacs.
Youcanchecktheresultofyourbuildwiththetestsuiteweusetocheckagainstregres-
sions. Itissplitintosyntactictestsinfrontend/testcheckingthatexamplemodelandrule
lescangetcompiledby grgen(ornotcompiled,oronlycompiledemittingwarnings)and
theresultingcodecangetcompiledbycsc. Thetestsgetexecutedbycalling./test.shor
./testpar.shfrombashorcygwin-bash(testpar.shexecutestheminparallelspeedingup
1
whichmaybespecialextensionsforadedicatedtask,butalsomaybeofgeneralinteresttootherusers
335
336
UnderstandingandExtendingGrGen.NET
executiononmulticoresystemsconsiderablyatthepriceofpotentialfalsepositivereports);
deviationsfromagoldstandardarereported. Andsemantictestsinengine-net-2/tests
checkingthatexecutingexampleshellscriptsonexamplemodelsandrulesyieldstheexpected
results.Theygetexecutedbycalling./test.sh.
26.2 TheGeneratedCode
Inthissectionwe’llhavealookatwhatisgeneratedbyGrGen.NETofyourspecications;
rstlythemodel,secondlytherules,bettermatchingtheirpatterns,endingthirdlywithan
explanationofthematchingofnestedandsubpatterns.
InternalGraphRepresentation
The graphstructure is maintainedinanLGSPGraph built of f LGSPNode e and d LGSPEdge e ob-
jects,basicallywithouttypeandattributeinformation. Thetypesdenedinthemodelare
realizedbygeneratednodeandedgeinterfacesdeningtheuservisibletypesandattributes,
whichareimplementedbygeneratednodeandedgeclassesinheritingfromandworkinglike
LGSPNodes andLGSPEdgesin n the graph,additionally y implementingthetype andattribute
bearinginterfaces.
Thenodesandedgesarecontainedinasystemofringlists. Topleveltherearethetype
ringlists,everynodeor edgeiscontainedinthelinkedlist ofitsspecictype;thedummy
headnodesorheadedgesservingasentrypointsintothesestructuresareaccessiblefroman
arrayinthegraph,storingasmanyheadsastherearetypes.Everynodeoredgecontainsa
eldtypeNextgivingthenextelementofthetype. Theselistsallowtoquicklylookupall
elements fromthegraphbearingacertaintype. . Figure 26.1gives anexampleforagraph
with3nodetypes,onehavingnoinstancenodes,onehavingonlyoneinstancenode,andone
having5instancenodes;thesameholdsfortheedgetypes.
T1 T2 2 T3
Head
T1 T2 2 T3
Head
Nodes
Edges
Head
Head
Head
Head
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
typeNext
Figure26.1: Examplefortyperinglists
Theconnectednessinformationisstoredinaringlistcontainingtheincomingedgesand
a ringlistcontainingtheoutgoingedgesfor everynode object;the nodeobjectcontainsa
eldinHead referencing anarbitrary edge object of the incoming edges (or null of there
is none)andaeldoutHeadreferencinganarbitraryedgeobjectoftheoutgoingedges(or
Documents you may be interested
Documents you may be interested