Java Doc for LispParser.java in  » Scripting » Jatha » org » jatha » read » 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 » Jatha » org.jatha.read 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jatha.read.LispParser

LispParser
public class LispParser (Code)
A parser that reads LISP-syntax text from a text stream or string. It recognizes all standard LISP datatypes, although not structured ones. This function is designed to fulfill the function of the reader in a LISP read-eval-print loop. Once the LISP parser is instantiated, the parse() function can be used to read from a string or stream. It is best not to instantiate the LispParser yourself. Instead, do the following:
 1.  LispParser parser = Jatha.getParser();
 2.  parser.setInputString(myString);
 3.  parser.setCaseSensitivity(LispParser.PRESERVE);
 4.  LispValue result = parser.parse();
 
Normal usage is to parse a string. If you want to use a Reader, do: new PushbackReader(myReader).
See Also:   org.jatha.dynatype.LispValue
author:
   Micheal S. Hewett
version:
   1.0


Field Summary
final static  charAT_SIGN
    
final static  charBACKSLASH
    
final static  charBACK_QUOTE
    
final static  charCOLON
    
final static  charCOMMA
    
final static  charDECIMAL
    
final static  charDOUBLE_QUOTE
    
final public static  intDOWNCASE
    
final static  charEQUAL_SIGN
    
final static  charHYPHEN
    
final static  charLEFT_ANGLE_BRACKET
    
final static  charLEFT_PAREN
    
final static  charOR_BAR
    
final static  charPERIOD
    
final static  charPOUND
    
final public static  intPRESERVE
    
final static  intREADING_BACKQUOTED_LIST
    
final static  intREADING_CHARACTER
    
final static  intREADING_MIXED_CASE_SYMBOL
    
final static  intREADING_NOTHING
    
final static  intREADING_STRING
    
final static  intREADING_SYMBOL
    
final static  charRIGHT_ANGLE_BRACKET
    
final static  charRIGHT_PAREN
    
final static  charSEMICOLON
    
final static  charSINGLE_QUOTE
    
final static  charUNDERSCORE
    
final public static  intUPCASE
    

Constructor Summary
public  LispParser(Jatha lisp, Reader inStream)
    
public  LispParser(Jatha lisp, String inString)
    
public  LispParser(Jatha lisp, Reader inStream, int caseSensitivity)
     Allows you to create a parser that handles input case conversion as you like. Default is UPCASE.
public  LispParser(Jatha lisp, String inString, int caseSensitivity)
     Allows you to create a parser that handles input case conversion as you like. Default is UPCASE.

Method Summary
 booleanINTEGER_token_p(String str)
    
 booleanNIL_token_p(String str)
    
 booleanREAL_token_p(String str)
     Does NOT recognize an isolated '+' or '-' as a real number.
 booleanSTRING_token_p(String str)
    
 booleanSYMBOL_token_p(String str)
    
 booleanT_token_p(String str)
    
