2025-01-25 02:23:13 +08:00
|
|
|
|
|
|
|
module Passes
|
|
|
|
include("classes.jl")
|
|
|
|
using .Classes
|
|
|
|
|
|
|
|
export processed_passes, Pass
|
|
|
|
processed_passes = []
|
|
|
|
|
|
|
|
struct Pass
|
|
|
|
pattern
|
|
|
|
func
|
|
|
|
end
|
|
|
|
|
|
|
|
####definition of passes ####
|
|
|
|
|
|
|
|
# 2 newline become @par{}
|
|
|
|
function two_nl_to_par_pass_func(two_nl)
|
|
|
|
return [Classes.SEQ([Classes.ID("par")])]
|
|
|
|
end
|
|
|
|
|
2025-01-25 11:18:37 +08:00
|
|
|
two_nl_to_par_pattern = [Classes.NL([]), Classes.NL([])] #two continuous newline
|
2025-01-25 02:23:13 +08:00
|
|
|
|
|
|
|
two_nl_to_par_pass = Pass(two_nl_to_par_pattern,
|
|
|
|
two_nl_to_par_pass_func)
|
2025-01-25 11:18:37 +08:00
|
|
|
push!(processed_passes, two_nl_to_par_pass)
|
2025-01-25 02:23:13 +08:00
|
|
|
|
2025-01-25 11:18:37 +08:00
|
|
|
# in 2 hanzi add glue.
|
|
|
|
function insert_hglue_in_adjacent_chinese(two_nl)
|
|
|
|
_0pt = Classes.SEQ([Classes.ID("pt"); Classes.CHAR(["0"])])
|
|
|
|
inner = Classes.SEQ([Classes.ID("hglue"); _0pt])
|
|
|
|
return [two_nl[1]; inner; two_nl[2]]
|
|
|
|
end
|
|
|
|
adjacent_chinese_pattern = [Classes.CHAR(r"[\p{Han},。!?:「」『』…]"),
|
|
|
|
Classes.CHAR(r"[\p{Han},。!?:「」『』…]")]
|
2025-01-25 02:23:13 +08:00
|
|
|
|
2025-01-25 11:18:37 +08:00
|
|
|
adjacent_glue_pass = Pass(adjacent_chinese_pattern,
|
|
|
|
insert_hglue_in_adjacent_chinese)
|
|
|
|
push!(processed_passes, adjacent_glue_pass)
|
2025-01-25 02:23:13 +08:00
|
|
|
|
|
|
|
end
|