Skip to content

Commit

Permalink
complete lexical part
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdihaghverdi committed Dec 29, 2023
1 parent ebdf474 commit d641405
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 0 deletions.
Binary file modified Extra3/RTP-EXTRA03-02-4003613023.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions Extra3/RTP-EXTRA03-02-4003613023.tex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
\usepackage{listings}
\usepackage{docs/style}

\newcommand{\token}[1]{\left\langle\text{\lr{\textbf{id}}}, \text{\lr{#1}}\right\rangle}

\usepackage{xepersian}
\settextfont{Yas}

Expand Down
Binary file added Extra3/docs/images/generator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Extra3/docs/images/intermediate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Extra3/docs/images/optimizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Extra3/docs/images/semantic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Extra3/docs/images/symboltable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Extra3/docs/images/syntax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions Extra3/docs/structure.tex
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,52 @@ \section{ساختار یک کامپایلر}
\end{center}
\end{figure}
\end{frame}

\begin{frame}{تحلیل واژگانی \lr{(Lexical Analysis)}}
\begin{itemize}\itemr
\item[-]
اولین کار کامپایلر اسکن کردن فایل داده شده و شکستن آن به توکن‌های کوچک‌تریست که در آن زبان تعریف شده.

\item[-]
چیزی که تحلیل‌گر واژگان تولید می‌کند، دنباله‌ای از چنین ترکیبی‌ست:
\begin{equation*}
\left\langle\text{\lr{token-name}}, \text{\lr{attribute-value}}\right\rangle
\end{equation*}
\end{itemize}
\end{frame}

\begin{frame}{تحلیل واژگانی \lr{(Lexical Analysis)}}
\begin{itemize}\itemr
\item[-]
فرض کنید چنین عبارتی را می‌خواهیم آنالیز کنیم:

\begin{flushleft}
\lr{\texttt{position = initial + rate * 60}}
\end{flushleft}
\item[-]
چیزی که تحلیل‌گر واژگان تولید می‌کند:
\begin{equation*}
\token{1}
\left\langle\text{\lr{\texttt{=}}}\right\rangle
\token{2}
\left\langle\text{\lr{\texttt{+}}}\right\rangle
\token{3}
\left\langle\ast\right\rangle
\left\langle\text{\lr{\texttt{60}}}\right\rangle
\end{equation*}

\item[-]
که
\lr{\textbf{id}}
مخفف
\lr{identifier}
و عدد روبه‌روی آن اندیس
\lr{symbol table}
است.
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.25\textwidth, height=0.3\textheight]{docs/images/symboltable}
\end{center}
\end{figure}
\end{itemize}
\end{frame}

0 comments on commit d641405

Please sign in to comment.