Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion artifacts/latex.bindings.python.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"artifact_kind":"parg-bindings","target":"python","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"a1025ab6e3570568d70bc823e9e61b50da484ecbf203eb318837578954300a44","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:18cdbd69e1b2851fc9b99ff4581b8a7ae8173118ed7c3eab54ac4e1fb934ca66"}
{"artifact_kind":"parg-bindings","target":"python","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"7df8aaf22ff73024a5dae6621e54e4794488fa9c8a0f7ba5241ca0dc1ed858d4","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:f247d6f406160d6c30353610f2c479f8232344ecab7ec227da39ea9187258773"}
2 changes: 1 addition & 1 deletion artifacts/latex.bindings.rs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"artifact_kind":"parg-bindings","target":"rs","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"a1025ab6e3570568d70bc823e9e61b50da484ecbf203eb318837578954300a44","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:e2d457b6fb8c72d2668590e1929234947b60449bced3d6bc124520d162bace19"}
{"artifact_kind":"parg-bindings","target":"rs","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"7df8aaf22ff73024a5dae6621e54e4794488fa9c8a0f7ba5241ca0dc1ed858d4","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:52ff5e740754b65992ea2de1233942104759b998fb686d5508952ddd92a98e61"}
2 changes: 1 addition & 1 deletion artifacts/latex.bindings.ruby.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"artifact_kind":"parg-bindings","target":"ruby","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"a1025ab6e3570568d70bc823e9e61b50da484ecbf203eb318837578954300a44","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:9cc621387823f0329df6958a7c614a53118b5886a3c19d2044c07a4c5f38f812"}
{"artifact_kind":"parg-bindings","target":"ruby","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"7df8aaf22ff73024a5dae6621e54e4794488fa9c8a0f7ba5241ca0dc1ed858d4","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:57e974bcea8eff4a8b49ee95c7c8a3b2d61b16aececf58e4ce06b315de357957"}
2 changes: 1 addition & 1 deletion artifacts/latex.bindings.ts.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"artifact_kind":"parg-bindings","target":"ts","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"a1025ab6e3570568d70bc823e9e61b50da484ecbf203eb318837578954300a44","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:68697cec37aed894d65dd1afcbaf0848475be69bcbc4f5c5aa8861e411cc3337"}
{"artifact_kind":"parg-bindings","target":"ts","binding_version":1,"grammar":"Latex","grammar_version":"0.1.0","grammar_source_hash":"7df8aaf22ff73024a5dae6621e54e4794488fa9c8a0f7ba5241ca0dc1ed858d4","shape":"parsanol-tree/v2","entries":{"dot":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"comma":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]},"arabic":{"bindings":[{"capture":"latex_tree","path":"latex_tree","type":"raw","card":null,"preprocess":null},{"capture":"latex_tree","path":"model","type":"any","card":null,"preprocess":null}]}},"checksum":"sha256:b1130029fa3e2e9b96339b3436996cfc78552b7fa3c0844d553daae83e46d576"}
26 changes: 13 additions & 13 deletions artifacts/latex.checksums.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Written by scripts/compile.rb. Envelope checksums are Parsanol's own;
# the sha256 lines are of the files' bytes.
artifact_checksum sha256:b582338f5f0575aca6a9d42d862d4fe63c4b3762ecb1c2f052a8b9093972ae8d
artifact_checksum sha256:8243828c72faa31eabf02f3eaf9f4743d5faf1898bbd1516a05c9fa48f7a95a8
compiler_version 1.3.134
edition 2
source_hash sha256:a1025ab6e3570568d70bc823e9e61b50da484ecbf203eb318837578954300a44
artifacts/latex.json sha256:2e8e17ce8490211ea6d78c6bb55ff7125a47b3537211b72c1bb7677432c7e5b3
bindings ruby checksum sha256:9cc621387823f0329df6958a7c614a53118b5886a3c19d2044c07a4c5f38f812
artifacts/latex.bindings.ruby.json sha256:1d95cf3775dd0e28c5b6b58da70044e217f656276e4af95ed9940f3d05aed799
bindings rs checksum sha256:e2d457b6fb8c72d2668590e1929234947b60449bced3d6bc124520d162bace19
artifacts/latex.bindings.rs.json sha256:7b034b2e1c25b68fde1b4c13899e29429b31411bc969268fce1d85beb2e7033d
bindings ts checksum sha256:68697cec37aed894d65dd1afcbaf0848475be69bcbc4f5c5aa8861e411cc3337
artifacts/latex.bindings.ts.json sha256:d5ab0691054d83b53022f58fcb6d5e39b0381113d1b12b5a9c23b0f0a9f5bd93
bindings python checksum sha256:18cdbd69e1b2851fc9b99ff4581b8a7ae8173118ed7c3eab54ac4e1fb934ca66
artifacts/latex.bindings.python.json sha256:49ece376dd5639731a2ce62aac8c5e45ec0edc77ebb65261b4cffa9478dad436
grammars/latex.parg sha256:a1025ab6e3570568d70bc823e9e61b50da484ecbf203eb318837578954300a44
source_hash sha256:7df8aaf22ff73024a5dae6621e54e4794488fa9c8a0f7ba5241ca0dc1ed858d4
artifacts/latex.json sha256:b6e2027c917e537458d821ab7459c24c133e5b203d305f354fc16be7a0b1a317
bindings ruby checksum sha256:57e974bcea8eff4a8b49ee95c7c8a3b2d61b16aececf58e4ce06b315de357957
artifacts/latex.bindings.ruby.json sha256:0ed2ac9d681421c1ca6d1fdc93eff588d9256ba0ff44101bfba3c344b9c7831c
bindings rs checksum sha256:52ff5e740754b65992ea2de1233942104759b998fb686d5508952ddd92a98e61
artifacts/latex.bindings.rs.json sha256:8ba518981c575001429786d2fba89b28c9581301f9681b49336669edabc26c1b
bindings ts checksum sha256:b1130029fa3e2e9b96339b3436996cfc78552b7fa3c0844d553daae83e46d576
artifacts/latex.bindings.ts.json sha256:05256039211d7f17c40b397aaf0e7238bbbdc80b2b5d4ad596f46122cb1725b6
bindings python checksum sha256:f247d6f406160d6c30353610f2c479f8232344ecab7ec227da39ea9187258773
artifacts/latex.bindings.python.json sha256:3e0dff0c2ccdf7c02951cb68fe1708c7cff5dba320efb1e6481589f57bda5e8a
grammars/latex.parg sha256:7df8aaf22ff73024a5dae6621e54e4794488fa9c8a0f7ba5241ca0dc1ed858d4
data/latex-atoms.json sha256:69d1f126bde8c781324c55dfe5b26c2a1abd558914a3cbfa92c737436fc828e5
entries dot comma arabic
order_warnings 31906
order_warnings 31933
2 changes: 1 addition & 1 deletion artifacts/latex.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions docs/parser-contract.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ The raw-tree boundary already exists in this gem:

`Latexmath::ParseError` carries the offsets described under <<Errors>>.

=== Box enclosures

The stage also accepts `\boxed{...}`, an extension to the pinned legacy
grammar. The braces are required; their contents may be empty or contain
nested commands, including another box. The chosen decimal marker applies
inside the box. A command prefix such as `\boxedx` and unbraced box
arguments are refused.

The typed model uses the existing `UnaryFunctions` node with `unary` equal
to `"boxed"` and the grouped contents in `first_value`. This represents an
enclosure with MathML notation `box`; a consumer must map it to its enclosure
model rather than discard the command. This syntax extension is applied by
the generator before shape normalization. The pinned oracle export and
shared corpus generations are unchanged.

== Reference implementation

The behaviour to reproduce is the LaTeX path of Plurimath at one fixed commit.
Expand Down
2 changes: 1 addition & 1 deletion grammars/latex.normalized-rules.json

Large diffs are not rendered by default.

48 changes: 34 additions & 14 deletions grammars/latex.parg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Plurimath::Latex::Parse#parse(text), where text is
# Plurimath::Latex::Parser.new(input).text (see docs/parser-contract.adoc).
# No model and no transform.
# Stage extension: \boxed{...} retains unary "boxed" and its body
# as unary_functions, the typed equivalent of a box enclosure.
#
# Transcription: every Parsanol Entity (rule) is one rule here, under its
# Plurimath name; every other atom is written inline, mechanically:
Expand Down Expand Up @@ -86,7 +88,9 @@ grammar Latex version "0.1.0" {
sequence__comma = sequence_part1__comma / sequence_part2__comma
sequence__arabic = sequence_part1__arabic / sequence_part2__arabic
sequence_part1__dot = {
(limits__dot) as limits
((slash ("boxed") as unary ("{" (expression__dot / "" as absent) as expression "}") as first_value) as unary_functions base (intermediate_exp__dot) as subscript power (intermediate_exp__dot) as supscript) as power_base
/ ((slash ("boxed") as unary ("{" (expression__dot / "" as absent) as expression "}") as first_value) as unary_functions power (intermediate_exp__dot) as supscript base (intermediate_exp__dot) as subscript) as power_base
/ (limits__dot) as limits
/ ((binary_functions__dot) as binary_functions power (sequence__dot) as supscript) as power
/ ((binary_functions__dot) as binary_functions base (sequence__dot) as subscript) as base
/ binary_functions__dot
Expand All @@ -100,11 +104,11 @@ grammar Latex version "0.1.0" {
/ slash ("substack") as substack intermediate_exp__dot
/ (array_begin array_args__dot (expression__dot) as table_data ending__dot) as environment
/ (begining__dot (expression__dot) as table_data ending__dot) as environment
/ (slash environment intermediate_exp__dot) as table_data
/ power_base__dot
}
sequence_part1__comma = {
(limits__comma) as limits
((slash ("boxed") as unary ("{" (expression__comma / "" as absent) as expression "}") as first_value) as unary_functions base (intermediate_exp__comma) as subscript power (intermediate_exp__comma) as supscript) as power_base
/ ((slash ("boxed") as unary ("{" (expression__comma / "" as absent) as expression "}") as first_value) as unary_functions power (intermediate_exp__comma) as supscript base (intermediate_exp__comma) as subscript) as power_base
/ (limits__comma) as limits
/ ((binary_functions__comma) as binary_functions power (sequence__comma) as supscript) as power
/ ((binary_functions__comma) as binary_functions base (sequence__comma) as subscript) as base
/ binary_functions__comma
Expand All @@ -118,11 +122,11 @@ grammar Latex version "0.1.0" {
/ slash ("substack") as substack intermediate_exp__comma
/ (array_begin array_args__comma (expression__comma) as table_data ending__comma) as environment
/ (begining__comma (expression__comma) as table_data ending__comma) as environment
/ (slash environment intermediate_exp__comma) as table_data
/ power_base__comma
}
sequence_part1__arabic = {
(limits__arabic) as limits
((slash ("boxed") as unary ("{" (expression__arabic / "" as absent) as expression "}") as first_value) as unary_functions base (intermediate_exp__arabic) as subscript power (intermediate_exp__arabic) as supscript) as power_base
/ ((slash ("boxed") as unary ("{" (expression__arabic / "" as absent) as expression "}") as first_value) as unary_functions power (intermediate_exp__arabic) as supscript base (intermediate_exp__arabic) as subscript) as power_base
/ (limits__arabic) as limits
/ ((binary_functions__arabic) as binary_functions power (sequence__arabic) as supscript) as power
/ ((binary_functions__arabic) as binary_functions base (sequence__arabic) as subscript) as base
/ binary_functions__arabic
Expand All @@ -136,12 +140,25 @@ grammar Latex version "0.1.0" {
/ slash ("substack") as substack intermediate_exp__arabic
/ (array_begin array_args__arabic (expression__arabic) as table_data ending__arabic) as environment
/ (begining__arabic (expression__arabic) as table_data ending__arabic) as environment
/ (slash environment intermediate_exp__arabic) as table_data
}
sequence_part2__dot = {
(slash environment intermediate_exp__dot) as table_data
/ power_base__dot
/ intermediate_exp__dot
/ (intermediate_exp__dot) as intermediate_exp (rparen) as symbol
}
sequence_part2__comma = {
(slash environment intermediate_exp__comma) as table_data
/ power_base__comma
/ intermediate_exp__comma
/ (intermediate_exp__comma) as intermediate_exp (rparen) as symbol
}
sequence_part2__arabic = {
(slash environment intermediate_exp__arabic) as table_data
/ power_base__arabic
/ intermediate_exp__arabic
/ (intermediate_exp__arabic) as intermediate_exp (rparen) as symbol
}
sequence_part2__dot = intermediate_exp__dot / (intermediate_exp__dot) as intermediate_exp (rparen) as symbol
sequence_part2__comma = intermediate_exp__comma / (intermediate_exp__comma) as intermediate_exp (rparen) as symbol
sequence_part2__arabic = intermediate_exp__arabic / (intermediate_exp__arabic) as intermediate_exp (rparen) as symbol
limits__dot = {
math_operators__dot base (intermediate_exp__dot) as base power (intermediate_exp__dot) as power
/ math_operators__dot power (intermediate_exp__dot) as power base (intermediate_exp__dot) as base
Expand Down Expand Up @@ -5070,21 +5087,24 @@ grammar Latex version "0.1.0" {
}
slash = "\\"
binary_functions__dot = {
((intermediate_exp__dot) as first_value under_over (intermediate_exp__dot) as second_value) as under_over
(slash ("boxed") as unary ("{" (expression__dot / "" as absent) as expression "}") as first_value) as unary_functions
/ ((intermediate_exp__dot) as first_value under_over (intermediate_exp__dot) as second_value) as under_over
/ (slash ("sqrt") as root (sqrt_arg__dot) as first_value (intermediate_exp__dot) as second_value) as binary
/ (slash ("sqrt") as sqrt (intermediate_exp__dot) as intermediate_exp) as binary
/ "{" slash (("color") as literal) as binary (color) as first_value [(sequence__dot [iteration__dot]) as second_value] "}"
/ slash (("color") as literal) as binary (color) as first_value [(expression__dot) as second_value]
}
binary_functions__comma = {
((intermediate_exp__comma) as first_value under_over (intermediate_exp__comma) as second_value) as under_over
(slash ("boxed") as unary ("{" (expression__comma / "" as absent) as expression "}") as first_value) as unary_functions
/ ((intermediate_exp__comma) as first_value under_over (intermediate_exp__comma) as second_value) as under_over
/ (slash ("sqrt") as root (sqrt_arg__comma) as first_value (intermediate_exp__comma) as second_value) as binary
/ (slash ("sqrt") as sqrt (intermediate_exp__comma) as intermediate_exp) as binary
/ "{" slash (("color") as literal) as binary (color) as first_value [(sequence__comma [iteration__comma]) as second_value] "}"
/ slash (("color") as literal) as binary (color) as first_value [(expression__comma) as second_value]
}
binary_functions__arabic = {
((intermediate_exp__arabic) as first_value under_over (intermediate_exp__arabic) as second_value) as under_over
(slash ("boxed") as unary ("{" (expression__arabic / "" as absent) as expression "}") as first_value) as unary_functions
/ ((intermediate_exp__arabic) as first_value under_over (intermediate_exp__arabic) as second_value) as under_over
/ (slash ("sqrt") as root (sqrt_arg__arabic) as first_value (intermediate_exp__arabic) as second_value) as binary
/ (slash ("sqrt") as sqrt (intermediate_exp__arabic) as intermediate_exp) as binary
/ "{" slash (("color") as literal) as binary (color) as first_value [(sequence__arabic [iteration__arabic]) as second_value] "}"
Expand Down
2 changes: 1 addition & 1 deletion grammars/latex.wrappers.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"rules": {
"N1 text alternative": 145,
"N10 list site": 5,
"N11 named option": 8,
"N11 named option": 11,
"N8 catalog text": 3246,
"N9 empty list": 4
}
Expand Down
1 change: 1 addition & 0 deletions lib/latexmath/model/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class BinaryFunctions < Lutaml::Model::Serializable
attribute :binary, "Latexmath::Model::Binary"
attribute :first_value, "Latexmath::Model::FirstValue"
attribute :second_value, "Latexmath::Model::SecondValue"
attribute :unary_functions, "Latexmath::Model::UnaryFunctions"
attribute :under_over, "Latexmath::Model::UnderOver"
end

Expand Down
Loading
Loading