CFScriptify
Compile
mvn --quiet clean compile assembly:single
Maven 3 is assumed. For Mac users, it is available via homebrew.
The assembly:single
"goal" (from maven-assembly-plugin
) compiles
target/cfscriptify-0.0.1.jar
. This jar
is self-contained, ie. includes its
dependencies.
Usage
Reads CFML on stdin, writes cfscript to stdout.
echo '<cfset x = 1>' | java -jar target/cfscriptify-0.0.1.jar
# x = 1;
There's an optional bin/run.sh
that may be convenient for some people.
Sublime Text 2 Plugin
Nothing polished yet, but here's a starting point:
- Make sure the tests (described above) pass
- Tools -> New Plugin ..
- Paste in
src/main/sublime/cfscriptify.py
- Edit
cfs_path()
to return the path torun.sh
- Select some CFML
- Try your new plugin in sublime's python shell (ctrl-backtick)
view.run_command("cfscriptify")
- If it works, bind a key, eg.
{ "keys": ["ctrl+alt+super+s"], "command": "cfscriptify" }
Limitations
- Tags: Only the most common 20% of tags are supported (See Appendix A).
- Operators: Mixed-case, eg. CoNtAiNs, is legal in CFML, but not supported here.
Whitespace Output
- Line Endings: LF (but CR and CRLF are acceptable as input)
- Indentation: Tabs, but I'd welcome a pull request for spaces
Development
PRs welcome.
bin/test.rb [--skip-compile] [test numbers ..]
- Write a new test in
src/test
- Most changes start in
src/main/java/CFScriptifyListener.java
- Sometimes, we need to improve the ANTLR grammar,
src/main/antlr4/CFML.g4
References
- Adobe ColdFusion 10 documentation
- ANTLR 4 Runtime API
- ErrorType (ANTLR 4 Tool 4.1 API) (describes some runtime errors)
- ANTLR 4 and AST visitors
- ANTLR 4 tree inject/rewrite operator
- openbd.org
- /trunk/src/com/naryx/tagfusion/cfm/parser/CFML.g (ANTLR3 grammer)
- cftag2cfscript (similar project, but written in ColdFusion)
- Sublime Text 2
- Plugins - Sublime Text Unofficial Documentation
- randomize.py (example of replacing the selected text)
- Python - store output of subprocess.Popen call in a string
- Calling an external command in Python
- Left recursion
Appendix A: Supported CFML Tags
Supported (25)
cfabort cfbreak cfcatch cfcomponent cfcontent cfcontinue cfdefaultcase cfdump cfelse cfelseif cffinally cfheader cfif cfinclude cflocation cflock cflog cfparam cfrethrow cfreturn cfscript cfset cfsilent cfswitch cfthrow cftry
Partially supported (4)
cfargument is supported except that hint
and displayName
attributes are discarded, because the syntax for those attributes
is awkward in cfscript. I'd welcome a pull request.
cfcase is supported for single values. List values are not supported yet.
cffunction is supported for the following attributes:
name, access, and returnType. The output
attribute is
ignored, and all other attributes will cause an error.
cfloop is supported for list, array, and from/to/step. Support is planned for loop over query, structure, and condition. Loop over date range is rare, but wouldn't be too difficult to implement. Finally, loop over file is rare and has no convenient cfscript equivalent.
No Plans to Support (118)
These tags either do not have convenient cfscript equivalents, have complicated varients (eg. cffile), or are too rare to be worth the trouble. Pull requests, however, are welcome.
cfapplication cfassociate cfajaximport cfajaxproxy cfapplet cfcache cfcalendar cfchart cfchartdata cfchartseries cfcol cfcollection cfcookie cfdbinfo cfdirectory cfdiv cfdocument cfdocumentitem cfdocumentsection cferror cfexchangecalendar cfexchangeconnection cfexchangecontact cfexchangefilter cfexchangemail cfexchangetask cfexecute cfexit cffeed cffile cffileupload cfflush cfform cfformgroup cfformitem cfftp cfgrid cfgridcolumn cfgridrow cfgridupdate cfhtmlhead cfhttp cfhttpparam cfimage cfimap cfimport cfindex cfinput cfinsert cfinterface cfinvoke cfinvokeargument cflayout cflayoutarea cfldap cflogin cfloginuser cflogout cfmail cfmailparam cfmailpart cfmap cfmapitem cfmediaplayer cfmenu cfmenuitem cfmessagebox cfNTauthenticate cfobject cfobjectcache cfoutput cfpdf cfpdfform cfpdfformparam cfpdfparam cfpdfsubform cfpod cfpop cfpresentation cfpresentationslide cfpresenter cfprint cfprocessingdirective cfprocparam cfprocresult cfprogressbar cfproperty cfquery cfqueryparam cfregistry cfreport cfreportparam cfsavecontent cfschedule cfsearch cfselect cfsetting cfsharepoint cfslider cfspreadsheet cfsprydataset cfstoredproc cftable cftextarea cfthread cftimer cftooltip cftrace cftransaction cftree cftreeitem cfupdate cfwddx cfwindow cfxml cfzip cfzipparam