Source Code Cross Referenced for SyntaxForm.java in  » Scripting » Kawa » kawa » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » Kawa » kawa.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package kawa.lang;
002:
003:        import gnu.expr.*;
004:        import gnu.mapping.Symbol;
005:        import java.io.*;
006:
007:        /** A "syntatic closure" - a syntax form with its compilation environment. */
008:
009:        public class SyntaxForm implements  Externalizable {
010:            public Object form;
011:
012:            public TemplateScope scope;
013:
014:            // PairPosition pos;
015:
016:            /*DEBUGGING:
017:            static int counter;
018:            int id = ++counter;
019:             */
020:
021:            private SyntaxForm() {
022:            }
023:
024:            public static SyntaxForm make(Object form, TemplateScope scope) {
025:                SyntaxForm sf = new SyntaxForm();
026:                sf.form = form;
027:                sf.scope = scope;
028:                return sf;
029:            }
030:
031:            public String toString() {
032:                return "#<syntax " + form
033:                ///* DEBUGGING:
034:                        // + " #" id +
035:                        + " in #" + scope.id
036:                        //*/
037:                        + ">";
038:            }
039:
040:            /** Make a SyntaxForm object with the same contextual information as this.
041:             * @param form which used for the new syntax value.
042:             * Corresponds to the <code>datum-&gt;syntax-object</code> function.
043:             */
044:            public SyntaxForm fromDatum(Object form) {
045:                SyntaxForm sf = new SyntaxForm();
046:                sf.form = form;
047:                sf.scope = this .scope;
048:                return sf;
049:            }
050:
051:            /** Create a syntax object with specified form, and given syntatic context.
052:             * Used to implement datum->syntax-object in the syntax-case API.
053:             * @param template If this is a SyntaxForm, use its scope;
054:             *   otherwise use the current Compilation's current scope.
055:             *   (This means just returning the form as-is.)
056:             * @param form The value (S-expression form) to use.
057:             */
058:            public static Object makeWithTemplate(Object template, Object form) {
059:                if (form instanceof  SyntaxForm)
060:                    return (SyntaxForm) form;
061:                if (template instanceof  SyntaxForm) {
062:                    SyntaxForm sform = (SyntaxForm) template;
063:                    if (form == sform.form)
064:                        return sform;
065:                    return sform.fromDatum(form);
066:                }
067:                return form;
068:            }
069:
070:            public SyntaxForm fromDatumIfNeeded(Object form) {
071:                if (form == this .form)
072:                    return this ;
073:                else if (form instanceof  SyntaxForm)
074:                    return (SyntaxForm) form;
075:                else
076:                    return fromDatum(form);
077:            }
078:
079:            public static Expression rewrite(Object x) {
080:                Translator tr = (Translator) Compilation.getCurrent();
081:                return tr.rewrite(x);
082:            }
083:
084:            public static Expression rewriteBody(Object x) {
085:                Translator tr = (Translator) Compilation.getCurrent();
086:                return tr.rewrite_body(x);
087:            }
088:
089:            public boolean isIdentifier() {
090:                return form instanceof  String || form instanceof  Symbol;
091:            }
092:
093:            public static boolean freeIdentifierEquals(SyntaxForm id1,
094:                    SyntaxForm id2) {
095:                Translator tr = (Translator) Compilation.getCurrent();
096:                return tr.lexical.lookup(id1.form, -1) == tr.lexical.lookup(
097:                        id2.form, -1);
098:            }
099:
100:            public void writeExternal(ObjectOutput out) throws IOException {
101:                out.writeObject(form);
102:                out.writeObject(scope);
103:            }
104:
105:            public void readExternal(ObjectInput in) throws IOException,
106:                    ClassNotFoundException {
107:                form = in.readObject();
108:                scope = (TemplateScope) in.readObject();
109:            }
110:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.