35 | | 'grammar'name=ID |
36 | | |
37 | | ( type='/__bnf__'?';' |
38 | | |
39 | | (importSection=!ImportSection)? |
40 | | |
41 | | (bnfEntry+=!BnfEntry)+ |
42 | | |
43 | | ) |
44 | | |
45 | | | |
46 | | |
47 | | ( type='/delta'';' |
48 | | |
49 | | (importSection=!ImportSection)? |
50 | | |
51 | | (deltaEntry+=!DeltaEntry)* |
52 | | |
53 | | ) |
54 | | |
55 | | | |
56 | | |
57 | | ( type='/merge'';' |
58 | | |
59 | | (importSection=!ImportSection)? |
60 | | |
61 | | (mergeEntry+=!MergeEntry)* |
62 | | |
63 | | ) |
| 35 | 'grammar'name=ID |
| 36 | |
| 37 | ( type='/__ bnf__ '?';' |
| 38 | |
| 39 | (importSection=!ImportSection )? |
| 40 | |
| 41 | (bnfEntry+=!BnfEntry )+ |
| 42 | |
| 43 | ) |
| 44 | |
| 45 | | |
| 46 | |
| 47 | ( type='/delta'' ;''' |
| 48 | |
| 49 | (importSection=!ImportSection )? |
| 50 | |
| 51 | (deltaEntry+=!DeltaEntry )* |
| 52 | |
| 53 | ) |
| 54 | |
| 55 | | |
| 56 | |
| 57 | ( type='/merge'' ;''' |
| 58 | |
| 59 | (importSection=!ImportSection )? |
| 60 | |
| 61 | (mergeEntry+=!MergeEntry )* |
| 62 | |
| 63 | ) |
81 | | ''' var''' List<!RuleReference > references = !EbnfAnalysisUtils .'' findReferences'' (rule); |
82 | | |
83 | | ''' var''' List<Rule> references1 = !EbnfAnalysisUtils .'' findReferences'' (rule,resourceDescriptions); |
84 | | |
85 | | ''' if''' ((references.size+references1.size ==0) && (rule.getRulenumber() !=1)) |
86 | | |
87 | | warning(''unusedRuleDescription'', !EbnfPackage$Literals::''RULE!__NAME'',''unusedRuleDescription'', rule.name); |
| 81 | ''' var''' List<!RuleReference > references = !EbnfAnalysisUtils .'' findReferences'' (rule); |
| 82 | |
| 83 | ''' var''' List<Rule> references1 = !EbnfAnalysisUtils .'' findReferences'' (rule,resourceDescriptions); |
| 84 | |
| 85 | ''' if''' ((references.size+references1.size ==0) && (rule.getRulenumber() !=1)) |
| 86 | warning(''unusedRuleDescription'', !EbnfPackage$Literals::''RULE!__NAME'',''unusedRuleDescription'', rule.name); |
123 | | ''' var''' Rule rule = element''' as''' Rule; |
124 | | |
125 | | ''' var''' IXtextDocument xtextDocument = context.getXtextDocument(); |
126 | | |
127 | | ''' var''' ICompositeNode node = !NodeModelUtils .'' findActualNodeFor'' (rule); |
128 | | |
129 | | ''' varint''' offset = node.textRegion.offset; |
130 | | |
131 | | ''' var''' String nodeText = node.text; |
132 | | |
133 | | ''' varint''' textLength = nodeText.length -2; |
| 122 | ''' var''' Rule rule = element''' as''' Rule; |
| 123 | |
| 124 | ''' var''' IXtextDocument xtextDocument = context.getXtextDocument(); |
| 125 | |
| 126 | ''' var''' ICompositeNode node = !NodeModelUtils .'' findActualNodeFor'' (rule); |
| 127 | |
| 128 | ''' varint''' offset = node.textRegion.offset; |
| 129 | |
| 130 | ''' var''' String nodeText = node.text; |
| 131 | |
| 132 | ''' varint''' textLength = nodeText.length -2; |
191 | | '''var'''String workspacePath = !WorkspaceResolver.''getWorkspace''(); |
192 | | |
193 | | '''for'''(e : resource.allContents.''toIterable''.''filter''(!EtsiBnf)) { |
194 | | |
195 | | '''if'''(e.bnfEntry.size !=0) { |
196 | | |
197 | | fsa.generateFile(e.name +".__fo__", e.compile) |
198 | | |
199 | | //generate__pdf__ |
200 | | |
201 | | '''var'''uri = (fsa'''as'''IFileSystemAccessExtension2).getURI(e.name +".__fo__"); |
202 | | |
203 | | '''var'''String fullUri = workspacePath + uri.path.substring(10, uri.path.length); |
204 | | |
205 | | '''var'''File file ='''new'''File(fullUri); |
206 | | |
207 | | '''if'''(file.exists) { |
208 | | |
209 | | foToPdf.''createPdfFromFo''(fullUri.substring(0, fullUri.length -3)); |
210 | | |
211 | | } |
212 | | |
213 | | } |
214 | | |
215 | | } |
| 189 | ''' var'''String workspacePath = !WorkspaceResolver.''getWorkspace''(); |
| 190 | |
| 191 | ''' for'''(e : resource.allContents.''toIterable''.''filter''(!EtsiBnf)) { |
| 192 | |
| 193 | ''' if'''(e.bnfEntry.size !=0) { |
| 194 | |
| 195 | fsa.generateFile(e.name +".__fo__", e.compile) |
| 196 | |
| 197 | //generate__pdf__ |
| 198 | |
| 199 | ''' var '''uri = (fsa'''as'''IFileSystemAccessExtension2).getURI(e.name +".__fo__"); |
| 200 | |
| 201 | ''' var '''String fullUri = workspacePath + uri.path.substring(10, uri.path.length); |
| 202 | |
| 203 | ''' var '''File file ='''new'''File(fullUri); |
| 204 | |
| 205 | ''' if'''(file.exists) { |
| 206 | |
| 207 | foToPdf.''createPdfFromFo''(fullUri.substring(0, fullUri.length -3)); |
| 208 | |
| 209 | } |
| 210 | |
| 211 | } |
| 212 | |
| 213 | } |
231 | | @Inject'''extension'''!EbnfGrammarAccess |
232 | | |
233 | | '''overrideprotectedvoid'''configureFormatting(!FormattingConfig c) { |
234 | | |
235 | | c.setLinewrap(0,1,2).before(SL_COMMENTRule) |
236 | | |
237 | | c.setLinewrap(0,1,2).before(ML_COMMENTRule) |
238 | | |
239 | | c.setLinewrap(0,1,1).after(ML_COMMENTRule) |
240 | | |
241 | | '''var'''!EbnfGrammarAccess f = getGrammarAccess'''as'''!EbnfGrammarAccess; |
242 | | |
243 | | c.setLinewrap.before(f.ruleRule); |
244 | | |
245 | | c.setLinewrap.before(f.importRule); |
246 | | |
247 | | c.setNoSpace.after(f.ruleAccess.rulenumberINTTerminalRuleCall_0_0_0) |
248 | | |
249 | | } |
| 229 | @Inject''' extension '''!EbnfGrammarAccess |
| 230 | |
| 231 | ''' override protected void'''configureFormatting(!FormattingConfig c) { |
| 232 | |
| 233 | c.setLinewrap(0,1,2).before(SL_COMMENTRule) |
| 234 | |
| 235 | c.setLinewrap(0,1,2).before(ML_COMMENTRule) |
| 236 | |
| 237 | c.setLinewrap(0,1,1).after(ML_COMMENTRule) |
| 238 | |
| 239 | ''' var '''!EbnfGrammarAccess f = getGrammarAccess''' as '''!EbnfGrammarAccess; |
| 240 | |
| 241 | c.setLinewrap.before(f.ruleRule); |
| 242 | |
| 243 | c.setLinewrap.before(f.importRule); |
| 244 | |
| 245 | c.setNoSpace.after(f.ruleAccess.rulenumberINTTerminalRuleCall_0_0_0) |
| 246 | |
| 247 | } |
339 | | <menuContributionlocationURI="!popup:org.eclipse.jdt.ui.PackageExplorer"> |
340 | | |
341 | | <command |
342 | | |
343 | | commandId="de.ugoe.cs.swe.bnftools.ui.handler.!GenerationCommand" |
344 | | |
345 | | style="push"> |
346 | | |
347 | | <visibleWhen |
348 | | |
349 | | checkEnabled="false"> |
350 | | |
351 | | <iterate> |
352 | | |
353 | | <adapttype="org.eclipse.core.resources.IResource"> |
354 | | |
355 | | <testproperty="org.eclipse.core.resources.name" |
356 | | |
357 | | value="*.bnf"/> |
358 | | |
359 | | </adapt> |
360 | | |
361 | | </iterate> |
362 | | |
363 | | </visibleWhen> |
364 | | |
365 | | </command> |
| 337 | <menuContributionlocationURI="!popup:org.eclipse.jdt.ui.PackageExplorer"> |
| 338 | |
| 339 | <command |
| 340 | |
| 341 | commandId="de.ugoe.cs.swe.bnftools.ui.handler.!GenerationCommand" |
| 342 | |
| 343 | style="push"> |
| 344 | |
| 345 | <visibleWhen |
| 346 | |
| 347 | checkEnabled="false"> |
| 348 | |
| 349 | <iterate> |
| 350 | |
| 351 | <adapttype="org.eclipse.core.resources.IResource"> |
| 352 | |
| 353 | <testproperty="org.eclipse.core.resources.name" |
| 354 | |
| 355 | value="*.bnf"/> |
| 356 | |
| 357 | </adapt> |
| 358 | |
| 359 | </iterate> |
| 360 | |
| 361 | </visibleWhen> |
| 362 | |
| 363 | </command> |
379 | | '''public'''Object execute(!ExecutionEvent event)'''throws'''!ExecutionException { |
380 | | |
381 | | ISelection selection = !HandlerUtil.''getCurrentSelection''(event); |
382 | | |
383 | | ''' if'''(selection'''instanceof'''IStructuredSelection) { |
384 | | |
385 | | IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
386 | | |
387 | | Object firstElement = structuredSelection.getFirstElement(); |
388 | | |
389 | | ''' if'''(firstElement'''instanceof'''IFile) { |
390 | | |
391 | | IFile file = (IFile) firstElement; |
392 | | |
393 | | IProject project = file.getProject(); |
394 | | |
395 | | IFolder srcGenFolder = project.getFolder("src-gen"); |
396 | | |
397 | | ''' if'''(!srcGenFolder.exists()) { |
398 | | |
399 | | ''' try'''{ |
400 | | |
401 | | srcGenFolder.create('''true''','''true''','''new'''!NullProgressMonitor()); |
402 | | |
403 | | }'''catch'''(!CoreException e) { |
404 | | |
405 | | ''' returnnull'''; |
406 | | |
407 | | } |
408 | | |
409 | | } |
410 | | |
411 | | ''' final'''!EclipseResourceFileSystemAccess2 fsa =fileAccessProvider.get(); |
412 | | |
413 | | fsa.setOutputPath(srcGenFolder.getFullPath().toString()); |
414 | | |
415 | | URI uri = URI.''createPlatformResourceURI''(file.getFullPath().toString(),'''true'''); |
416 | | |
417 | | !ResourceSet rs =resourceSetProvider.get(project); |
418 | | |
419 | | Resource r = rs.getResource(uri,'''true'''); |
420 | | |
421 | | generator.doGenerate(r, fsa); |
422 | | |
423 | | } |
424 | | |
425 | | } |
426 | | |
427 | | ''' returnnull'''; |
| 377 | '''public '''Object execute(!ExecutionEvent event) '''throws '''!ExecutionException { |
| 378 | |
| 379 | ISelection selection = !HandlerUtil.''getCurrentSelection''(event); |
| 380 | |
| 381 | ''' if'''(selection''' instanceof '''IStructuredSelection) { |
| 382 | |
| 383 | IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
| 384 | |
| 385 | Object firstElement = structuredSelection.getFirstElement(); |
| 386 | |
| 387 | ''' if'''(firstElement '''instanceof''' IFile) { |
| 388 | |
| 389 | IFile file = (IFile) firstElement; |
| 390 | |
| 391 | IProject project = file.getProject(); |
| 392 | |
| 393 | IFolder srcGenFolder = project.getFolder("src-gen"); |
| 394 | |
| 395 | ''' if'''(!srcGenFolder.exists()) { |
| 396 | |
| 397 | ''' try'''{ |
| 398 | |
| 399 | srcGenFolder.create('''true''','''true''','''new'''!NullProgressMonitor()); |
| 400 | |
| 401 | }'''catch'''(!CoreException e) { |
| 402 | |
| 403 | ''' returnnull'''; |
| 404 | |
| 405 | } |
| 406 | |
| 407 | } |
| 408 | |
| 409 | ''' final'''!EclipseResourceFileSystemAccess2 fsa =fileAccessProvider.get(); |
| 410 | |
| 411 | fsa.setOutputPath(srcGenFolder.getFullPath().toString()); |
| 412 | |
| 413 | URI uri = URI.''createPlatformResourceURI''(file.getFullPath().toString(),'''true'''); |
| 414 | |
| 415 | !ResourceSet rs =resourceSetProvider.get(project); |
| 416 | |
| 417 | Resource r = rs.getResource(uri,'''true'''); |
| 418 | |
| 419 | generator.doGenerate(r, fsa); |
| 420 | |
| 421 | } |
| 422 | |
| 423 | } |
| 424 | |
| 425 | ''' returnnull'''; |