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


java.lang.Object
   fri.patterns.interpreter.parsergenerator.lexer.LexerImpl

LexerImpl
public class LexerImpl implements Lexer,StrategyFactoryMethod,Serializable(Code)
This Lexer must be created using LexerBuilder. It knows token and ignored terminals. To get this Lexer working the setTerminals() call must be called at least once. When using the Lexer standalone, the client must do this, else the Parser will call that method.

This lexer can be reused, but it can not be loaded with other syntaxes after it has been built for one.
author:
   (c) 2002, Fritz Ritzberger



Field Summary
protected  Strategystrategy
    

Constructor Summary
public  LexerImpl(List ignoredSymbols, Map charConsumers)
     Creates a Lexer from token- and ignored symbols, and a map of character consumers (built by LexerBuilder).
Parameters:
  ignoredSymbols - list of Strings containing ignored symbols to scan.
protected  LexerImpl()
     Do-nothing constructor for subclasses (currently unused).

Method Summary
public  voidaddTokenListener(Lexer.TokenListener tokenListener)
     Implements Lexer.
public  voidclear()
     Implements Lexer: Does nothing as no states are stored.
protected  TokencreateToken(String tokenIdentifier, ResultTree result, LexerSemantic lexerSemantic)
     Token factory method.
protected  TokencreateToken(String tokenIdentifier, String text, Token.Range range)
     Token factory method.
public  voiddump(PrintStream out)
     Outputs current and previous line, with line numbers.
public  intgetColumn()
     Returns the position within the current line, 0-n.
public  intgetLine()
     Returns the number of the current line, 1-n.
public  StringgetLineText()
     Returns the current line, as far as read.
public  TokengetNextToken(LexerSemantic lexerSemantic)
     This is an optional functionality of Lexer.
public  TokengetNextToken(Map expectedTokenSymbols)
     Implements Lexer: returns the next token from input, or EPSILON when no more input. This is called by the Parser to get the next syntax token from input. When returned token.symbol is null, no input could be recognized (ERROR).
Parameters:
  expectedTokenSymbols - contains the expected String token symbols (in keys),can be null when no Parser drives this Lexer.
public  intgetOffset()
     Returns the offset read so far from input.
public  booleanlex(LexerSemantic lexerSemantic)
     This is an optional functionality of Lexer.
protected  voidloopResultTree(ResultTree result, LexerSemantic lexerSemantic)
     After top-down lexing this method is called to dispatch all results.
public  StrategynewStrategy()
     Implements StrategyFactoryMethod.
public  voidremoveTokenListener(Lexer.TokenListener tokenListener)
     Implements Lexer.
public  voidsetCompeteForLongestInput(boolean competeForLongestInput)
     When false, the sort order (significance) of scan items without fixed start character decide what token is returned.
public  voidsetDebug(boolean debug)
     Implements Lexer: Set debug on to output information about scanned tokens.
public  voidsetInput(Object text)
     Implements Lexer: set the input to be scanned.
public  voidsetTerminals(List terminals)
     Implements Lexer: Parser call to pass all tokens symbols (all enclosed in `backquote`) and literals ("xyz").

Field Detail
strategy
protected Strategy strategy(Code)




Constructor Detail
LexerImpl
public LexerImpl(List ignoredSymbols, Map charConsumers)(Code)
Creates a Lexer from token- and ignored symbols, and a map of character consumers (built by LexerBuilder).
Parameters:
  ignoredSymbols - list of Strings containing ignored symbols to scan. These are NOT enclosed in `backquotes` like tokens.
Parameters:
  charConsumers - map with key = nonterminal and value = Consumer.



LexerImpl
protected LexerImpl()(Code)
Do-nothing constructor for subclasses (currently unused).




Method Detail
addTokenListener
public void addTokenListener(Lexer.TokenListener tokenListener)(Code)
Implements Lexer. Adds the passed token listener to listener list.



clear
public void clear()(Code)
Implements Lexer: Does nothing as no states are stored. This Lexer can not be loaded with new syntaxes.



createToken
protected Token createToken(String tokenIdentifier, ResultTree result, LexerSemantic lexerSemantic)(Code)
Token factory method. Can be overridden to access the lexing ResultTree. Delegates to createToken(tokenIdentifier, text, range).



