Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
% (find-LATEX "2021burghardt.tex") % (defun c () (interactive) (find-LATEXsh "lualatex -record 2021burghardt.tex" :end)) % (defun C () (interactive) (find-LATEXSH "lualatex 2021burghardt.tex" "Success!!!")) % (defun D () (interactive) (find-pdf-page "~/LATEX/2021burghardt.pdf")) % (defun d () (interactive) (find-pdftools-page "~/LATEX/2021burghardt.pdf")) % (defun e () (interactive) (find-LATEX "2021burghardt.tex")) % (defun u () (interactive) (find-latex-upload-links "2021burghardt")) % (defun v () (interactive) (find-2a '(e) '(d))) % (defun b () (interactive) (find-2a '(e) '(find-fline "/tmp/b.jpg"))) % (defun cv () (interactive) (C) (ee-kill-this-buffer) (v) (g)) % (defun d0 () (interactive) (find-ebuffer "2021burghardt.pdf")) % (code-eec-LATEX "2021burghardt") % (find-pdf-page "~/LATEX/2021burghardt.pdf") % (find-xournalpp "~/LATEX/2021burghardt.pdf") % (find-sh0 "cp -v ~/LATEX/2021burghardt.pdf /tmp/") % (find-sh0 "cp -v ~/LATEX/2021burghardt.pdf /tmp/pen/") % file:///home/edrx/LATEX/2021burghardt.pdf % file:///tmp/2021burghardt.pdf % file:///tmp/pen/2021burghardt.pdf % http://angg.twu.net/LATEX/2021burghardt.pdf % (find-LATEX "2019.mk") % (find-lualatex-links "2021burghardt") % https://en.wikipedia.org/wiki/Backus-Naur_form % https://en.wikipedia.org/wiki/Backus-Naur_form#Further_examples % https://en.wikipedia.org/wiki/Syntax_diagram % https://en.wikipedia.org/wiki/Extended_Backus-Naur_form % https://en.wikipedia.org/wiki/Context-free_grammar *** % (find-books "__comp/__comp.el" "kernighan-ritchie") % (find-books "__comp/__comp.el" "thain") % (find-es "dednat" "burghardt") % «.tree» (to "tree") \documentclass[oneside,12pt]{article} \usepackage[colorlinks,citecolor=DarkRed,urlcolor=DarkRed]{hyperref} % (find-es "tex" "hyperref") \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{pict2e} \usepackage[x11names,svgnames]{xcolor} % (find-es "tex" "xcolor") %\usepackage{colorweb} % (find-es "tex" "colorweb") %\usepackage{tikz} % % (find-dn6 "preamble6.lua" "preamble0") \usepackage{proof} % For derivation trees ("%:" lines) %\input diagxy % For 2D diagrams ("%D" lines) %\xyoption{curve} % For the ".curve=" feature in 2D diagrams % \usepackage{edrx21} % (find-LATEX "edrx21.sty") \input edrxaccents.tex % (find-LATEX "edrxaccents.tex") \input edrxchars.tex % (find-LATEX "edrxchars.tex") \input edrxheadfoot.tex % (find-LATEX "edrxheadfoot.tex") \input edrxgac2.tex % (find-LATEX "edrxgac2.tex") % % (find-es "tex" "geometry") \begin{document} \catcode`\^^J=10 \directlua{dofile "dednat6load.lua"} % (find-LATEX "dednat6load.lua") \thispagestyle{empty} \def\NT<#1>{〈\textsf{#1}〉} \def\T#1{\ColorRed{\tt#1}} \def\T#1{\mathstrut \ColorRed{\tt#1}} Adapted from: \url{https://en.wikipedia.org/wiki/Context-free_grammar} \bsk \bsk $\begin{array}{rcl} \NT<Stmt> &→& \NT<Id> \; \T{=} \; \NT<Expr> \; \T{;} \\ \NT<Stmt> &→& \T{\{} \; \NT<StmtList> \; \T{\}} \\ \NT<Stmt> &→& \T{if} \; \T{(} \; \NT<Expr> \; \T{)} \; \NT<Stmt> \\ \NT<StmtList> &→& \NT<Stmt> \\ \NT<StmtList> &→& \NT<StmtList> \NT<Stmt> \\ \NT<Expr> &→& \NT<Id> \\ \NT<Expr> &→& \NT<Num> \\ \NT<Expr> &→& \NT<Expr> \; \NT<Optr> \; \NT<Expr> \\ \NT<Id> &→& \T{x} \\ \NT<Id> &→& \T{y} \\ \NT<Num> &→& \T{0} \\ \NT<Num> &→& \T{1} \\ \NT<Num> &→& \T{9} \\ \NT<Optr> &→& \T{>} \\ \NT<Optr> &→& \T{+} \\ \end{array} $ % «tree» (to ".tree") %: %: \T{0} %: -------- %: \T{x} \NT<Num> \T{y} \T{+} \T{1} %: ------- --------- --------- --------- --------- %: \NT<Id> \T{=} \NT<Expr> \T{;} \T{y} \NT<Expr> \NT<Optr> \NT<Expr> %: ----------------------------- ------- ----------------------------- %: \T{x} \T{9} \NT<Stmt> \NT<Id> \T{=} \NT<Expr> \T{;} %: ------- -------- ------------- -------------------------------------------------- %: \NT<Id> \T{>} \NT<Num> \T{\{} \NT<StmtList> \NT<Stmt> \T{\}} %: --------- --------- --------- --------------------------------------------------------------------------------------- %: \NT<Expr> \NT<Optr> \NT<Expr> \NT<StmtList> %: ----------------------------- ------------- %: \T{if} \T{(} \NT<Expr> \T{)} \NT<Stmt> %: ---------------------------------------------------------- %: \NT<Stmt> %: %: ^Bur-tree %: \pu %\hspace*{-4cm} %$\ded{Bur-tree}$ $\scalebox{0.7}{$ \ded{Bur-tree} $} $ \def\und#1#2{\underbrace{#1}_{\textstyle#2}} %L -- (find-es "dednat" "burghardt") %L -- (find-angg "LUA/Rect.lua" "undtolatex") %L %L undtolatex = function (o, pre) %L if type(o) == "string" then return o end %L if type(o) == "number" then return tostring(o) end %L if type(o) == "table" and #o == 0 then return o[0] end %L local s = " " %L local f = function (o) return undtolatex(o, pre..s).."\n"..pre..s end %L pre = pre or "" %L local upper = mapconcat(f, o, "") %L local lower = "}{"..o[0].."}" %L return "\\und{"..upper..lower %L end %L %L caretsegs = {} %L for n,segments in pairs(allsegments) do %L local seg = segments[1] %L if seg and seg.t:match("^^") then print(seg); caretsegs[seg.t] = seg end %L end %L caretseg = caretsegs["^Bur-tree"] %L tree = caretseg:rootnode():totreenode() %L defbody = undtolatex(tree) %L deffull = "\\def\\BurUnd{\n"..defbody.."\n}" %L output(deffull) \pu \bsk \bsk % Slightly changed version: % \def\BurUnd{ \und{\T{if} \;\; \T{(} \und{\und{\und{\T{x} }{\NT<Id>} }{\NT<Expr>} \und{\T{>} }{\NT<Optr>} \und{\und{\T{9} }{\NT<Num>} }{\NT<Expr>} }{\NT<Expr>} \T{)} \; \und{\und{\T{\{} \und{\und{\und{\T{x} }{\NT<Id>} \T{=} \und{\und{\T{0} }{\NT<Num>} }{\NT<Expr>} \T{;} }{\NT<Stmt>} }{\NT<StmtList>} \und{\und{\T{y} }{\NT<Id>} \T{=} \und{\und{\T{y} }{\NT<Expr>} \und{\T{+} }{\NT<Optr>} \und{\T{1} }{\NT<Expr>} }{\NT<Expr>} \T{;} }{\NT<Stmt>} \; \T{\}} }{\NT<StmtList>} }{\NT<Stmt>} }{\NT<Stmt>} } $\BurUnd$ \GenericWarning{Success:}{Success!!!} % Used by `M-x cv' \end{document} % __ __ _ % | \/ | __ _| | _____ % | |\/| |/ _` | |/ / _ \ % | | | | (_| | < __/ % |_| |_|\__,_|_|\_\___| % % <make> * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # (find-LATEXfile "2019planar-has-1.mk") make -f 2019.mk STEM=2021burghardt veryclean make -f 2019.mk STEM=2021burghardt pdf * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd /tmp/ wget -O b.jpg https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/C_grammar_example_derivation.pdf/page1-800px-C_grammar_example_derivation.pdf.jpg # (find-fline "/tmp/b.jpg") % Local Variables: % coding: utf-8-unix % ee-tla: "NONE" % End: