Changeset 72 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de
- Timestamp:
- 06/15/14 08:59:05 (11 years ago)
- Location:
- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/formatting/EbnfFormatter.xtend
r65 r72 6 6 import com.google.inject.Inject 7 7 import de.ugoe.cs.swe.bnftools.services.EbnfGrammarAccess 8 import org.eclipse.xtext.Keyword9 8 import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter 10 9 import org.eclipse.xtext.formatting.impl.FormattingConfig 11 import org.eclipse.emf.ecore.EObject 12 import de.ugoe.cs.swe.bnftools.ebnf.Rule 13 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList 10 14 11 15 12 /** … … 38 35 39 36 40 // for (Keyword bar : f.findKeywords("|")) {41 //42 // c.setSpace("\n\t\t").before(bar);43 // }44 45 37 } 46 38 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/EbnfGenerator.xtend
r70 r72 24 24 import org.eclipse.xtext.generator.IFileSystemAccessExtension 25 25 import java.io.PrintWriter 26 26 27 /** 27 28 * Generates code from your model files on save. … … 30 31 */ 31 32 class EbnfGenerator implements IGenerator { 33 32 34 //generation of the xsl-file 33 35 override void doGenerate(Resource resource, IFileSystemAccess fsa) { 34 var String workspacePath = WorkspaceResolver.getWorkspace();36 var String workspacePath = WorkspaceResolver.getWorkspace(); 35 37 for (e : resource.allContents.toIterable.filter(EtsiBnf)) { 36 if (e.bnfEntry.size !=0) {37 38 39 40 var uri = (fsa as IFileSystemAccessExtension2).getURI(e.name+".fo");41 var String fullUri = workspacePath+uri.path.substring(10,uri.path.length);42 System.out.println(workspacePath +uri.path.substring(10,uri.path.length));38 if (e.bnfEntry.size != 0) { 39 fsa.generateFile(e.name + ".fo", e.compile) 40 41 //generate pdf 42 var uri = (fsa as IFileSystemAccessExtension2).getURI(e.name + ".fo"); 43 var String fullUri = workspacePath + uri.path.substring(10, uri.path.length); 44 System.out.println(workspacePath + uri.path.substring(10, uri.path.length)); 43 45 var File file = new File(fullUri); 44 System.out.println(file.exists); 45 // System.out.println(uri.toString()); 46 47 48 // System.out.println(file.exists); 49 50 // foToPdf.createPdfFromFo(file,aPath.substring(0,aPath.length-3)); 46 System.out.println(file.exists+ "," + fullUri.substring(0, fullUri.length - 3)); 47 48 if (file.exists) { 49 foToPdf.createPdfFromFo(fullUri.substring(0, fullUri.length - 3)); 50 } 51 51 } 52 52 } … … 54 54 55 55 // compile the different entities of the Bnf----------------------------------------------------------------------------- 56 def compile(EtsiBnf bnf) 57 ''' 56 def compile(EtsiBnf bnf) ''' 58 57 <?xml version="1.0"?> 59 58 <!-- fop «bnf.name».xml -rtf «bnf.name».rtf --> 60 59 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 61 60 62 61 <fo:layout-master-set> 63 64 65 62 <fo:simple-page-master master-name="A4" page-width="210mm" page-height="297mm"> 63 <fo:region-body region-name="xsl-region-body" margin="2cm"/> 64 </fo:simple-page-master> 66 65 </fo:layout-master-set> 67 66 … … 69 68 <fo:flow flow-name="xsl-region-body" font-family="verdana"> 70 69 71 <fo:block span="all" text-align="center" text-indent="1em" font-family="Arial" font-size="20pt" font-weight="bold" background-color="#EEEEEE" line-height="20mm">«bnf.name»</fo:block> 70 <fo:block span="all" text-align="center" text-indent="1em" font-family="Arial" font-size="20pt" font-weight="bold" background-color="#EEEEEE" line-height="20mm">«bnf. 71 name»</fo:block> 72 72 73 «FOR bnfentry :bnf.bnfEntry»73 «FOR bnfentry : bnf.bnfEntry» 74 74 «bnfentry.compile» 75 75 «ENDFOR» … … 77 77 </fo:page-sequence> 78 78 </fo:root>''' 79 80 def compile(BnfEntry bnfEntry) '''81 «IF bnfEntry.rule != null»82 79 80 def compile(BnfEntry bnfEntry) ''' 81 «IF bnfEntry.rule != null» 82 «bnfEntry.rule.compile» 83 83 «ENDIF» 84 84 ''' 85 86 def compile(Rule rule)'''<fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber!=0»«rule.rulenumber». «ENDIF»«rule.name»</fo:inline> ::= «rule.definitionList.compile»</fo:block>'''87 88 def compile(DefinitionList dList)'''«FOR sDef:dList.singleDefinition»«sDef.compile»«IF !sDef.equals(dList.singleDefinition.last)» | «ENDIF»«ENDFOR»'''89 90 def compile(SingleDefinition sDefinition)'''«FOR term:sDefinition.terms»«term.compile»«ENDFOR»'''91 92 def compile(Term term)'''«IF term.termAtom!=null»«term.termAtom.compile»«ENDIF»«IF term.termOptionalSequence!=null»«term.termOptionalSequence.compile»«ENDIF»«IF term.termRepeatedSequence!=null»«term.termRepeatedSequence.compile»«ENDIF»«IF term.termGroupedSequence!=null»«term.termGroupedSequence.compile»«ENDIF»'''93 94 def compile(GroupedSequence gSequ)'''«FOR d :gSequ.definitionList»«d.compile»«ENDFOR»'''95 85 96 def compile(RepeatedSequence rSequ)'''{«FOR d:rSequ.definitions»«d.compile»«ENDFOR»}«IF rSequ.morethanonce»+«ENDIF»''' 97 98 def compile(OptionalSequence oSequ)'''(«FOR d:oSequ.definitionList»«d.compile»«ENDFOR»)''' 99 100 def compile(Atom atom)''' 101 «IF atom.atomRuleReference!= null»«atom.atomRuleReference.compile»«ENDIF»«IF atom.atomStringRule!= null»«atom.atomStringRule.compile»«ENDIF»''' 102 103 def compile(RuleReference rRef)'''<fo:basic-link internal-destination="«rRef.ruleref.name»" text-decoration="underline" color="blue">«rRef.ruleref.name»</fo:basic-link> ''' 104 105 def compile(StringRule sRule)'''«IF sRule.colon!=null»«sRule.colon»«ENDIF»«IF sRule.literal!=null»«sRule.literal» «ENDIF»''' 106 107 86 def compile(Rule rule) '''<fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber != 0»«rule. 87 rulenumber». «ENDIF»«rule.name»</fo:inline> ::= «rule.definitionList.compile»</fo:block>''' 88 89 def compile(DefinitionList dList) '''«FOR sDef : dList.singleDefinition»«sDef.compile»«IF !sDef.equals( 90 dList.singleDefinition.last)» | «ENDIF»«ENDFOR»''' 91 92 def compile(SingleDefinition sDefinition) '''«FOR term : sDefinition.terms»«term.compile»«ENDFOR»''' 93 94 def compile(Term term) '''«IF term.termAtom != null»«term.termAtom.compile»«ENDIF»«IF term.termOptionalSequence != 95 null»«term.termOptionalSequence.compile»«ENDIF»«IF term.termRepeatedSequence != null»«term.termRepeatedSequence. 96 compile»«ENDIF»«IF term.termGroupedSequence != null»«term.termGroupedSequence.compile»«ENDIF»''' 97 98 def compile(GroupedSequence gSequ) '''«FOR d : gSequ.definitionList»«d.compile»«ENDFOR»''' 99 100 def compile(RepeatedSequence rSequ) '''{«FOR d : rSequ.definitions»«d.compile»«ENDFOR»}«IF rSequ.morethanonce»+«ENDIF»''' 101 102 def compile(OptionalSequence oSequ) '''(«FOR d : oSequ.definitionList»«d.compile»«ENDFOR»)''' 103 104 def compile(Atom atom) ''' 105 «IF atom.atomRuleReference != null»«atom.atomRuleReference.compile»«ENDIF»«IF atom.atomStringRule != null»«atom. 106 atomStringRule.compile»«ENDIF»''' 107 108 def compile(RuleReference rRef) '''<fo:basic-link internal-destination="«rRef.ruleref.name»" text-decoration="underline" color="blue">«rRef. 109 ruleref.name»</fo:basic-link> ''' 110 111 def compile(StringRule sRule) '''«IF sRule.colon != null»«sRule.colon»«ENDIF»«IF sRule.literal != null»«sRule. 112 literal» «ENDIF»''' 113 108 114 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/foToPdf.java
r70 r72 15 15 import javax.xml.transform.stream.StreamSource; 16 16 17 18 17 19 import org.apache.fop.apps.FOPException; 20 import org.apache.fop.apps.Fop; 18 21 import org.apache.fop.apps.FopFactory; 19 import org.apache.fop.apps.Fop;20 22 import org.apache.fop.apps.MimeConstants; 23 21 24 22 25 public class foToPdf { 23 26 24 public static void main(String args[]) throws IOException, FOPException,25 TransformerException {26 27 27 createfoFromPdf("test1","test1");28 }29 28 30 29 public static void createPdfFromFo(String fileName) throws IOException, FOPException, -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/validation/EbnfValidator.xtend
r66 r72 14 14 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList 15 15 import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition 16 import java.util.ArrayList17 16 import com.google.inject.Inject 18 17 import org.eclipse.xtext.resource.IResourceDescriptions
Note: See TracChangeset
for help on using the changeset viewer.