📄 semantic.tex
字号:
\chapter{Semantic Checks}\label{sem_check_c}The syntax of \hysdel{} is defined in the grammar. The parser only accepts input that is syntactically correct.However, this does not mean that it is a correct \hysdel{} source. The input also has to be semantically correct.Checking this is done immediately after the parsing step.\section{Basic Checks}Semantic checks are implemented in the methods called \function{semantic\_checks}. The following checks areperformed:\begin{itemize}\item in \cppclass{Var\_symbol}: \begin{itemize} \item variables must not be defined twice. \item variable definitions must not be circular. (e.g., a=b; b=c; c=a; is not allowed) \end{itemize}\item in \cppclass{Expr}: \begin{itemize} \item arguments of operators have the right type (real or Boolean). \item no output variable is used.\end{itemize}\item in \cppclass{Item}: The semantic conditions mentioned in section \ref{Item_section} must be fulfilled (the grammar guarantees that the variables have the right type).\item in \cppclass{Min\_max\_eps}: Minimum, maximum and epsilon must be constant.\end{itemize}\section{Argument Range Checks}Mathematical operators have a domain of definition. For example, a division by zero is not allowed, therefore thedomain of definition of '$/$' is $\mathbb{R} \times \mathbb{R}\setminus \{0\}$. The\hysdel{} compiler has to check that all arguments are within the domain. \method{Expr}{arg\_range\_check\_matlab}performs these checks.What kind of checks are possible depends on the arguments and fall in three categories:\begin{itemize}\item the argument contains variables: no check is possible\item the argument is constant but contains symbolic variables: create \matlab{} code to check range when symbolicparameters are known.\item the argument is constant and contains no symbolic variables: checks can be performed at compile time,violations result in compilation errors.\end{itemize}The following range checks are implemented:\begin{itemize}\item Division by zero\item Logarithm of a non positive number\item Square root of a negative number\end{itemize}%bad identifer name ('.', ':', '_')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -