static void Unread(PushbackTextReader r, int ch) { if (ch != -1) { r.Unread(ch); } }
//static ListReader _listReader = new ListReader(); protected override object Read(PushbackTextReader r, char lparen) { if (ARG_ENV.deref() != null) { throw new InvalidOperationException("Nested #()s are not allowed"); } try { Var.pushThreadBindings(RT.map(ARG_ENV, PersistentTreeMap.EMPTY)); r.Unread('('); ////object form = ReadAux(r, true, null, true); object form = ReadAux(r); //object form = _listReader.invoke(r, '('); IPersistentVector args = PersistentVector.EMPTY; PersistentTreeMap argsyms = (PersistentTreeMap)ARG_ENV.deref(); ISeq rargs = argsyms.rseq(); if (rargs != null) { int higharg = (int)((IMapEntry)rargs.first()).key(); if (higharg > 0) { for (int i = 1; i <= higharg; ++i) { object sym = argsyms.valAt(i); if (sym == null) { sym = garg(i); } args = args.cons(sym); } } object restsym = argsyms.valAt(-1); if (restsym != null) { args = args.cons(Compiler._AMP_); args = args.cons(restsym); } } return(RT.list(Compiler.FN, args, form)); } finally { Var.popThreadBindings(); } }
//static ListReader _listReader = new ListReader(); protected override object Read(PushbackTextReader r, char lparen) { if (ARG_ENV.deref() != null) throw new InvalidOperationException("Nested #()s are not allowed"); try { Var.pushThreadBindings(RT.map(ARG_ENV, PersistentTreeMap.EMPTY)); r.Unread('('); ////object form = ReadAux(r, true, null, true); object form = ReadAux(r); //object form = _listReader.invoke(r, '('); IPersistentVector args = PersistentVector.EMPTY; PersistentTreeMap argsyms = (PersistentTreeMap)ARG_ENV.deref(); ISeq rargs = argsyms.rseq(); if (rargs != null) { int higharg = (int)((IMapEntry)rargs.first()).key(); if (higharg > 0) { for (int i = 1; i <= higharg; ++i) { object sym = argsyms.valAt(i); if (sym == null) sym = garg(i); args = args.cons(sym); } } object restsym = argsyms.valAt(-1); if (restsym != null) { args = args.cons(Compiler._AMP_); args = args.cons(restsym); } } return RT.list(Compiler.FN, args, form); } finally { Var.popThreadBindings(); } }
static void Unread(PushbackTextReader r, int ch) { if (ch != -1) r.Unread(ch); }
static bool readToken(PushbackTextReader r, char initch, out string nameString, out int lastSlashIndex) { bool oddVertBarMode = false; lastSlashIndex = -1; bool allowSymEscape = RT.booleanCast(RT.AllowSymbolEscapeVar.deref()); StringBuilder sb = new StringBuilder(); if (allowSymEscape && initch == '|') oddVertBarMode = true; else sb.Append(initch); for (; ; ) { int ch = r.Read(); if (oddVertBarMode) { if (ch == -1) { nameString = sb.ToString(); return true; } if (ch == '|') { int ch2 = r.Read(); if (ch2 == '|') sb.Append('|'); else { r.Unread(ch2); oddVertBarMode = false; } } else sb.Append((char)ch); } else { if (ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch)) { Unread(r, ch); nameString = sb.ToString(); return false; } else if (ch == '|' && allowSymEscape) { oddVertBarMode = true; } else { sb.Append((char)ch); if (ch == '/') lastSlashIndex = sb.Length - 1; } } } }
static void readToken(PushbackTextReader r, char initch, out String rawToken, out String token, out String mask, out bool eofSeen) { bool allowSymEscape = RT.booleanCast(RT.AllowSymbolEscapeVar.deref()); bool rawMode = false; StringBuilder sbRaw = new StringBuilder(); StringBuilder sbToken = new StringBuilder(); StringBuilder sbMask = new StringBuilder(); if (allowSymEscape && initch == '|') { rawMode = true; sbRaw.Append(initch); } else { sbRaw.Append(initch); sbToken.Append(initch); sbMask.Append(initch); } for (; ; ) { int ch = r.Read(); if (rawMode) { if (ch == -1) { rawToken = sbRaw.ToString(); token = sbToken.ToString(); mask = sbMask.ToString(); eofSeen = true; return; } if (ch == '|') { int ch2 = r.Read(); if (ch2 == '|') { sbRaw.Append('|'); sbToken.Append('|'); sbMask.Append('a'); } else { r.Unread(ch2); rawMode = false; sbRaw.Append(ch); } } else { sbRaw.Append((char)ch); sbToken.Append((char)ch); sbMask.Append('a'); } } else { if (ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch)) { Unread(r, ch); rawToken = sbRaw.ToString(); token = sbToken.ToString(); mask = sbMask.ToString(); eofSeen = false; return; } else if (ch == '|' && allowSymEscape) { rawMode = true; sbRaw.Append((char)ch); } else { sbRaw.Append((char)ch); sbToken.Append((char)ch); sbMask.Append((char)ch); } } } }
static void readToken(PushbackTextReader r, char initch, bool leadConstituent, out String rawToken, out String token, out String mask, out bool eofSeen) { if (leadConstituent && NonConstituent(initch)) { throw new InvalidOperationException("Invalid leading characters: " + (char)initch); } bool allowSymEscape = RT.booleanCast(RT.AllowSymbolEscapeVar.deref()); bool rawMode = false; StringBuilder sbRaw = new StringBuilder(); StringBuilder sbToken = new StringBuilder(); StringBuilder sbMask = new StringBuilder(); if (allowSymEscape && initch == '|') { rawMode = true; sbRaw.Append(initch); } else { sbRaw.Append(initch); sbToken.Append(initch); sbMask.Append(initch); } for (; ;) { int ch = r.Read(); if (rawMode) { if (ch == -1) { rawToken = sbRaw.ToString(); token = sbToken.ToString(); mask = sbMask.ToString(); eofSeen = true; return; } if (ch == '|') { int ch2 = r.Read(); if (ch2 == '|') { sbRaw.Append('|'); sbToken.Append('|'); sbMask.Append('a'); } else { r.Unread(ch2); rawMode = false; sbRaw.Append(ch); } } else { sbRaw.Append((char)ch); sbToken.Append((char)ch); sbMask.Append('a'); } } else { if (ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch)) { Unread(r, ch); rawToken = sbRaw.ToString(); token = sbToken.ToString(); mask = sbMask.ToString(); eofSeen = false; return; } else if (NonConstituent(ch)) { throw new InvalidOperationException("Invalid constituent character: " + (char)ch); } else if (ch == '|' && allowSymEscape) { rawMode = true; sbRaw.Append((char)ch); } else { sbRaw.Append((char)ch); sbToken.Append((char)ch); sbMask.Append((char)ch); } } } }
static bool readToken(PushbackTextReader r, char initch, bool leadConstituent, out string nameString, out int lastSlashIndex) { if (leadConstituent && NonConstituent(initch)) { throw new InvalidOperationException("Invalid leading characters: " + (char)initch); } bool oddVertBarMode = false; lastSlashIndex = -1; bool allowSymEscape = RT.booleanCast(RT.AllowSymbolEscapeVar.deref()); StringBuilder sb = new StringBuilder(); if (allowSymEscape && initch == '|') { oddVertBarMode = true; } else { sb.Append(initch); } for (; ;) { int ch = r.Read(); if (oddVertBarMode) { if (ch == -1) { nameString = sb.ToString(); return(true); } if (ch == '|') { int ch2 = r.Read(); if (ch2 == '|') { sb.Append('|'); } else { r.Unread(ch2); oddVertBarMode = false; } } else { sb.Append((char)ch); } } else { if (ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch)) { Unread(r, ch); nameString = sb.ToString(); return(false); } else if (NonConstituent(ch)) { throw new InvalidOperationException("Invalid constituent character: " + (char)ch); } else if (ch == '|' && allowSymEscape) { oddVertBarMode = true; } else { sb.Append((char)ch); if (ch == '/') { lastSlashIndex = sb.Length - 1; } } } } }