Skip to content

Commit

Permalink
Merge pull request #6 from jamesnvc/speed-up-parser-failing
Browse files Browse the repository at this point in the history
Fix DCG for parsing json-rpc messages
  • Loading branch information
TeamSPoon authored Feb 5, 2025
2 parents 8cf0145 + 564812e commit ff4c104
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions libraries/lsp_server_metta/prolog/lsp_json_parser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
header(Header), "\r\n",
headers(Headers).

json_chars(0, []) --> [].
json_chars(N, [C|Cs]) --> [C], { succ(Nn, N) }, json_chars(Nn, Cs).

lsp_metta_request(_{headers: Headers, body: Body}) -->
headers(HeadersList),
headers(HeadersList), !,
{ list_to_assoc(HeadersList, Headers),
get_assoc("Content-Length", Headers, LengthS),
number_string(Length, LengthS) },
json_chars(Length, JsonCodes),
number_string(Length, LengthS),
length(JsonCodes, Length) },
JsonCodes,
{ ground(JsonCodes),
open_codes_stream(JsonCodes, JsonStream),
json_read_dict(JsonStream, Body, []) }.
Expand Down

0 comments on commit ff4c104

Please sign in to comment.