2.3 TheLanguagesandtheirFeatures
17
are the right place e to o do o so. . Most t usages s are e related d to storages s which h are variables s of
containertypestoringgraphelements,theyesp. allowtobuildtransformationsfollowinga
wavefrontrunningoverthegraph(seeChapter13formoreoncontainers).
Thesequencescanbe abstractedinto a sequence denition that canthenbecalledin
theplaceofarule. Thisway y commonparts canbereused,butespeciallyis itpossibleto
programarecursivestrategy. Forsimulationruns,severalindeterministicchoiceoperators
areavailable.
Advancedconstructsareavailablewithtransactionsanglesandbacktrackingdoubleangles
capableofrollingbackchangescarriedoutonthegraphtogetbacktothestateofthegraph
againfrombeforetheirnestedcontentwas applied d (see Chapter18). . Withthemyoucan
easilytrythingsoutwithouthavingtoinvestintoprogrammingthebookkeepingneededto
reverttoanoldstate. Theyallowtosystematicallyrunthroughasearchspace,orevento
enumerateastatespace,materializinginterestingstatesreachedintimeoutintospace.
Thosesequencesareavailableinanintegratedformintherulelanguage(seeChapter11).
Afterapplyingthedirecteectsofaruleit is possibletoapplyanembedded sequence e for
follow-uptasks thatjust can’tbeexpressedwithasingleruleapplication;those sequences
haveaccesstotheelementsoftheircontainingrule,theyallowtobuildcomplextransforma-
tionswithrule-sequence-rulecallchains.
2.3.4 ShellLanguage
Those werethe features ofthe languages atthe core ofthe GrGen.NET-System(imple-
mentedbythegeneratorgrgen.exeandtheruntimelibrarieslibGrandlgspBackend). In
addition,theGrGen.NETsystemsuppliesashellapplication,theGrShell,whichoers
besidessome commoncommands,variablehandlingconstructs,andlesystemcommands
several constructs s for graph handling g and d visualization, as s well l as s constructs for sequence
executionanddebugging.Furthermore,someswitchesareavailabletoconguretheshelland
thegraphprocessingenvironment,aswellasthegrgencompiler.
Regardinggraphhandlingyoundcommandsforgraphcreationandmanipulation,graph
exportandimport,andgraphchangerecordingplusreplaying(seeChapter20). Forgraph
creation 3 simple new commands s are available, , one for r creating anempty y graph, one e for
creatinganode,andoneforcreationanedge. TheGRSexporterserializes s withthesame
syntax,whichisalsoexpectedbytheGRSimporter. Writealeinthissimpleformatifthe
availableimportformatsarenotsupportedbyyourdatasource.
Fordirectgraphmanipulationyounddeletionandretypingcommandsinadditionto
the creation commands,and commands forassigning attributes of graphelements. . More-
over,export andimportcommandsare available for serializinga graphtoale,andfor
unserializing agraph froma le(in GRS, GXL andXMI/ecore formats). . Changes s that are
occurringtoagraphmay be recorded d to aGRS S andlater replayed d or r simply imported.
Changerecordingallows for post-problemdebugging,but allows alsoto use GrGen.NET
asakindofembeddeddatabasethatpersistschangesastheyappear.
The graph and the model can be queried furtheron for e.g. . the e dened types s or the
attributesofagraphelement. Thegraphmaybevalidatedagainsttheconnectionassertions
speciedinthemodel,oragainstasequencethatgetsexecutedonacloneofthehostgraph.
Regardingsequenceexecutionyoundthecentralexeccommandthatisinterpretingthe
followingsequence(infactbydelegatingtheparsingandexecutiontolibGr). Inaddition,
action profiles may be e shown. . They y are available when proling g instrumentation n was
switchedon,tellingaboutthenumberofsearchstepsorgraphaccessescarriedout.
Theactionscanbereplacedatruntimebyloadinganotheractionslibrary;thebackend
couldbe,butcurrentlythereisonlyoneavailable,thelgspBackend. Thisbackendsupports
furthercustomcommands,thatstartwithacustom graphorcustom m actionsprex.They
allow to analyze e the e graph in order r to o compile some statistics s about the characteristics
of the graph that t are e of f relevance e for r the pattern matcher. . And d in the following to re-
Pdf to jpg - 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 for online; pdf to jpeg
Pdf to jpg - 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
convert pdf file into jpg; .pdf to jpg converter online
18
Overview
generatethepatternmatchersatruntime(gen
searchplans)giventheknowledgeaboutthe
characteristicsofthegraph,yieldingmatcherswhichareadaptedtothehostgraph andthus
typicallyfasterthanthedefaultpatternmatchersgeneratedstaticallyintotheblue. Youcan
inspectthesearchplansinusewiththeexplaincustomcommand.
ThedebuggercomponentoftheGrShellallowstodebuga sequence executionstep-
by-step,highlightingthecurrentlyexecutedruleinthesequence,anddisplayingthecurrent
graphinthe graphviewer yComp; indetail mode even the matchfoundandtherewrite
carriedoutbytherulearehighlightedinthegraph(seeChapter21).
Thegraphvisualizationishighlycustomizable. Youcanchooseonefromseveralavailable
layout algorithms. . Youcandene e e.g. . thecolors,theshapes s of nodes,or thelinestyleof
edges,basedonthetypeofthegraphelements,orexcludeuninterestingtypesaltogetherfrom
thedisplay.Youcanpicktheattributesthataretobeshowndirectly(normallytheyareonly
displayedonmouse-over).Furthermore,youcancongurevisualgraphnesting bydeclaring
edges as containment edges,thus keeping large graphs withcontainment or treerelations
understandable. Forlargegraphs s thatarebeyondthe capabilitiesofthegraphvieweryou
can dene that t only y the matches plus s their r context t up p to a certain depth are displayed.
Altogether,youcantailorthegraphdisplaytowhatyouneed,transforminganunreadable
haystackwhichiswhatlargegraphstendtobecomeintoawell-readablerepresentation.
Online Convert Jpeg to PDF file. Best free online export Jpg image
Download Free Trial. Convert a JPG to PDF. Web Security. All your JPG and PDF files will be permanently erased from our servers after one hour.
convert pdf pages to jpg; .net pdf to jpg
Online Convert PDF to Jpeg images. Best free online PDF JPEG
Download Free Trial. Convert a PDF File to JPG. Web Security. Your PDF and JPG files will be deleted from our servers an hour after the conversion.
convert pdf file into jpg format; changing pdf to jpg
CHAPTER 3
QUICKSTART
Inthischapterwe’llbuildagraphrewritesystemfromscratch. WewilluseGrGen.NET
toconstructnon-deterministicstatemachines,andtoremove"-transitionsfromthem. This
chaptergivesaquicktourofGrGen.NETandtheprocessofusingit;itesp. highlightsits
lookandfeel.Forcomprehensivespecications,pleasetakealookatthesucceedingchapters.
3.1 Downloading&Installing
Ifyouarereadingthisdocument,youprobablyhavealreadydownloadedtheGrGen.NET
softwarefromourwebsite(http://www.grgen.net). Makesureyouhavethefollowingsys-
temrequirementsinstalledandavailableinthesearchpath:
 Java1.5orabove
 Mono1.2.3orabove/Microsoft.NET2.0orabove
Ifyou’reusingLinux: Unpackthepackagetoadirectoryofyourchoice,forexampleinto
/opt/grgen:
mkdir /opt/grgen
tarxvfjGrGenNET-V1_3_1-2007-12-06.tar.bz2
mv GrGenNET-V1_3_1-2007-12-06/*/opt/grgen/
rmdir GrGenNET-V1_3_1-2007-12-06
Addthe/opt/grgen/bindirectorytoyoursearchpaths,forinstanceifyouusebashadda
linetoyour/home/.profilele.
exportPATH=/opt/grgen/bin:$PATH
FurthermorewecreateadirectoryforourGrGen.NETdata,forinstancebymkdir /home/grgen.
Ifyou’reusingMicrosoftWindows: Extractthe.ziparchivetoadirectoryofyourchoice
andaddthebin subdirectorytoyour searchpathviacontrolpanel l !systemproperties /
environmentvariables. ExecutetheGrGen.NETassembliesfromacommandlinewindow
(Start !Run... !cmd). . ForMS.NETthemonoprexisneitherapplicablenorneeded.
NOTE(6)
You might be interested in the syntax highlighting specications of the e GrGen.NET-
languagessuppliedforthevim,Emacs,andNotepad++editorsinthesyntaxhighlighting
subdirectory.
19
C# Image Convert: How to Convert Adobe PDF to Jpeg, Png, Bmp, &
String inputFilePath = @"C:\input.pdf"; String outputFilePath = @"C:\output.jpg"; // Convert PDF to jpg. C# sample code for PDF to jpg image conversion.
change pdf into jpg; change pdf to jpg format
C# Image Convert: How to Convert Tiff Image to Jpeg, Png, Bmp, &
RasterEdge.XDoc.PDF.dll. String inputFilePath = @"C:\input.tif"; String outputFilePath = @"C:\output.jpg"; // Convert tiff to jpg.
convert multi page pdf to jpg; changing file from pdf to jpg
20
Quickstart
3.2 CreatingaGraphModel
Inthedirectory/home/grgenwecreateatextleStateMachine.gmthatcontainsthegraph
metamodelforourstatemachine
1
.Bygraphmetamodelwemeanasetofnodetypesand
edgetypeswhichareavailableforbuildingstatemachinegraphs(seeChapter 4).Figure3.1
showsthemetamodel.
1
nodeclassState{
2
id:int;
3
}
4
5
abstractnodeclassSpecialStateextendsState;
6
nodeclassStartStateextendsSpecialState;
7
nodeclassFinalStateextendsSpecialState;
8
nodeclassStartFinalStateextendsStartState,FinalState;
9
10
edgeclassTransition{
11
Trigger: string;
12
}
13
14
const edgeclassEpsilonTransitionextendsTransition;
Figure3.1:MetaModelforStateMachines
Whathavewedone?Wespeciedtwobasetypes,StateforstatenodesandTransition
for transition n edges s thatwillconnect the state nodes. . State e has an n integer r attribute id,
andTransitionhasastringattributeTriggerwhichindicates thecharacter sequencefor
switchingfromthesourcestatenodetothedestinationstatenode. Theothertypesinherit
fromthose basetypes (keyword extends). . Inheritance e works basically like inheritance in
objectorientedlanguages,asdoes the abstractmodierforSpecialState,meaningthat
youcannotcreateanodeofthatprecisetype(onlynodesofnon-abstractsubtypes). With
StartFinalStatewehaveconstructeda\diamond"typehierarchy,highlightingthesupport
formultipleinheritance.
3.3 CreatingGraphs
Let’stestourgraphmetamodelbycreatingastatemachinegraph.WewillusetheGrShell
(seeChapter20)and|forvisualization|yComp. Togeteverythingworkingweneedarule
setle,too. Forthemomentwe e justcreateanalmost emptyle removeEpsilons.grgin
the/home/grgendirectory,containingonlytheline
1
#using"StateMachine.gm"
Now,wecouldstartbylaunchingtheGrShellandbytypingthecommandsinteractively.
However,inmostofthecasesthisisnotthepreferredway,aswewanttoexecutethesame
stepsmultipletimes. Soinstead,wecreateaGrShellscriptremoveEpsilons.grs,inthe
/home/grgendirectory. Figure3.2showsthisscript. Runthescriptby y executing grshell
removeEpsilons.grs. Thersttimeyouexecutethescript,itmight t takeawhilebecause
GrGen.NEThastocompilethemetamodelandtherulesetinto.NETassemblies.
ThegraphvieweryCompopensandafterclickingtheblue\layoutgraph"buttononthe
veryrightsideofthebuttonbar,yougetawindowsimilartogure3.3(seealsoSection2.2.5).
QuityCompandexittheGrShellbytypingexit.
1
You’ll nd thesource code of this quick start example shipped with the GrGen.NET package in the
examples/FiniteStateMachine/directory.
JPEG to PDF Converter | Convert JPEG to PDF, Convert PDF to JPEG
similar software; Support a batch conversion of JPG to PDF with amazingly high speed; Get a compressed PDF file after conversion; Support
change file from pdf to jpg on; convert pdf file to jpg
JPG to JBIG2 Converter | Convert JPEG to JBIG2, Convert JBIG2 to
Image Converter Pro - JPEG to JBIG2 Converter. Convert JPEG (JPG) Images to, from JBIG2 Images on Windows.
convert pdf to 300 dpi jpg; convert pdf picture to jpg
3.3 CreatingGraphs
21
1
newgraphremoveEpsilons"StateMachineGraph"
2
3
new:StartState($=S,id=0)
4
new:FinalState($=F,id=3)
5
new:State($="1",id=1)
6
new:State($="2",id=2)
7
new@(S)-:Transition(Trigger="a")-> @("1")
8
new@("1")-:Transition(Trigger="b")-> @("2")
9
new@("2")-:Transition(Trigger="c")-> @(F)
10
new@(S)-:EpsilonTransition-> @("2")
11
new@("1")-:EpsilonTransition->@(F)
12
new@(S)-:EpsilonTransition-> @(F)
13
14
showgraphycomp
Figure3.2: ConstructingastatemachinegraphinGrShell
Figure3.3: Arststatemachine(with"-transitions)
JPG to GIF Converter | Convert JPEG to GIF, Convert GIF to JPG
Converter. Convert JPEG (JPG) Images to, from GIF Images on Windows. JPEG to GIF Converter can directly convert GIF files to JPG files.
change pdf to jpg on; pdf to jpg
JPG to DICOM Converter | Convert JPEG to DICOM, Convert DICOM to
Image Converter Pro - JPEG to DICOM Converter. Convert JPEG (JPG) Images to, from DICOM Images on Windows.
batch convert pdf to jpg online; c# pdf to jpg
22
Quickstart
OurscriptrstcreatesanemptygraphofthemetamodelStateMachine(whichisrefer-
encedbytherulesetremoveEpsilons.grg)withthenameStateMachineGraph.Thereafter,
itcreatesthenodesandedges,withaname:typecolonnotation{thenamesareoptionaland
missinghere. Notetheinplace-arrownotationforedges(-Edge->resp.-:EdgeType->). . As
youcansee,attributesofgraphelementscanbesetduringcreationwithacall-likesyntax.
The$and@notationisduetotheusageofpersistentnames. Persistentnamesareseton
creationby$=Identifierandusedlateronby@(Identifier)toretrievethegraphelement
boundtothem. Inadditiontopersistentnames,anotherkindof\names"isavailableinthe
GrShellwiththeglobalvariables,whichwouldappearbeforethecolon,butwedidnotuse
theminthisscript.Persistentnamesmustbeidentierstringsandnotnumbers,that’swhy
wehavetousethequotecharsaround"1"and"2".
3.4 TheRewriteRules
We will now add the real rewrite rules s to o the rule set le e removeEpsilons.grg. . The
ideais to\forward"normaltransitionsover"-transitionsone after another,i.e.ifwehave
apatternlikea:State -:EpsilonTransition-> b:State -ne:Transition-> c:Statedo
we add another a a -ne-> > c. . After r alltransitionshavebeenforwardedwe can n remove the
"-transitionsalltogether.Thecompleterulesetisshowningure3.4.SeeChapter5forthe
rulesetlanguagereference.
Let’sinspecttherulesetspecicationindetail:Therulesetleconsistsofanumberof
rulesandtests,eachofthembearinganame,likeforwardTransition. Rules s containa
patternspeciedbysemicolon-terminatedgraphlets,andarewritepartgivenwithanested
modifyorreplaceblock. Testscontainonlyapattern;they y areusedtocheckforacertain
patternwithoutdoinganyrewriteoperations.Ifaruleisapplied,GrGen.NETtriestond
thepatternwithinthehostgraph,forinstancewithinthegraphwecreatedinSection3.3.Of
coursetherecouldbeseveralmatchesforapattern|GrGen.NETwillchooseoneofthem
arbitrarily(technicallytherstmatchinanimplementationdenedorder).
Figure3.4alsodisplaysthesyntaxname:NodeTypefornodesand-name:EdgeType->for
Edges,whichwe havealreadyseeninSection3.3,againwithanoptionalname. . Buthere
the meaningof adeclaration n name:Type e depends onwhether itappearsin n the patternor
therewritepart. Adeclarationinthepatterndenesapatternelementthatistobebound
by searching, , resp. . matchinginthehost t graph, , whereas s adeclarationinthe rewritepart
denesanelementthatistobecreated(soonlythelatterdoesthesameasitscounterpart
fromtheshellscript). Anelementwithanameassignedtocanbereferenced d fromanother
graphlet,orfromtherewriteblock,bynotingdownsimplythenameforanode,orusingthe
syntax-name->foranedge(anamecanbereferencedinthesameornestedblocks). Ifyou
wantto\dosomething"withyourspeciedgraphelement\inanotherlocation"(whichmay
meansimplylinkinganodetoanotheredge),deneaname;otherwiseananonymousgraph
elementwillworkne(likethe:FinalStateor-:EpsilonTransistion->declarationsthat
willbeboundtoanodeoftypeFinalStateresp.anedgeoftypeEpsilonTransition,but
areinaccessibleforotheroperations).Alsohavealookatexample8onpage42foradditional
patternspecications.
Therewritepartcanbegiveninoneoftwomodes,modifymodeorreplacemode. In
replacemode,everygraphelementofthepatternwhichisnotreferencedwithinthereplace
blockisdeleted.Themodifymode,incontrast,deletesnothing(bydefault),butjustaddsor
keepsgraphelements. Instead,themodifypartallowsforexplicit t deletionofgraphelements
byusingadeletecommandinsidethemodifyblock.
Whatelsedoweuse?Weemploynegativepatterns;theypreventtheircontainingrule
fromgettingappliedifthenegativepatternisfound.Wealsouseattributeconditionsnoted
downinsideanif f...g g toexpress non-structuralconstraints;aruleis only applicableif
allsuchconditionsareevaluatedtotrue.Attributesofgraphelementsareaccessedwithdot
3.4 TheRewriteRules
23
1
#using"StateMachine.gm"
2
3
testcheckStartState{
4
x:StartState;
5
negative{
6
x;
7
y:StartState;
8
}
9
}
10
11
testcheckDoublettes{
12
negative{
13
x:State -e:Transition->y:State;
14
hom(x,y);
15
x -doublette:Transition-> y;
16
if{typeof(doublette) ==typeof(e);}
17
if{ ((typeof(e)==EpsilonTransition) || (e.Trigger ==doublette.Trigger)); }
18
}
19
}
20
21
ruleforwardTransition {
22
x:State-:EpsilonTransition-> y:State-e:Transition-> z:State;
23
hom(x,y,z);
24
negative{
25
x -exists:Transition-> z;
26
if{typeof(exists) == typeof(e);}
27
if{ ((typeof(e)==EpsilonTransition) || (e.Trigger ==exists.Trigger)); }
28
}
29
modify{
30
x -forward:typeof(e)-> z;
31
eval {forward.Trigger =e.Trigger;}
32
}
33
}
34
35
ruleaddStartFinalState{
36
x:StartState-:EpsilonTransition->:FinalState;
37
modify{
38
y:StartFinalState<x>;
39
emit("Start state (", , x.id, ") mutated into a start-and-final state");
40
}
41
}
42
43
ruleaddFinalState {
44
x:State-:EpsilonTransition-> :FinalState;
45
if{typeof(x)< SpecialState;}
46
modify{
47
y:FinalState<x>;
48
}
49
}
50
51
ruleremoveEpsilonTransition{
52
-:EpsilonTransition->;
53
replace{}
54
}
Figure3.4:Rulesetforremoving"-transitions
24
Quickstart
notation(as ine.Trigger). . Thehom(x,y) ) andhom(x,y,z) statements mean\matchthe
embracednodeshomomorphically",i.e.theycan(butdon’thaveto)bematchedtothesame
nodewithinthehostgraph.
Theeval f...gstatementintherewritepartisusedtoevaluateorrecalculateattributes
of graph h elements. . The e emit t statement t prints a a string to stdout. . Have e a a look k at the
statement y:StartFinalState<x> > in n addStartFinalState: : we e retype e the e node x. . That
meansthatthenewlycreatednodeycanbefoundatthepositionofxinthegraph,thatit
bearsitspersistentname,andthattheattributescommontothenewandtheprevioustype
keeptheiroldvalues{onlythenodetypeischangedorcastedtoStartFinalState.
3.5 ApplyingtheRules
Thecreatedrewriterulesarerewriteprimitives,wemustcomposetheminordertoimplement
morecomplexfunctionality. Forinstancewedon’twanttoforwardjustone e "-transitionas
forwardTransition would d do; we want t to forwardthem m all. . Such h arule compositionis
calledagraphrewritesequence (seeChapter9).Weaddthefollowinglinetoourshellscript
removeEpsilons.grs:
1
debug execcheckStartState&& !checkDoublettes && (forwardTransition*| addStartFinalState |
addFinalState* |removeEpsilonTransition* |true)
Thislookslikeabooleanexpressionandinfactitbehavessimilarly.Thewholeexpression
is evaluatedfromlefttoright. . Arule e is successfully evaluatedifa matchcouldbe found
(andisrewritten,butthiswon’tchangetheexecutionresult).Thenegationoperator! just
toggles theresult. . Werstcheckfor r avalidstate machine,i.e.if the hostgraphcontains
exactlyonestartstateandnoredundanttransitions. Thereafterwedotheactualrewriting.
These threesteps are connectedby lazy-evaluation-ands (&&), i.e. ifone of themfails the
evaluation will be canceled. . We e continue with disjunctively connected rules (by y |). . The
eageroperatorcausesallrulestogetexecuted,butonlyonemustndamatchtocountasa
success;thenaltrueensuresoverallsuccess. The*isusedtoapplytherulerepeatedlyas
longasamatchcanbefound.Thisincludesapplyingtherulezerotimes. Eveninthiscase
Rule*isstillsuccessful.
3.6 DebuggingandOutput
Ifyouexecute the modiedGrShellscript,GrGen.NETstarts its debugger. . Thisway
youcanfollowthe executionof thegraphrewritesequence stepbystep inyComp. . Just
play aroundwiththekeysd,s,andrinGrShell: : thed d keyletsyoufollowasinglerule
applicationinamatchingandarewritingstep,highlightingthefoundspotinthegraph;the
skeyjumpstothenextrule;andtherkeyrunstotheendofthegraphrewritesequence.
Aftersequenceexecution,youshouldseeagraphliketheoneinFigure3.5.
Ifeverythingisworkingneyoucandeletethedebugkeywordinfrontoftheexecand
just(re)usethis sequence as you u needto. . Maybeyouwant t to savea visualization n of the
resultinggraph. Thisispossiblebytypingdump graph h mygraph.vcginGrShell,whichis
thenwritingmygraph.vcgintothecurrentdirectoryintheVCGformatreadablebyyComp.
Oryouwanttosavetheresultinggraphassuch,tocontinueprocessinglateron. Sayexport
mygraph.grsinGrShellthen,itwillwritealecomposedofnewcommandsasisourinput
lefromFigure3.2,butcontainingthe"-freegraph.
FeelfreetobrowsetheexamplesfoldershipedwithGrGen.NET;havea look at the
successionofexamplesintheFiniteStateMachineandProgramGraphssubfolders,theygive
anoverviewovermostofthecapabilitiesofthesoftware.
3.6 DebuggingandOutput
25
Figure3.5:Astatemachinewithout"-transitions
26
Quickstart
Documents you may be interested
Documents you may be interested