public  LispValueapplyReaderMacro(PushbackReader stream)
     This routine is called by parse when it encounters a pound (#) mark.
public static  intfirstCharNotInSet(int startIndex, String str, String charSet)
     The equivalent of the C function 'strspn'. Given a string and another string representing a set of characters, this function scans the string and accepts characters that are elements of the given set of characters.
public  intgetCaseSensitivity()
     Retrieves the current case-sensitivity of the parser.
public  PushbackReadergetInputReader()
     Gets the current reader to be parsed.
public static  booleanhasBalancedParentheses(Jatha lisp, LispValue input)
    
public static  booleanhasBalancedParentheses(Jatha lisp, String input)
    
 booleanisAtSign(char x)
    
 booleanisBackQuote(char x)
    
 booleanisBackSlash(char x)
    
 booleanisColon(char x)
    
 booleanisComma(char x)
    
 booleanisDoubleQuote(char x)
    
 booleanisLeftAngleBracket(char x)
    
 booleanisLparen(char x)
    
 booleanisOrBar(char x)
    
 booleanisPeriod(char x)
    
 booleanisPound(char x)
    
 booleanisQuote(char x)
    
 booleanisRightAngleBracket(char x)
    
 booleanisRparen(char x)
    
 booleanisSemi(char x)
    
 booleanisSpace(char x)
    
 booleanisTerminator(char x)
    
public  LispValueparse()
     Parse() assumes that there is only one expression in the input string or file.
public  LispValueread()
     Reads one s-expression from the input stream (a string or file).
public  LispValueread_backquoted_list_token(PushbackReader stream)
     This library can't read backquotes yet.
public  LispValueread_backquoted_token(PushbackReader stream)
     This routine is called by parse when it encounters a backquote mark.
 LispValueread_comma_token(PushbackReader stream)
     This routine is called by parse when it encounters a comma, which is only legal inside a backquote.
public  LispValueread_list_token(PushbackReader stream)
     Reads one list expression from the input stream and returns it.
 LispValueread_quoted_token(PushbackReader stream)
     This routine is called by parse when it encounters a quote mark.
public  voidsetCaseSensitivity(int caseSensitivity)
     Sets the current case-sensitivity of the parser.
public  voidsetInputReader(PushbackReader inputReader)
     Sets the input reader for the Parser.
public  voidsetInputString(String s)
     Sets the input string for the parser.
public  voidsimple_parser_test()
    
public  voidtest_parser(String s)
    
public  voidtest_parser_loop()
    
public  LispValuetokenToLispValue(String token)
     Converts a string to a LISP value such as NIL, T, an integer, a real number, a string or a symbol.

Field Detail
AT_SIGN
final static char AT_SIGN(Code)



BACKSLASH
final static char BACKSLASH(Code)



BACK_QUOTE
final static char BACK_QUOTE(Code)



COLON
final static char COLON(Code)



COMMA
final static char COMMA(Code)



DECIMAL
final static char DECIMAL(Code)



DOUBLE_QUOTE
final static char DOUBLE_QUOTE(Code)



DOWNCASE
final public static int DOWNCASE(Code)



EQUAL_SIGN
final static char EQUAL_SIGN(Code)



HYPHEN
final static char HYPHEN(Code)



LEFT_ANGLE_BRACKET
final static char LEFT_ANGLE_BRACKET(Code)



LEFT_PAREN
final static char LEFT_PAREN(Code)



OR_BAR
final static char OR_BAR(Code)



PERIOD
final static char PERIOD(Code)



POUND
final static char POUND(Code)



PRESERVE
final public static int PRESERVE(Code)



READING_BACKQUOTED_LIST
final static int READING_BACKQUOTED_LIST(Code)



READING_CHARACTER
final static int READING_CHARACTER(Code)



READING_MIXED_CASE_SYMBOL
final static int READING_MIXED_CASE_SYMBOL(Code)



READING_NOTHING
final static int READING_NOTHING(Code)



READING_STRING
final static int READING_STRING(Code)



READING_SYMBOL
final static int READING_SYMBOL(Code)



RIGHT_ANGLE_BRACKET
final static char RIGHT_ANGLE_BRACKET(Code)



RIGHT_PAREN
final static char RIGHT_PAREN(Code)



SEMICOLON
final static char SEMICOLON(Code)



SINGLE_QUOTE
final static char SINGLE_QUOTE(Code)



UNDERSCORE
final static char UNDERSCORE(Code)



UPCASE
final public static int UPCASE(Code)




Constructor Detail
LispParser
public LispParser(Jatha lisp, Reader inStream)(Code)



LispParser
public LispParser(Jatha lisp, String inString)(Code)



LispParser
public LispParser(Jatha lisp, Reader inStream, int caseSensitivity)(Code)
Allows you to create a parser that handles input case conversion as you like. Default is UPCASE. Other values are DOWNCASE and PRESERVE.
Parameters:
  inStream -



LispParser
public LispParser(Jatha lisp, String inString, int caseSensitivity)(Code)
Allows you to create a parser that handles input case conversion as you like. Default is UPCASE. Other values are DOWNCASE and PRESERVE.




Method Detail
INTEGER_token_p
boolean INTEGER_token_p(String str)(Code)



NIL_token_p
boolean NIL_token_p(String str)(Code)



REAL_token_p
boolean REAL_token_p(String str)(Code)
Does NOT recognize an isolated '+' or '-' as a real number.



STRING_token_p
boolean STRING_token_p(String str)(Code)



SYMBOL_token_p
boolean SYMBOL_token_p(String str)(Code)



T_token_p
boolean T_token_p(String str)(Code)



applyReaderMacro
public LispValue applyReaderMacro(PushbackReader stream) throws EOFException(Code)
This routine is called by parse when it encounters a pound (#) mark.



firstCharNotInSet
public static int firstCharNotInSet(int startIndex, String str, String charSet)(Code)
The equivalent of the C function 'strspn'. Given a string and another string representing a set of characters, this function scans the string and accepts characters that are elements of the given set of characters. It returns the index of the first element of the string that is not a member of the set of characters. For example: pos = firstCharNotInSet(0, "hello there, how are you?", "ehlort "); returns 11. If the string does not contain any of the characters in the set, str.length() is returned.



getCaseSensitivity
public int getCaseSensitivity()(Code)
Retrieves the current case-sensitivity of the parser. It can be eiher LispParser.UPCASE, LispParser.DOWNCASE or LispParser.PRESERVE UPCASE, DOWNCASE or PRESERVE



getInputReader
public PushbackReader getInputReader()(Code)
Gets the current reader to be parsed.



hasBalancedParentheses
public static boolean hasBalancedParentheses(Jatha lisp, LispValue input)(Code)
Returns true if the input expression has balanced parentheses
Parameters:
  input - a String true if it has balanced parentheses



hasBalancedParentheses
public static boolean hasBalancedParentheses(Jatha lisp, String input)(Code)
Returns true if the input expression has balanced parentheses
Parameters:
  input - a String true if it has balanced parentheses



isAtSign
boolean isAtSign(char x)(Code)



isBackQuote
boolean isBackQuote(char x)(Code)



isBackSlash
boolean isBackSlash(char x)(Code)



isColon
boolean isColon(char x)(Code)



isComma
boolean isComma(char x)(Code)



isDoubleQuote
boolean isDoubleQuote(char x)(Code)



isLeftAngleBracket
boolean isLeftAngleBracket(char x)(Code)



isLparen
boolean isLparen(char x)(Code)



isOrBar
boolean isOrBar(char x)(Code)



isPeriod
boolean isPeriod(char x)(Code)



isPound
boolean isPound(char x)(Code)



isQuote
boolean isQuote(char x)(Code)



isRightAngleBracket
boolean isRightAngleBracket(char x)(Code)



isRparen
boolean isRparen(char x)(Code)



isSemi
boolean isSemi(char x)(Code)



isSpace
boolean isSpace(char x)(Code)



isTerminator
boolean isTerminator(char x)(Code)



parse
public LispValue parse() throws EOFException(Code)
Parse() assumes that there is only one expression in the input string or file. If you need to read multiple items from a string or file, use the read() function. Parse just calls read right now.
See Also:   LispParser.read



read
public LispValue read() throws EOFException(Code)
Reads one s-expression from the input stream (a string or file). Throws an EOFxception when EOF is reached. Call this method repeatedly to do read-eval-print on a file.



read_backquoted_list_token
public LispValue read_backquoted_list_token(PushbackReader stream)(Code)
This library can't read backquotes yet.



read_backquoted_token
public LispValue read_backquoted_token(PushbackReader stream) throws EOFException(Code)
This routine is called by parse when it encounters a backquote mark. It calls parse recursively.



read_comma_token
LispValue read_comma_token(PushbackReader stream) throws EOFException(Code)
This routine is called by parse when it encounters a comma, which is only legal inside a backquote.



read_list_token
public LispValue read_list_token(PushbackReader stream) throws EOFException(Code)
Reads one list expression from the input stream and returns it. The input pointer should be on the character following the left parenthesis.



read_quoted_token
LispValue read_quoted_token(PushbackReader stream) throws EOFException(Code)
This routine is called by parse when it encounters a quote mark. It calls parse recursively.



setCaseSensitivity
public void setCaseSensitivity(int caseSensitivity)(Code)
Sets the current case-sensitivity of the parser. It can be eiher LispParser.UPCASE, LispParser.DOWNCASE or LispParser.PRESERVE



setInputReader
public void setInputReader(PushbackReader inputReader)(Code)
Sets the input reader for the Parser.



setInputString
public void setInputString(String s)(Code)
Sets the input string for the parser. This is the String to parse.



simple_parser_test
public void simple_parser_test()(Code)



test_parser
public void test_parser(String s)(Code)



test_parser_loop
public void test_parser_loop() throws EOFException(Code)



tokenToLispValue
public LispValue tokenToLispValue(String token)(Code)
Converts a string to a LISP value such as NIL, T, an integer, a real number, a string or a symbol.



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.