summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2007-07-13 17:03:14 +0000
committerRich Hickey <richhickey@gmail.com>2007-07-13 17:03:14 +0000
commit3ed3682254f22b1bfbc45ee72b49b80fe995e990 (patch)
treeab56df827794b3729c8c4b340ce27560cef879d1 /src
parent1b68f771ed620a7fee62551c0959496168b1cd9d (diff)
first cut at ANTLR-based Reader
Diffstat (limited to 'src')
-rw-r--r--src/jvm/Reader.g328
-rw-r--r--src/jvm/clojure/lang/ReaderLexer.java2388
-rw-r--r--src/jvm/clojure/lang/ReaderParser.java2072
3 files changed, 4788 insertions, 0 deletions
diff --git a/src/jvm/Reader.g b/src/jvm/Reader.g
new file mode 100644
index 00000000..4b0a13b5
--- /dev/null
+++ b/src/jvm/Reader.g
@@ -0,0 +1,328 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ **/
+
+grammar Reader;
+options { language=Java; backtrack=true; memoize=true;}
+@header {
+package clojure.lang;
+import java.math.BigInteger;
+import java.io.Writer;
+import java.io.PrintWriter;
+}
+@lexer::header {
+
+ package clojure.lang;
+}
+@lexer::members{
+ RecognitionException rex = null;
+
+ public void recover(RecognitionException re) {
+ super.recover(re);
+ if(rex == null)
+ rex = re;
+ }
+
+ public void reportError(RecognitionException e) {
+ if(rex == null)
+ rex = e;
+ }
+}
+
+@members{
+//add these lines to expressions, dotExpression, args
+// in the e=expression(); case
+//after:
+// if (failed) return val;
+
+/*WARNING- HAND MODIFIED!
+if(es == null) es = new ArrayList();
+es.add(e);
+// END HAND MODIFIED*/
+
+//add this to mapexpr:
+/*WARNING- HAND MODIFIED!
+ val = val.assoc(k, v);
+// END HAND MODIFIED*/
+
+final static Symbol DOTDOT = new Symbol("..");
+
+public static void main(String[] args) throws Exception {
+Writer w = new PrintWriter(System.out);
+// Create an input character stream from standard in
+CharStream input = new ANTLRFileStream(args[0]);
+// Create an ExprLexer that feeds from that stream
+ReaderLexer lexer = new ReaderLexer(input);
+// Create a stream of tokens fed by the lexer
+CommonTokenStream tokens = new CommonTokenStream(lexer);
+// Create a parser that feeds off the token stream
+ReaderParser parser = new ReaderParser(tokens);
+// Begin parsing at rule prog, get return value structure
+try{
+ if(lexer.rex != null)
+ throw lexer.rex;
+ for(int i=0;i<10;i++)
+ {
+ Object e = parser.expression();
+ RT.print(e,w);
+ w.write('\n');
+ w.flush();
+ }
+ }
+catch(RecognitionException rex)
+ {
+ System.err.printf("Error parsing at line: \%d, col: \%d",rex.line,rex.charPositionInLine);
+ }
+}
+
+protected void mismatch(IntStream input, int ttype, BitSet follow)
+throws RecognitionException
+{
+throw new MismatchedTokenException(ttype, input);
+}
+public void recoverFromMismatchedSet(IntStream input,
+RecognitionException e,
+BitSet follow)
+throws RecognitionException
+{
+throw e;
+}
+
+
+}
+
+@rulecatch {
+catch (RecognitionException exc) {
+throw exc;
+}
+}
+
+expression returns[Object val]
+ : lt = literal {$val = $lt.val;}
+ |s = symbol {$val = $s.val;}
+ |k = keyword {$val = $k.val;}
+ |le = listExpression {$val = $le.val;}
+ |ve = vectorExpression {$val = $ve.val;}
+ |me = mapExpression {$val = $me.val;}
+ |mx = metaExpression {$val = $mx.val;}
+ |g = dotExpression {$val = $g.val;}
+ ;
+
+listExpression returns[ISeq val]
+ : '(' es = expressions ')' {$val = es!=null?RT.seq(es):PersistentList.EMPTY;}
+ ;
+
+fragment expressions returns[List es]
+ : e = expression*
+ ;
+
+vectorExpression returns[IPersistentArray val]
+ : '[' es = expressions ']' {$val = es!=null?RT.tuple(es.toArray()):PersistentVector.EMPTY;}
+ ;
+
+mapExpression returns[IPersistentMap val]
+@init{
+val = PersistentHashMap.EMPTY;
+}
+ : '{' (k=expression v=expression)* '}'
+ ;
+
+symbol returns[Symbol val]
+ :n = (Identifier|JavaIdentifier) {$val = new Symbol($n.text);}
+ |ns = (Identifier|JavaIdentifier) '/' nn = (Identifier|JavaIdentifier) {$val = new Symbol($ns.text,$nn.text);}
+ |dd = DotDot {$val = DOTDOT;}
+ ;
+
+keyword returns[Keyword val]
+ :':' s = symbol {$val = new Keyword($s.val);}
+ ;
+
+
+literal returns[Object val]
+ :i = integerLiteral {$val=$i.val;}
+ |fp = FloatingPointLiteral {$val=Num.from(Double.valueOf($fp.text));}
+ |c = CharacterLiteral {$val=$c.text.charAt(0);}
+ |s = StringLiteral {$val=$s.text.substring(1,s.getText().length()-1);}
+ |TrueToken {$val=Boolean.TRUE;}
+ |NullToken {$val=null;}
+ |r = ratioLiteral {$val=$r.val;}
+ ;
+
+ratioLiteral returns[Num val]
+ : n = DecimalLiteral '/' d = DecimalLiteral {$val = Num.divide(new BigInteger($n.text),new BigInteger($d.text));}
+ ;
+
+integerLiteral returns[Num val]
+ : hn = HexLiteral {$val = Num.from(new BigInteger($hn.text.substring(2),16));}
+ | on = OctalLiteral {$val = Num.from(new BigInteger($on.text.substring(1),8));}
+ | nn = DecimalLiteral {$val = Num.from(new BigInteger($nn.text));}
+ ;
+
+
+
+fragment
+metaTag returns[IPersistentMap val]
+ :'#^' s = symbol {$val = RT.map(RT.TAG_KEY,$s.val);}
+ |'#^' m = mapExpression {$val = $m.val;}
+ ;
+
+fragment
+objExpression returns[Obj val]
+ :s = symbol {$val = $s.val;}
+ |le = listExpression {$val = (Obj)$le.val;}
+ |me = mapExpression {$val = (Obj)$me.val;}
+ |ve = vectorExpression {$val = (Obj)$ve.val;}
+ ;
+
+metaExpression returns [Obj val]
+ :m = metaTag e = objExpression {$val = $e.val.withMeta($m.val);}
+ ;
+
+fragment
+member returns [Object val]
+ : '.' i = JavaIdentifier {$val = new Symbol($i.text);}
+ | '.' m = method {$val = $m.val;}
+ ;
+
+fragment
+method returns [Object val]
+ : i = MethodIdentifier es = args? ')' {$val = RT.cons(new Symbol($i.text.substring(0,$i.text.length()-1)), es);}
+ ;
+
+fragment args returns[ISeq val]
+@init{
+List es = null;
+}
+ : e1 = expression (Comma e = expression)* {$val = RT.cons(e1,es!=null?RT.seq(es):null);}
+ ;
+
+dotExpression returns [Object val]
+@init{
+List es = null;
+}
+ :s = symbol e = member+ {$val = RT.listStar(DOTDOT,s,RT.seq(es));}
+ ;
+// LEXER
+Comma : ',';
+TrueToken : 'true';
+
+NullToken : 'null' ;
+
+DotDot : '..';
+
+HexLiteral : '0' ('x'|'X') HexDigit+;
+
+DecimalLiteral : ('0' | '1'..'9' '0'..'9'*);
+
+OctalLiteral : '0' ('0'..'7')+;
+
+fragment
+HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+FloatingPointLiteral
+ : ('0'..'9')+ '.' ('0'..'9')* Exponent? FloatTypeSuffix?
+ | '.' ('0'..'9')+ Exponent? FloatTypeSuffix?
+ | ('0'..'9')+ Exponent FloatTypeSuffix?
+ | ('0'..'9')+ Exponent? FloatTypeSuffix
+ ;
+
+fragment
+Exponent : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
+
+fragment
+FloatTypeSuffix : ('f'|'F'|'d'|'D') ;
+
+CharacterLiteral
+ : '\\' ( EscapeSequence | ~('\\') )
+ ;
+
+StringLiteral
+ : '"' ( EscapeSequence | ~('\\'|'"') )* '"'
+ ;
+
+fragment
+EscapeSequence
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ | UnicodeEscape
+ | OctalEscape
+ ;
+
+fragment
+OctalEscape
+ : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7')
+ ;
+
+fragment
+UnicodeEscape
+ : '\\' 'u' HexDigit HexDigit HexDigit HexDigit
+ ;
+
+JavaIdentifier
+ : Letter (Letter|JavaIDDigit)*
+ ;
+
+Identifier
+ : Letter ('-' |Letter|JavaIDDigit)*
+ ;
+
+MethodIdentifier
+ : Letter (Letter|JavaIDDigit)* '('
+ ;
+/**I found this char range in JavaCC's grammar, but Letter and Digit overlap.
+ Still works, but...
+ */
+fragment
+Letter
+ : '\u0024' |
+ '\u0041'..'\u005a' |
+ '\u005f' |
+ '\u0061'..'\u007a' |
+ '\u00c0'..'\u00d6' |
+ '\u00d8'..'\u00f6' |
+ '\u00f8'..'\u00ff' |
+ '\u0100'..'\u1fff' |
+ '\u3040'..'\u318f' |
+ '\u3300'..'\u337f' |
+ '\u3400'..'\u3d2d' |
+ '\u4e00'..'\u9fff' |
+ '\uf900'..'\ufaff'
+ ;
+
+fragment
+JavaIDDigit
+ :
+ '\u0030'..'\u0039' |
+ '\u0660'..'\u0669' |
+ '\u06f0'..'\u06f9' |
+ '\u0966'..'\u096f' |
+ '\u09e6'..'\u09ef' |
+ '\u0a66'..'\u0a6f' |
+ '\u0ae6'..'\u0aef' |
+ '\u0b66'..'\u0b6f' |
+ '\u0be7'..'\u0bef' |
+ '\u0c66'..'\u0c6f' |
+ '\u0ce6'..'\u0cef' |
+ '\u0d66'..'\u0d6f' |
+ '\u0e50'..'\u0e59' |
+ '\u0ed0'..'\u0ed9' |
+ '\u1040'..'\u1049'
+ ;
+
+WS : (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
+ ;
+
+COMMENT
+ : '#|' ( options {greedy=false;} : . )* '|#' {$channel=HIDDEN;}
+ ;
+
+LINE_COMMENT
+ : ';' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
+ ;
diff --git a/src/jvm/clojure/lang/ReaderLexer.java b/src/jvm/clojure/lang/ReaderLexer.java
new file mode 100644
index 00000000..631f002f
--- /dev/null
+++ b/src/jvm/clojure/lang/ReaderLexer.java
@@ -0,0 +1,2388 @@
+// $ANTLR 3.0 /Users/rich/dev/clojure/src/jvm/Reader.g 2007-07-13 12:56:20
+
+
+package clojure.lang;
+
+
+import org.antlr.runtime.*;
+
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+
+public class ReaderLexer extends Lexer{
+public static final int TrueToken = 10;
+public static final int T29 = 29;
+public static final int Exponent = 18;
+public static final int OctalLiteral = 14;
+public static final int T33 = 33;
+public static final int Identifier = 4;
+public static final int HexDigit = 17;
+public static final int T36 = 36;
+public static final int WS = 25;
+public static final int CharacterLiteral = 8;
+public static final int MethodIdentifier = 15;
+public static final int T28 = 28;
+public static final int T35 = 35;
+public static final int COMMENT = 26;
+public static final int StringLiteral = 9;
+public static final int LINE_COMMENT = 27;
+public static final int DotDot = 6;
+public static final int T34 = 34;
+public static final int JavaIDDigit = 24;
+public static final int Letter = 23;
+public static final int UnicodeEscape = 21;
+public static final int Comma = 16;
+public static final int HexLiteral = 13;
+public static final int T37 = 37;
+public static final int EscapeSequence = 20;
+public static final int NullToken = 11;
+public static final int EOF = -1;
+public static final int DecimalLiteral = 12;
+public static final int T32 = 32;
+public static final int Tokens = 38;
+public static final int T31 = 31;
+public static final int OctalEscape = 22;
+public static final int FloatingPointLiteral = 7;
+public static final int T30 = 30;
+public static final int FloatTypeSuffix = 19;
+public static final int JavaIdentifier = 5;
+
+RecognitionException rex = null;
+
+public void recover(RecognitionException re){
+ super.recover(re);
+ if(rex == null)
+ rex = re;
+}
+
+public void reportError(RecognitionException e){
+ if(rex == null)
+ rex = e;
+}
+
+public ReaderLexer(){
+ ;
+}
+
+public ReaderLexer(CharStream input){
+ super(input);
+}
+
+public String getGrammarFileName(){
+ return "/Users/rich/dev/clojure/src/jvm/Reader.g";
+}
+
+// $ANTLR start T28
+public final void mT28() throws RecognitionException{
+ try
+ {
+ int _type = T28;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:25:7: ( '(' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:25:7: '('
+ {
+ match('(');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T28
+
+// $ANTLR start T29
+
+public final void mT29() throws RecognitionException{
+ try
+ {
+ int _type = T29;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:26:7: ( ')' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:26:7: ')'
+ {
+ match(')');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T29
+
+// $ANTLR start T30
+
+public final void mT30() throws RecognitionException{
+ try
+ {
+ int _type = T30;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:27:7: ( '[' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:27:7: '['
+ {
+ match('[');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T30
+
+// $ANTLR start T31
+
+public final void mT31() throws RecognitionException{
+ try
+ {
+ int _type = T31;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:28:7: ( ']' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:28:7: ']'
+ {
+ match(']');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T31
+
+// $ANTLR start T32
+
+public final void mT32() throws RecognitionException{
+ try
+ {
+ int _type = T32;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:29:7: ( '{' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:29:7: '{'
+ {
+ match('{');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T32
+
+// $ANTLR start T33
+
+public final void mT33() throws RecognitionException{
+ try
+ {
+ int _type = T33;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:30:7: ( '}' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:30:7: '}'
+ {
+ match('}');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T33
+
+// $ANTLR start T34
+
+public final void mT34() throws RecognitionException{
+ try
+ {
+ int _type = T34;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:31:7: ( '/' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:31:7: '/'
+ {
+ match('/');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T34
+
+// $ANTLR start T35
+
+public final void mT35() throws RecognitionException{
+ try
+ {
+ int _type = T35;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:32:7: ( ':' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:32:7: ':'
+ {
+ match(':');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T35
+
+// $ANTLR start T36
+
+public final void mT36() throws RecognitionException{
+ try
+ {
+ int _type = T36;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:33:7: ( '#^' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:33:7: '#^'
+ {
+ match("#^");
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T36
+
+// $ANTLR start T37
+
+public final void mT37() throws RecognitionException{
+ try
+ {
+ int _type = T37;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:34:7: ( '.' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:34:7: '.'
+ {
+ match('.');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end T37
+
+// $ANTLR start Comma
+
+public final void mComma() throws RecognitionException{
+ try
+ {
+ int _type = Comma;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:212:10: ( ',' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:212:10: ','
+ {
+ match(',');
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end Comma
+
+// $ANTLR start TrueToken
+
+public final void mTrueToken() throws RecognitionException{
+ try
+ {
+ int _type = TrueToken;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:213:16: ( 'true' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:213:16: 'true'
+ {
+ match("true");
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end TrueToken
+
+// $ANTLR start NullToken
+
+public final void mNullToken() throws RecognitionException{
+ try
+ {
+ int _type = NullToken;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:215:16: ( 'null' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:215:16: 'null'
+ {
+ match("null");
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end NullToken
+
+// $ANTLR start DotDot
+
+public final void mDotDot() throws RecognitionException{
+ try
+ {
+ int _type = DotDot;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:217:10: ( '..' )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:217:10: '..'
+ {
+ match("..");
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end DotDot
+
+// $ANTLR start HexLiteral
+
+public final void mHexLiteral() throws RecognitionException{
+ try
+ {
+ int _type = HexLiteral;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:219:14: ( '0' ( 'x' | 'X' ) ( HexDigit )+ )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:219:14: '0' ( 'x' | 'X' ) ( HexDigit )+
+ {
+ match('0');
+ if(input.LA(1) == 'X' || input.LA(1) == 'x')
+ {
+ input.consume();
+
+ }
+ else
+ {
+ MismatchedSetException mse =
+ new MismatchedSetException(null, input);
+ recover(mse);
+ throw mse;
+ }
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:219:28: ( HexDigit )+
+ int cnt1 = 0;
+ loop1:
+ do
+ {
+ int alt1 = 2;
+ int LA1_0 = input.LA(1);
+
+ if(((LA1_0 >= '0' && LA1_0 <= '9') || (LA1_0 >= 'A' && LA1_0 <= 'F') || (LA1_0 >= 'a' && LA1_0 <= 'f')))
+ {
+ alt1 = 1;
+ }
+
+
+ switch(alt1)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:219:28: HexDigit
+ {
+ mHexDigit();
+
+ }
+ break;
+
+ default:
+ if(cnt1 >= 1) break loop1;
+ EarlyExitException eee =
+ new EarlyExitException(1, input);
+ throw eee;
+ }
+ cnt1++;
+ } while(true);
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end HexLiteral
+
+// $ANTLR start DecimalLiteral
+
+public final void mDecimalLiteral() throws RecognitionException{
+ try
+ {
+ int _type = DecimalLiteral;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:18: ( ( '0' | '1' .. '9' ( '0' .. '9' )* ) )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:18: ( '0' | '1' .. '9' ( '0' .. '9' )* )
+ {
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:18: ( '0' | '1' .. '9' ( '0' .. '9' )* )
+ int alt3 = 2;
+ int LA3_0 = input.LA(1);
+
+ if((LA3_0 == '0'))
+ {
+ alt3 = 1;
+ }
+ else if(((LA3_0 >= '1' && LA3_0 <= '9')))
+ {
+ alt3 = 2;
+ }
+ else
+ {
+ NoViableAltException nvae =
+ new NoViableAltException("221:18: ( '0' | '1' .. '9' ( '0' .. '9' )* )", 3, 0, input);
+
+ throw nvae;
+ }
+ switch(alt3)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:19: '0'
+ {
+ match('0');
+
+ }
+ break;
+ case 2:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:25: '1' .. '9' ( '0' .. '9' )*
+ {
+ matchRange('1', '9');
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:34: ( '0' .. '9' )*
+ loop2:
+ do
+ {
+ int alt2 = 2;
+ int LA2_0 = input.LA(1);
+
+ if(((LA2_0 >= '0' && LA2_0 <= '9')))
+ {
+ alt2 = 1;
+ }
+
+
+ switch(alt2)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:221:34: '0' .. '9'
+ {
+ matchRange('0', '9');
+
+ }
+ break;
+
+ default:
+ break loop2;
+ }
+ } while(true);
+
+
+ }
+ break;
+
+ }
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end DecimalLiteral
+
+// $ANTLR start OctalLiteral
+
+public final void mOctalLiteral() throws RecognitionException{
+ try
+ {
+ int _type = OctalLiteral;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:223:16: ( '0' ( '0' .. '7' )+ )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:223:16: '0' ( '0' .. '7' )+
+ {
+ match('0');
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:223:20: ( '0' .. '7' )+
+ int cnt4 = 0;
+ loop4:
+ do
+ {
+ int alt4 = 2;
+ int LA4_0 = input.LA(1);
+
+ if(((LA4_0 >= '0' && LA4_0 <= '7')))
+ {
+ alt4 = 1;
+ }
+
+
+ switch(alt4)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:223:21: '0' .. '7'
+ {
+ matchRange('0', '7');
+
+ }
+ break;
+
+ default:
+ if(cnt4 >= 1) break loop4;
+ EarlyExitException eee =
+ new EarlyExitException(4, input);
+ throw eee;
+ }
+ cnt4++;
+ } while(true);
+
+
+ }
+
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end OctalLiteral
+
+// $ANTLR start HexDigit
+
+public final void mHexDigit() throws RecognitionException{
+ try
+ {
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:226:12: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:226:12: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )
+ {
+ if((input.LA(1) >= '0' && input.LA(1) <= '9') || (input.LA(1) >= 'A' && input.LA(1) <= 'F') ||
+ (input.LA(1) >= 'a' && input.LA(1) <= 'f'))
+ {
+ input.consume();
+
+ }
+ else
+ {
+ MismatchedSetException mse =
+ new MismatchedSetException(null, input);
+ recover(mse);
+ throw mse;
+ }
+
+
+ }
+
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end HexDigit
+
+// $ANTLR start FloatingPointLiteral
+
+public final void mFloatingPointLiteral() throws RecognitionException{
+ try
+ {
+ int _type = FloatingPointLiteral;
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:9: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( Exponent )? ( FloatTypeSuffix )? | '.' ( '0' .. '9' )+ ( Exponent )? ( FloatTypeSuffix )? | ( '0' .. '9' )+ Exponent ( FloatTypeSuffix )? | ( '0' .. '9' )+ ( Exponent )? FloatTypeSuffix )
+ int alt16 = 4;
+ alt16 = dfa16.predict(input);
+ switch(alt16)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:9: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( Exponent )? ( FloatTypeSuffix )?
+ {
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:9: ( '0' .. '9' )+
+ int cnt5 = 0;
+ loop5:
+ do
+ {
+ int alt5 = 2;
+ int LA5_0 = input.LA(1);
+
+ if(((LA5_0 >= '0' && LA5_0 <= '9')))
+ {
+ alt5 = 1;
+ }
+
+
+ switch(alt5)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:10: '0' .. '9'
+ {
+ matchRange('0', '9');
+
+ }
+ break;
+
+ default:
+ if(cnt5 >= 1) break loop5;
+ EarlyExitException eee =
+ new EarlyExitException(5, input);
+ throw eee;
+ }
+ cnt5++;
+ } while(true);
+
+ match('.');
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:25: ( '0' .. '9' )*
+ loop6:
+ do
+ {
+ int alt6 = 2;
+ int LA6_0 = input.LA(1);
+
+ if(((LA6_0 >= '0' && LA6_0 <= '9')))
+ {
+ alt6 = 1;
+ }
+
+
+ switch(alt6)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:26: '0' .. '9'
+ {
+ matchRange('0', '9');
+
+ }
+ break;
+
+ default:
+ break loop6;
+ }
+ } while(true);
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:37: ( Exponent )?
+ int alt7 = 2;
+ int LA7_0 = input.LA(1);
+
+ if((LA7_0 == 'E' || LA7_0 == 'e'))
+ {
+ alt7 = 1;
+ }
+ switch(alt7)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:37: Exponent
+ {
+ mExponent();
+
+ }
+ break;
+
+ }
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:47: ( FloatTypeSuffix )?
+ int alt8 = 2;
+ int LA8_0 = input.LA(1);
+
+ if((LA8_0 == 'D' || LA8_0 == 'F' || LA8_0 == 'd' || LA8_0 == 'f'))
+ {
+ alt8 = 1;
+ }
+ switch(alt8)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:229:47: FloatTypeSuffix
+ {
+ mFloatTypeSuffix();
+
+ }
+ break;
+
+ }
+
+
+ }
+ break;
+ case 2:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:9: '.' ( '0' .. '9' )+ ( Exponent )? ( FloatTypeSuffix )?
+ {
+ match('.');
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:13: ( '0' .. '9' )+
+ int cnt9 = 0;
+ loop9:
+ do
+ {
+ int alt9 = 2;
+ int LA9_0 = input.LA(1);
+
+ if(((LA9_0 >= '0' && LA9_0 <= '9')))
+ {
+ alt9 = 1;
+ }
+
+
+ switch(alt9)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:14: '0' .. '9'
+ {
+ matchRange('0', '9');
+
+ }
+ break;
+
+ default:
+ if(cnt9 >= 1) break loop9;
+ EarlyExitException eee =
+ new EarlyExitException(9, input);
+ throw eee;
+ }
+ cnt9++;
+ } while(true);
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:25: ( Exponent )?
+ int alt10 = 2;
+ int LA10_0 = input.LA(1);
+
+ if((LA10_0 == 'E' || LA10_0 == 'e'))
+ {
+ alt10 = 1;
+ }
+ switch(alt10)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:25: Exponent
+ {
+ mExponent();
+
+ }
+ break;
+
+ }
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:35: ( FloatTypeSuffix )?
+ int alt11 = 2;
+ int LA11_0 = input.LA(1);
+
+ if((LA11_0 == 'D' || LA11_0 == 'F' || LA11_0 == 'd' || LA11_0 == 'f'))
+ {
+ alt11 = 1;
+ }
+ switch(alt11)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:230:35: FloatTypeSuffix
+ {
+ mFloatTypeSuffix();
+
+ }
+ break;
+
+ }
+
+
+ }
+ break;
+ case 3:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:231:9: ( '0' .. '9' )+ Exponent ( FloatTypeSuffix )?
+ {
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:231:9: ( '0' .. '9' )+
+ int cnt12 = 0;
+ loop12:
+ do
+ {
+ int alt12 = 2;
+ int LA12_0 = input.LA(1);
+
+ if(((LA12_0 >= '0' && LA12_0 <= '9')))
+ {
+ alt12 = 1;
+ }
+
+
+ switch(alt12)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:231:10: '0' .. '9'
+ {
+ matchRange('0', '9');
+
+ }
+ break;
+
+ default:
+ if(cnt12 >= 1) break loop12;
+ EarlyExitException eee =
+ new EarlyExitException(12, input);
+ throw eee;
+ }
+ cnt12++;
+ } while(true);
+
+ mExponent();
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:231:30: ( FloatTypeSuffix )?
+ int alt13 = 2;
+ int LA13_0 = input.LA(1);
+
+ if((LA13_0 == 'D' || LA13_0 == 'F' || LA13_0 == 'd' || LA13_0 == 'f'))
+ {
+ alt13 = 1;
+ }
+ switch(alt13)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:231:30: FloatTypeSuffix
+ {
+ mFloatTypeSuffix();
+
+ }
+ break;
+
+ }
+
+
+ }
+ break;
+ case 4:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:232:9: ( '0' .. '9' )+ ( Exponent )? FloatTypeSuffix
+ {
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:232:9: ( '0' .. '9' )+
+ int cnt14 = 0;
+ loop14:
+ do
+ {
+ int alt14 = 2;
+ int LA14_0 = input.LA(1);
+
+ if(((LA14_0 >= '0' && LA14_0 <= '9')))
+ {
+ alt14 = 1;
+ }
+
+
+ switch(alt14)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:232:10: '0' .. '9'
+ {
+ matchRange('0', '9');
+
+ }
+ break;
+
+ default:
+ if(cnt14 >= 1) break loop14;
+ EarlyExitException eee =
+ new EarlyExitException(14, input);
+ throw eee;
+ }
+ cnt14++;
+ } while(true);
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:232:21: ( Exponent )?
+ int alt15 = 2;
+ int LA15_0 = input.LA(1);
+
+ if((LA15_0 == 'E' || LA15_0 == 'e'))
+ {
+ alt15 = 1;
+ }
+ switch(alt15)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:232:21: Exponent
+ {
+ mExponent();
+
+ }
+ break;
+
+ }
+
+ mFloatTypeSuffix();
+
+ }
+ break;
+
+ }
+ this.type = _type;
+ }
+ finally
+ {
+ }
+}
+// $ANTLR end FloatingPointLiteral
+
+// $ANTLR start Exponent
+
+public final void mExponent() throws RecognitionException{
+ try
+ {
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:236:12: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:236:12: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+
+ {
+ if(input.LA(1) == 'E' || input.LA(1) == 'e')
+ {
+ input.consume();
+
+ }
+ else
+ {
+ MismatchedSetException mse =
+ new MismatchedSetException(null, input);
+ recover(mse);
+ throw mse;
+ }
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:236:22: ( '+' | '-' )?
+ int alt17 = 2;
+ int LA17_0 = input.LA(1);
+
+ if((LA17_0 == '+' || LA17_0 == '-'))
+ {
+ alt17 = 1;
+ }
+ switch(alt17)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:
+ {
+ if(input.LA(1) == '+' || input.LA(1) == '-')
+ {
+ input.consume();
+
+ }
+ else
+ {
+ MismatchedSetException mse =
+ new MismatchedSetException(null, input);
+ recover(mse);
+ throw mse;
+ }
+
+
+ }
+ break;
+
+ }
+
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:236:33: ( '0' .. '9' )+
+ int cnt18 = 0;
+ loop18:
+ do
+ {
+ int alt18 = 2;
+ int LA18_0 = input.LA(1);
+
+ if(((LA18_0 >= '0' && LA18_0 <= '9')))
+ {
+ alt18 = 1;
+ }
+
+
+ switch(alt18)
+ {
+ case 1:
+ // /Users/rich/dev/clojure/src/jvm/Reader.g:236:34: '0' .. '9'
+ {
+ matchRange('0', '9');
+