createToken
protected Token createToken(String tokenIdentifier, String text, Token.Range range)(Code)
Token factory method. Can be overridden to convert token.text to some Java object.



dump
public void dump(PrintStream out)(Code)
Outputs current and previous line, with line numbers. Call this on ERROR.



getColumn
public int getColumn()(Code)
Returns the position within the current line, 0-n.



getLine
public int getLine()(Code)
Returns the number of the current line, 1-n.



getLineText
public String getLineText()(Code)
Returns the current line, as far as read.



getNextToken
public Token getNextToken(LexerSemantic lexerSemantic) throws IOException(Code)
This is an optional functionality of Lexer. It is NOT called by the Parser. It can be used for heuristic reading from an input (not knowing if there is more input after the token was read).

The passed LexerSemantic will receive every matched rule (top-down) together with its ResultTree. See lex() for details.
Parameters:
  lexerSemantic - the LexerSemantic to be called with every evaluated Rule and its lexing ResultTree. a Token with a terminal symbol and its instance text, or a Token with null symbol for error.




getNextToken
public Token getNextToken(Map expectedTokenSymbols) throws IOException(Code)
Implements Lexer: returns the next token from input, or EPSILON when no more input. This is called by the Parser to get the next syntax token from input. When returned token.symbol is null, no input could be recognized (ERROR).
Parameters:
  expectedTokenSymbols - contains the expected String token symbols (in keys),can be null when no Parser drives this Lexer. a Token with a terminal symbol and its instance text, or a Token with null symbol for error.



getOffset
public int getOffset()(Code)
Returns the offset read so far from input. This is an absolute offset, including newlines.



lex
public boolean lex(LexerSemantic lexerSemantic) throws IOException(Code)
This is an optional functionality of Lexer. It is NOT called by the Parser. It can be used to run a standalone Lexer with a LexerSemantic, processing a ready-scanned syntax tree. Other than with Parser Semantic no value stack is available for LexerSemantic, and all input will have been read when LexerSemantic is called with the built syntax tree.

The passed LexerSemantic will receive every matched rule (top-down) together with its results ResultTree, containing the range within input. ResultTree can be converted to text by calling resultTree.toString().

This method evaluates the input using end-of-input like a parser, that means it returns false if the input was either syntactically incorrect or EOF was not received when all rules have been evaluated.

MIND: This method does not call any TokenListener, as the LexerSemantic is expected to dispatch results!
Parameters:
  lexerSemantic - the LexerSemantic to be called with every evaluated Rule and its lexing ResultTree. true when lexer succeeded (input was syntactically ok), else false.




loopResultTree
protected void loopResultTree(ResultTree result, LexerSemantic lexerSemantic)(Code)
After top-down lexing this method is called to dispatch all results. Can be overridden to change dispatch logic. This method calls itself recursively with all result tree children. Nonterminals starting with "_" are ignored by default, as this marks artificial rules.
Parameters:
  result - lexer result, returns text on getText().
Parameters:
  semantic - semantic that dispatches the lexer results. a Token with the range and return of the Semantic call for this Rule/ResultTree.



newStrategy
public Strategy newStrategy()(Code)
Implements StrategyFactoryMethod. To be overridden to create a derived Strategy implementation.



removeTokenListener
public void removeTokenListener(Lexer.TokenListener tokenListener)(Code)
Implements Lexer. Removes the passed token listener from listener list.



setCompeteForLongestInput
public void setCompeteForLongestInput(boolean competeForLongestInput)(Code)
When false, the sort order (significance) of scan items without fixed start character decide what token is returned. When true (default), the scan item (without fixed start character) that scnas longest wins.



setDebug
public void setDebug(boolean debug)(Code)
Implements Lexer: Set debug on to output information about scanned tokens.



setInput
public void setInput(Object text) throws IOException(Code)
Implements Lexer: set the input to be scanned. If text is InputStream, no Reader will be used (characters will not be converted).
Parameters:
  text - text to scan, as String, StringBuffer, File, InputStream, Reader.



setTerminals
public void setTerminals(List terminals)(Code)
Implements Lexer: Parser call to pass all tokens symbols (all enclosed in `backquote`) and literals ("xyz").
Parameters:
  terminals - List of String containing "literals" and `lexertokens`.



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.