Changeset 87 in default
- Timestamp:
- 11/05/14 15:49:44 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/EbnfGenerator.xtend
r85 r87 22 22 import org.eclipse.xtext.generator.IGenerator 23 23 import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading 24 import org.eclipse.core.resources.ResourcesPlugin 24 25 25 26 /** … … 39 40 //generate pdf 40 41 var uri = (fsa as IFileSystemAccessExtension2).getURI(e.name + ".fo"); 41 var String fullUri = workspacePath + uri.path.substring(10, uri.path.length);42 var File file = new File(fullUri);43 42 var String relativePath = uri.path.substring(10); 43 var String realPath = ResourcesPlugin.getWorkspace().root.findMember(relativePath).rawLocation.toOSString; 44 var File file = new File(realPath); 44 45 if (file.exists) { 45 46 //true -> pdf, false -> rtf 46 47 47 48 if(mode){ 48 FoToPdfOrRtf.createRtfFromFo( fullUri.substring(0, fullUri.length - 3));49 FoToPdfOrRtf.createRtfFromFo(realPath.substring(0, realPath.length - 3)); 49 50 }else{ 50 FoToPdfOrRtf.createPdfFromFo( fullUri.substring(0, fullUri.length - 3));51 FoToPdfOrRtf.createPdfFromFo(realPath.substring(0, realPath.length - 3)); 51 52 } 52 53 … … 90 91 91 92 <fo:page-sequence master-reference="A4"> 92 <fo:flow flow-name="xsl-region-body" font-family=" verdana">93 <fo:flow flow-name="xsl-region-body" font-family="Monospaced" font-size="8pt"> 93 94 94 <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.95 <fo:block span="all" text-align="center" text-indent="1em" font-family="Monospaced" font-size="20pt" font-weight="bold" background-color="#EEEEEE" line-height="20mm">«bnf. 95 96 name»</fo:block> 96 97 … … 113 114 def compile(SectionHeading sHeading) ''' 114 115 115 <fo:block role="H1" font- weight="bold"> «sHeading.sectionHeader» </fo:block>116 <fo:block role="H1" font-family="SansSerif" font-size="12pt" line-height="2em"> «sHeading.sectionHeader» </fo:block> 116 117 117 118 ''' 118 119 119 def compile(Rule rule) ''' «System.out.println(rule.name)»<fo:block><fo:inline id="«rule.name»" color="purple">«IF rule.rulenumber != 0»«rule.120 def compile(Rule rule) '''<fo:block><fo:inline id="«rule.name»" color="black">«IF rule.rulenumber != 0»«rule. 120 121 rulenumber». «ENDIF»«rule.name»</fo:inline> ::= «rule.definitionList.compile»</fo:block>''' 121 122 122 def compile(DefinitionList dList) '''«IF dList!= null»«FOR sDef : dList.singleDefinition»«sDef.compile »«IF !sDef.equals(123 dList.singleDefinition.last)» 123 def compile(DefinitionList dList) '''«IF dList!= null»«FOR sDef : dList.singleDefinition»«sDef.compile+" "»«IF !sDef.equals( 124 dList.singleDefinition.last)»| «ENDIF»«ENDFOR»«ENDIF»''' 124 125 125 126 def compile(SingleDefinition sDefinition) '''«FOR term : sDefinition.terms»«term.compile»«ENDFOR»''' … … 127 128 def compile(Term term) '''«IF term.termAtom != null»«term.termAtom.compile»«ENDIF»«IF term.termOptionalSequence != 128 129 null»«term.termOptionalSequence.compile»«ENDIF»«IF term.termRepeatedSequence != null»«term.termRepeatedSequence. 129 compile»«ENDIF»«IF term.termGroupedSequence != null»«term.termGroupedSequence.compile»«ENDIF» '''130 compile»«ENDIF»«IF term.termGroupedSequence != null»«term.termGroupedSequence.compile»«ENDIF» ''' 130 131 131 def compile(GroupedSequence gSequ) ''' «FOR d : gSequ.definitionList»«d.compile»«ENDFOR»'''132 def compile(GroupedSequence gSequ) '''( «FOR d : gSequ.definitionList»«d.compile+" "»«ENDFOR» )''' 132 133 133 def compile(RepeatedSequence rSequ) '''{ «FOR d : rSequ.definitions»«d.compile»«ENDFOR»}«IF rSequ.morethanonce»+«ENDIF»'''134 def compile(RepeatedSequence rSequ) '''{ «FOR d : rSequ.definitions»«d.compile+" "»«ENDFOR» }«IF rSequ.morethanonce»+«ENDIF»''' 134 135 135 def compile(OptionalSequence oSequ) ''' («FOR d : oSequ.definitionList»«d.compile»«ENDFOR»)'''136 def compile(OptionalSequence oSequ) '''[ «FOR d : oSequ.definitionList»«d.compile+" "»«ENDFOR» ]''' 136 137 137 138 def compile(Atom atom) ''' 138 139 «IF atom.atomRuleReference != null»«atom.atomRuleReference.compile»«ENDIF»«IF atom.atomStringRule != null»«atom. 139 atomStringRule.compile»«ENDIF» '''140 atomStringRule.compile»«ENDIF» ''' 140 141 141 142 def compile(RuleReference rRef) '''<fo:basic-link internal-destination="«rRef.ruleref.name»" text-decoration="underline" color="blue">«rRef. 142 ruleref.name»</fo:basic-link> 143 ruleref.name»</fo:basic-link> ''' 143 144 144 def compile(StringRule sRule) '''«IF sRule.colon != null»«sRule.colon»«ENDIF»«IF sRule.literal != null»« sRule.145 literal. replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")» «ENDIF»'''145 def compile(StringRule sRule) '''«IF sRule.colon != null»«sRule.colon»«ENDIF»«IF sRule.literal != null»«'"'+sRule. 146 literal.trim.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+'"'» «ENDIF»''' 146 147 147 148 }
Note: See TracChangeset
for help on using the changeset viewer.