Transfer code (#1)

* copy project root files

* import previously created code and rename where needed

* fix license and lint

* main is now just a JS wrapper

* minified main.cjs rather than copying to a newly named file
This commit is contained in:
2026-05-28 12:35:03 +02:00
committed by GitHub
parent 1561720e5f
commit 79155255f6
38 changed files with 1850 additions and 10 deletions
+42
View File
@@ -0,0 +1,42 @@
open Ast
let in_header = ref false
let next_token buf =
if !in_header then
let tok = Lexer.tokenize_header buf in
match tok with
| Parser.TAG_CLOSE ->
in_header := false;
Parser.TAG_CLOSE
| _ -> tok
else
let tok = Lexer.tokenize_game buf in
match tok with
| Parser.TAG_OPEN ->
in_header := true;
Parser.TAG_OPEN
| _ -> tok
let parse_pgn s =
let buf = Sedlexing.Utf8.from_string s in
in_header := false;
let provider () =
let tok = next_token buf in
let start_pos, end_pos = Sedlexing.lexing_positions buf in
(tok, start_pos, end_pos)
in
try MenhirLib.Convert.Simplified.traditional2revised Parser.main provider
with _ -> failwith "Parse error"
(* let parse_diagram_json json_str =
let json = Yojson.Basic.from_string json_str in
let json_assoc = Yojson.Basic.Util.to_assoc json in
List.fold_left
(fun acc (key_str, json_value) ->
let value_string = Yojson.Basic.Util.to_string json_value in
match int_of_string_opt key_str with
| Some k -> Pgn2tex.MoveMap.add k value_string acc
| None -> acc)
Pgn2tex.MoveMap.empty json_assoc *)