Skip to content

Commit

Permalink
Replace Array<Doc> w/ List<Doc>
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene Gleyzer committed Nov 12, 2024
1 parent 1c0274b commit b1dbbc3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
11 changes: 9 additions & 2 deletions lib_json/src/main/x/json.x
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ module json.xtclang.org
/**
* JSON primitive types are all JSON values except for arrays and objects.
*/
typedef (Nullable | Boolean | IntLiteral | FPLiteral | String) as Primitive;
// typedef (Nullable | Boolean | IntLiteral | FPLiteral | String) as Primitive;

// or maybe:

// typedef (Nullable | Boolean | IntLiteral | IntNumber | FPLiteral | FPNumber | String) as Primitive;

// or even:
// typedef (Nullable | Boolean | ecstasy.numbers.IntConvertible | ecstasy.numbers.FPConvertible | String) as Primitive;

/**
* JSON types include primitive types, array types, and map types.
*/
typedef (Primitive | Map<String, Doc> | Doc[]) as Doc;
typedef (Primitive | Map<String, Doc> | List<Doc>) as Doc;

/**
* A type representing a JSON Array.
Expand Down
5 changes: 1 addition & 4 deletions lib_json/src/main/x/json/JsonObject.x
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class JsonObject
// this doesn't work atm, but it should; will make put ops more usable
// @Op("[]=") void putInPlace(Key key, Int value) = putInPlace(key, value.toIntLiteral());
//
// @Op("[]=") void putInPlace(Key key, FPNumber value) = putInPlace(key, value.toIntLiteral());

@Auto
Doc toDoc() = jsonObject;
// @Op("[]=") void putInPlace(Key key, FPNumber value) = putInPlace(key, value.toFPLiteral());
}

8 changes: 4 additions & 4 deletions lib_json/src/main/x/json/Parser.x
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class Parser
* @return an array of JSON values
*/
@Override
Array<Doc> parseArray() {
List<Doc> parseArray() {
JsonArray array = json.newArray();
expect(ArrayEnter);
if (!match(ArrayExit)) {
Expand Down Expand Up @@ -807,7 +807,7 @@ class Parser
Token[] skipRemaining(Token[]? skipped = Null);
Doc parseDoc();
(Token first, Token last) skipDoc(Token[]? skipped = Null);
Array<Doc> parseArray();
List<Doc> parseArray();
(Token first, Token last) skipArray(Token[]? skipped = Null);
conditional ArrayParser matchArray();
ArrayParser expectArray();
Expand Down Expand Up @@ -890,9 +890,9 @@ class Parser
}

@Override
Array<Doc> parseArray() {
List<Doc> parseArray() {
checkEof();
Array<Doc> array = raw.parseArray();
List<Doc> array = raw.parseArray();
checkDelimiter();
return array;
}
Expand Down
2 changes: 1 addition & 1 deletion manualTests/src/main/x/TestSimple.x
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module TestSimple {

Doc getDoc(Dec d = 1) {
JsonObject o = json.newObject();
o["a"] = d/*this will not be needed*/.toFPLiteral();
o["a"] = d /*this will not be needed*/.toFPLiteral();
return o;
}
}
Expand Down

0 comments on commit b1dbbc3

Please sign in to comment.