The question title asks an unanswerable question about how (in general) to write a parser, but restricting to the code posted
\catcode`\@=11
\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,}
X\foreach \z in {a,b,c,d}{[\z]}X
\bye
The loop works but adds a lot of space to the output

Removing the space tokens from the definition prodces

\catcode`\@=11
\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,}
X\foreach \z in {a,b,c,d}{[\z]}X
\bye
It is harder to guess the intent of the calendar example.
\def\@testOccidental#1 #2, #3{
defines a command that takes three arguments, the first delimited by a space, the second by a comma and space and the third being an un-delimited {..} argument.
You only use this in one place, as \@testOccidental\subject where there is just a single token and no space or comma delimiters. \subject is defined by \def\subject{\today} so \ifx\subject\month is always going to be false, (and \month is a bad name for the loop variable as it is a TeX primitive for the current month number)
Trying to guess the intention of the loop over the months, perhaps something like:

\catcode`\@=11
\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,}
X\foreach \z in {a,b,c,d}{[\z]}X
\def\@testOccidental#1 #2, #3\relax{%
\def\subject{#1}%
\foreach \xmonth in {January,February,March,April,May,June,July,August,October,September,November,December}{%
\ifx\subject\xmonth
#1 #2, #3 (Occidental Solar)\par
\else
not \xmonth\par % just for debugging
\fi
}%
}
\def\checkCalendar#1{%
\@testOccidental#1\relax
}
\checkCalendar{June 7, 2019}
\bye
\@testOccidentalis defined with three arguments, you only pass one. – egreg Jun 07 '19 at 20:58%your iterate loop will insert several spaces at each iteration. – David Carlisle Jun 07 '19 at 21:18listofitems.texas a plain-TeX package input, for nested parsing tools. https://ctan.org/pkg/listofitems – Steven B. Segletes Jun 07 '19 at 22:08