In what ways can one write a parser in plain TeX or packageless LaTeX?

by Anonymouse   Last Updated June 07, 2019 21:23 PM

I want to write my own document class as a literate program with as minimal of a dependency tree as possible as an exercise to test my ability.

I've implemented a stable foreach loop by shredding an argument, but similarly attempting to parse a calendar failed.

\def\@pointer{\@pointer}
\long\def\@iterate#1#2#3,{
    \def\cell{#3}
    \ifx\cell\@pointer
        \let\next=\relax
    \else
        \def#1{#3}
        #2
        \def\next{\@iterate{#1}{#2}}
    \fi
    \next
}
\long\gdef\foreach#1in#2#3%
{\@iterate{#1}{#3}#2,\@pointer,}

\def\@testOccidental#1 #2, #3{
    \def\subject{#1}
    \foreach \month in {January,February,March,April,May,June,July,August,October,September,November,December}{
        \ifx\subject\month
            #1 #2, #3 (Occidental Solar)
        \fi
    }
}
\def\checkCalendar#1{
    \def\subject{#1}
    \@testOccidental\subject
}

\checkCalendar{\today}


Related Questions


Updated April 23, 2015 20:10 PM

Updated May 15, 2016 08:09 AM

Updated April 04, 2019 20:23 PM

Updated May 02, 2019 23:23 PM