root / framework / branches / dev / fuseboxLexiconCompiler.cfc

Revision 292, 4.4 kB (checked in by scorfield, 2 years ago)

Fixes #169 by changing copyright to TeraTech and adopting Apache Source License 2.0
(awaiting final confirmation from Michael Smith that ASL2.0 is acceptable).

Line 
1<!---
2Copyright 2006 TeraTech, Inc. http://teratech.com/
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15--->
16<cfcomponent output="false"
17                        hint="I compile a lexicon verb. I am created for each verb that needs to be compiled and I provide the thread-safe context in which that verb is compiled. That includes the various fb_* methods used to write to the parsed file.">
18
19        <cffunction name="init" returntype="any" access="public" output="false"
20                                hint="I am the constructor.">
21                <cfargument name="writer" type="any" required="false"
22                                        hint="I am the parsed file writer object. I am required but it's faster to specify that I am not required." />
23                <cfargument name="verbInfo" type="any" required="false"
24                                        hint="I am the verb compilation context. I am required but it's faster to specify that I am not required." />
25                <cfargument name="lexiconInfo" type="any" required="false"
26                                        hint="I am the lexicon definition that supports this verb. I am required but it's faster to specify that I am not required." />
27               
28                <cfset variables.fb_writer = arguments.writer />
29                <cfset variables.fb_ = structNew() />
30                <cfset variables.fb_.verbInfo = arguments.verbInfo />
31                <cfset variables.lexiconInfo = arguments.lexiconInfo />
32               
33                <cfreturn this />
34               
35        </cffunction>
36       
37        <cffunction name="compile" returntype="void" access="public" output="false"
38                                hint="I compile a lexicon verb by including its implementation file.">
39
40                <cfset var info = variables.lexiconInfo />
41                <cfset var lexiconFile = info.lexicon.path />
42               
43                <cfset lexiconFile = lexiconFile & info.verb />
44                <cfset lexiconFile = lexiconFile & "." & "cfm" />
45               
46                <cftry>
47                        <cfinclude template="#lexiconFile#" />
48                        <cfcatch type="missingInclude">
49                                <cfset fb_throw("fusebox.badGrammar.missingImplementationException",
50                                                                "Bad Grammar verb in circuit file",
51                                                                "The implementation file for the '#info.verb#' verb from the '#info.lexicon.namespace#'" &
52                                                                        " custom lexicon could not be found.  It is used in the '#variables.fb_.verbInfo.circuit#.#variables.fb_.verbInfo.fuseaction#' fuseaction.") />
53                        </cfcatch>
54                </cftry>
55               
56        </cffunction>
57       
58        <cffunction name="fb_appendLine" output="false" returntype="void"
59                                hint="I append a line to the parsed file.">
60                <cfargument name="lineContent" type="string" required="true"
61                                        hint="I am the line of text to append." />
62                <cfset variables.fb_writer.println(arguments.lineContent) />
63        </cffunction>
64       
65        <cffunction name="fb_appendIndent" output="false" returntype="void"
66                                hint="I am a no-op provided for backward compatibility.">
67        </cffunction>
68       
69        <cffunction name="fb_appendSegment" output="false" returntype="void"
70                                hint="I append a segment of text to the parsed file.">
71                <cfargument name="segmentContent" type="string" required="true"
72                                        hint="I am the segment of text to append." />
73                <cfset variables.fb_writer.print(segmentContent) />
74        </cffunction>
75       
76        <cffunction name="fb_appendNewline" output="false" returntype="void"
77                                hint="I append a newline to the parsed file.">
78                <cfset variables.fb_writer.println("") />
79        </cffunction>
80       
81        <cffunction name="fb_increaseIndent" output="false" returntype="void"
82                                hint="I am a no-op provided for backward compatibility.">
83        </cffunction>
84       
85        <cffunction name="fb_decreaseIndent" output="false" returntype="void"
86                                hint="I am a no-op provided for backward compatibility.">
87        </cffunction>
88       
89        <cffunction name="fb_throw" output="false" returntype="void"
90                                hint="I throw the specified exception.">
91                <cfargument name="type" type="string" required="true"
92                                        hint="I am the type of exception to throw." />
93                <cfargument name="message" type="string" required="true"
94                                        hint="I am the message to include in the thrown exception." />
95                <cfargument name="detail" type="string" required="true"
96                                        hint="I am the detail to include in the thrown exception." />
97               
98                <cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#" />
99
100        </cffunction>
101       
102</cfcomponent>
Note: See TracBrowser for help on using the browser.