Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jlangch committed Jul 26, 2022
1 parent ccc71ea commit 2c87dea
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/main/java/com/github/jlangch/venice/impl/reader/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ private static VncVal read_form(final Reader rdr) {
// Note: auto gen symbols can not be used across nested syntax quotes.
// Use gensym in these cases.
rdr.autoGenSym.enterSyntaxQuote();

return VncList.of(new VncSymbol("quasiquote"), read_form(rdr))
.withMeta(MetaUtil.toMeta(token));
}
Expand All @@ -311,23 +310,8 @@ private static VncVal read_form(final Reader rdr) {
.withMeta(MetaUtil.toMeta(token));
}

case '^': {
rdr.next();
final Token metaToken = rdr.peek();
VncVal meta = read_form(rdr);
if (Types.isVncKeyword(meta)) {
// allow ^:private is equivalent to ^{:private true}
meta = VncHashMap.of(meta, VncBoolean.True);
}
if (Types.isVncMap(meta)) {
final Token symToken = rdr.peek();
return read_form(rdr).withMeta(MetaUtil.mergeMeta(meta, MetaUtil.toMeta(symToken)));
}
else {
throw new ParseError(formatParseError(
metaToken, "Invalid meta data type %s", Types.getType(meta)));
}
}
case '^':
return parseMetaData(rdr);

case '@':
rdr.next();
Expand Down Expand Up @@ -364,7 +348,6 @@ private static VncVal read_form(final Reader rdr) {
}

private static VncVal parseReaderMacro(final Reader rdr, final Token token) {
// Reader macros (built-in)
final String sToken = token.getToken();
if (sToken.length() == 1) {
rdr.next();
Expand Down Expand Up @@ -414,7 +397,24 @@ else if (sToken.charAt(1) == '\\') {
throw new ParseError(formatParseError(
token,
"Expected a valid reader macro '#{..}', '#(..)' or '#\\x'"));
}

private static VncVal parseMetaData(final Reader rdr) {
rdr.next();
final Token metaToken = rdr.peek();
VncVal meta = read_form(rdr);
if (Types.isVncKeyword(meta)) {
// allow ^:private is equivalent to ^{:private true}
meta = VncHashMap.of(meta, VncBoolean.True);
}
if (Types.isVncMap(meta)) {
final Token symToken = rdr.peek();
return read_form(rdr).withMeta(MetaUtil.mergeMeta(meta, MetaUtil.toMeta(symToken)));
}
else {
throw new ParseError(formatParseError(
metaToken, "Invalid meta data type %s", Types.getType(meta)));
}
}

private static VncChar read_char(final Token token) {
Expand Down

0 comments on commit 2c87dea

Please sign in to comment.