Java Doc for SerializedLexer.java in  » Parser » runcc » fri » patterns » interpreter » parsergenerator » builder » 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 » Parser » runcc » fri.patterns.interpreter.parsergenerator.builder 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   fri.patterns.interpreter.parsergenerator.builder.SerializedObject
      fri.patterns.interpreter.parsergenerator.builder.SerializedLexer

SerializedLexer
public class SerializedLexer extends SerializedObject (Code)
Buffering Lexers. SerializedLexer will build the Lexer from scratch only the first time. Every following call will load the serialized Lexer from filesystem.

The time to build a lexer from scratch is equal to deserializing it in most cases. So a standalone lexer can be built without this class. When needed for a Parser, use the SerializedParser factory!

This factory will separate the passed syntax into parser and lexer syntax if token and ignored symbol Lists are null. So take care to use "token" and "ignored" rules within syntax to achieve the desired result!

Example (syntax input from a file):

 File ebnfFile = ...;
 Lexer lexer = new SerializedLexer().get(ebnfFile);
 
or (syntax input from a Reader, must pass a filename):
 Reader ebnfReader = ...;
 Lexer lexer = new SerializedLexer().get(ebnfReader, "MyLexer.ser");
 

author:
   (c) 2002, Fritz Ritzberger


Field Summary
protected  booleanPRODUCTION
    

Constructor Summary
public  SerializedLexer()
     Create a Lexer factory that caches built Lexers.
public  SerializedLexer(boolean production)
     Create a Lexer factory that caches built Lexers.

Method Summary
public  LexerbuildAndStoreLexer(Object syntaxInput, String baseName, List tokenSymbols, List ignoredSymbols)
     Builds a lexer from passed syntax and stores it to a File (when PRODUCTION is true, this is default).
public  Lexerget(Object syntaxInput)
     Builds the Lexer from scratch if not found in filesystem, else loads the serialized Lexer.
Parameters:
  syntaxInput - the Lexer syntax as File, InputStream, List of Lists, String [][] or Syntax.
public  Lexerget(Object syntaxInput, String baseName)
     Builds the Lexer from scratch if not found in filesystem, else loads the serialized Lexer.
public  Lexerget(Object syntaxInput, String baseName, List tokenSymbols, List ignoredSymbols)
     Builds the Lexer from scratch if not found in filesystem, else loads the serialized Lexer.
public  SyntaxSeparationgetSyntaxSeparation()
     If the lexer was built from scratch, the SyntaxSeparation object returned will not be null and can be used to retrieve the parser syntax, else null is returned, as the separation is not available in serialized Lexer.
public static  voidmain(String[] args)
     Test main.
protected  LexerBuildernewLexerBuilder(Syntax syntax, List ignoredSymbols)
     To be overridden when a modified LexerBuilder is needed.
protected  SyntaxSeparationnewSyntaxSeparation(Syntax syntax)
     To be overridden when a modified SyntaxSeparation is needed.
public  LexerreadLexer(Object syntaxInput, String baseName)
     Tries to read the lexer from a serialized file.

Field Detail
PRODUCTION
protected boolean PRODUCTION(Code)




Constructor Detail
SerializedLexer
public SerializedLexer()(Code)
Create a Lexer factory that caches built Lexers.



SerializedLexer
public SerializedLexer(boolean production)(Code)
Create a Lexer factory that caches built Lexers. @param production when false the Lexer will not be serialized.




Method Detail
buildAndStoreLexer
public Lexer buildAndStoreLexer(Object syntaxInput, String baseName, List tokenSymbols, List ignoredSymbols) throws Exception(Code)
Builds a lexer from passed syntax and stores it to a File (when PRODUCTION is true, this is default).
Parameters:
  syntaxInput - the lexer syntax input
Parameters:
  baseName - a file basename, if "Xml", the file "XmlLexer.ser" will be written



get
public Lexer get(Object syntaxInput) throws Exception(Code)
Builds the Lexer from scratch if not found in filesystem, else loads the serialized Lexer.
Parameters:
  syntaxInput - the Lexer syntax as File, InputStream, List of Lists, String [][] or Syntax. deserialized Lexer, or one built from scratch that gets written to filesystem.



get
public Lexer get(Object syntaxInput, String baseName) throws Exception(Code)
Builds the Lexer from scratch if not found in filesystem, else loads the serialized Lexer.
Parameters:
  syntaxInput - the Lexer syntax as File, InputStream, List of Lists, String [][] or Syntax.
Parameters:
  baseName - name of serialization file, can be null when syntaxInput is a File deserialized Lexer, or one built from scratch that gets written to filesystem.



get
public Lexer get(Object syntaxInput, String baseName, List tokenSymbols, List ignoredSymbols) throws Exception(Code)
Builds the Lexer from scratch if not found in filesystem, else loads the serialized Lexer.
Parameters:
  syntaxInput - the Lexer syntax as File, InputStream, List of Lists, String [][] or Syntax.
Parameters:
  baseName - name of serialization file, can be null when syntaxInput is a File
Parameters:
  tokenSymbols - the token symbols when used by a prebuilt Parser
Parameters:
  ignoredSymbols - the ignored symbols when used by a prebuilt Parser deserialized Lexer, or one built from scratch that gets written to filesystem.



getSyntaxSeparation
public SyntaxSeparation getSyntaxSeparation()(Code)
If the lexer was built from scratch, the SyntaxSeparation object returned will not be null and can be used to retrieve the parser syntax, else null is returned, as the separation is not available in serialized Lexer.



main
public static void main(String[] args)(Code)
Test main. Building serialized Lexer takes 330, building from scratch takes 130 millis.



newLexerBuilder
protected LexerBuilder newLexerBuilder(Syntax syntax, List ignoredSymbols) throws LexerException, SyntaxException(Code)
To be overridden when a modified LexerBuilder is needed.



newSyntaxSeparation
protected SyntaxSeparation newSyntaxSeparation(Syntax syntax) throws SyntaxException(Code)
To be overridden when a modified SyntaxSeparation is needed.



readLexer
public Lexer readLexer(Object syntaxInput, String baseName)(Code)
Tries to read the lexer from a serialized file. One of the two arguments must be non-null.
Parameters:
  syntaxInput - the lexer syntax input to retrieve a default name when it is a File
Parameters:
  baseName - if baseName is "Xml", the file "XmlLexer.ser" will be read, can be null



Methods inherited from fri.patterns.interpreter.parsergenerator.builder.SerializedObject
public static String baseNameFromSyntax(Object syntaxInput)(Code)(Java Doc)
protected String ensureDirectory(String fileName)(Code)(Java Doc)
protected String makeFilePath(String fileName)(Code)(Java Doc)
protected Object read(String fileName)(Code)(Java Doc)
public static Syntax toSyntax(Object syntaxInput) throws Exception(Code)(Java Doc)
protected boolean write(String fileName, Object o)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.