basicdoc: wip

This commit is contained in:
minjaesong
2020-12-25 13:44:45 +09:00
parent 36f2c887d3
commit 796a63f579
3 changed files with 101 additions and 37 deletions

View File

@@ -99,11 +99,11 @@ Functions are a form of expression that may taks input arguments surrounded by p
\section{Output}
\subsection{EMIT}
\codeline{\textbf{EMIT(}EXPR [\{\textbf{,}|\textbf{;}\} EXPR]\ldots\textbf{)}}\par
\codeline{\textbf{EMIT(} EXPR [\{\textbf{,}|\textbf{;}\} EXPR]\ldots\ \textbf{)}}\par
Prints out characters corresponding to given number on the code page being used.\par
\code{EXPR} is numeric expression.
\subsection{PRINT}
\codeline{\textbf{PRINT(}EXPR [\{\textbf{,}|\textbf{;}\} EXPR]\ldots\textbf{)}}\par
\codeline{\textbf{PRINT(} EXPR [\{\textbf{,}|\textbf{;}\} EXPR]\ldots\ \textbf{)}}\par
Prints out given string expressions.\par
\code{EXPR} is a string, numeric expression, or array.\par
\code{PRINT} is one of the few function that differentiates two style of argument separator: \codebf{;} will simply concatenate two expressions (unlike traditional BASIC, numbers will not have surrounding spaces), \codebf{,} tabulates the expressions.
@@ -155,38 +155,38 @@ Functions are a form of expression that may taks input arguments surrounded by p
\codeline{CHAR \textbf{= CHR(}X\textbf{)}}\par
Returns the character with code point of \code{X}. Code point is a numeric expression in the range of $[0-255]$.
\subsection{LEFT}
\codeline{SUBSTR \textbf{= LEFT(}STR \textbf{,} NUM\_CHARS\textbf{)}}\par
\codeline{SUBSTR \textbf{= LEFT(} STR \textbf{,} NUM\_CHARS \textbf{)}}\par
Returns the leftmost \code{NUM\_CHARS} characters of \code{STR}.
\subsection{MID}
\codeline{SUBSTR \textbf{= MID(}STR \textbf{,} POSITION \textbf{,} LENGTH\textbf{)}}\par
\codeline{SUBSTR \textbf{= MID(} STR \textbf{,} POSITION \textbf{,} LENGTH \textbf{)}}\par
Returns a substring of \code{STR} starting at \code{POSITION} with specified \code{LENGTH}.\par
When \code{OPTIONBASE 1} is specified, the position starts from 1; otherwise it will start from 0.
\subsection{RIGHT}
\codeline{SUBSTR \textbf{= RIGHT(}STR \textbf{,} NUM\_CHARS\textbf{)}}\par
\codeline{SUBSTR \textbf{= RIGHT(} STR \textbf{,} NUM\_CHARS \textbf{)}}\par
Returns the rightmost \code{NUM\_CHARS} characters of \code{STR}.
\subsection{SPC}
\codeline{STR \textbf{= SPC(}STR \textbf{,} NUM\_CHARS\textbf{)}}\par
\codeline{STR \textbf{= SPC(} STR \textbf{,} NUM\_CHARS \textbf{)}}\par
Returns a string of \code{NUM\_CHARS} spaces.
\section{Array Manipulation}
\subsection{HEAD}
\codeline{K \textbf{= HEAD(}ARRAY\textbf{)}}\par
Returns the head element of the given array.
\codeline{K \textbf{= HEAD(}X\textbf{)}}\par
Returns the head element of the array \code{X}.
\subsection{INIT}
\codeline{K \textbf{= INIT(}ARRAY\textbf{)}}\par
Returns the new array that has its last element removed.
\codeline{K \textbf{= INIT(}X\textbf{)}}\par
Constructs the new array from array \code{X} that has its last element removed.
\subsection{LAST}
\codeline{K \textbf{= LAST(}ARRAY\textbf{)}}\par
Returns the last element of the given array.
\codeline{K \textbf{= LAST(}X\textbf{)}}\par
Returns the last element of the array \code{X}.
\subsection{TAIL}
\codeline{K \textbf{= TAIL(}ARRAY\textbf{)}}\par
Returns the new array that has its head element removed.
\codeline{K \textbf{= TAIL(}X\textbf{)}}\par
Constructs the new array from array \code{X} that has its head element removed.
\section{Graphics}
\subsection{PLOT}
\codeline{\textbf{PLOT(}X\_POS \textbf{,} Y\_POS \textbf{,} COLOUR\textbf{)}}\par
\codeline{\textbf{PLOT(} X\_POS \textbf{,} Y\_POS \textbf{,} COLOUR \textbf{)}}\par
Plots a pixel to the framebuffer of the display, at XY-position of \code{X\_POS} and \code{Y\_POS}, with colour of \code{COLOUR}.\par
Top-left corner of the pixel will be 1 if \code{OPTIONBASE 1} is specified; otherwise it will be 0.
@@ -201,24 +201,50 @@ Functions are a form of expression that may taks input arguments surrounded by p
\subsection{OPTIONTRACE}
\codeline{\textbf{OPTIONTRACE} \{\textbf{0}|\textbf{1}\}}\par
Specifies whether or not the line numbers should be printed out. The messages will be printed out to the \emph{serial debugging console}, or to the stdout.
\subsection{TYPEOF}
\codeline{X \textbf{= TYPEOF(} VALUE \textbf{)}}\par
Returns a type of given value.\par
\begin{longtable}{*{2}{m{\textwidth}}}\hline
\endfirsthead
\endhead
\endfoot
\hline
\endlastfoot
\centering
\begin{tabulary}{\textwidth}{rl}
BASIC Type & Returned Value \\
\hline
Number & \ttfamily{num} \\
Boolean & \ttfamily{bool} \\
String & \ttfamily{str} \\
\end{tabulary}
\begin{tabulary}{\textwidth}{rl}
BASIC Type & Returned Value \\
\hline
Array & \ttfamily{array} \\
Generator & \ttfamily{generator} \\
User Function & \ttfamily{usrdefun}
\end{tabulary}
\end{longtable}
\section{System}
\subsection{PEEK}
\codeline{BYTE \textbf{= PEEK(}MEM\_ADDR\textbf{)}}\par
\codeline{BYTE \textbf{= PEEK(} MEM\_ADDR \textbf{)}}\par
Returns whatever the value stored in the \code{MEM\_ADDR} of the Scratchpad Memory.\par
Address mirroring, illegal access, etc. are entirely up to the virtual machine which the BASIC interpreter is running on.
\subsection{POKE}
\codeline{\textbf{POKE(}MEM\_ADDR \textbf{,} BYTE\textbf{)}}\par
\codeline{\textbf{POKE(} MEM\_ADDR \textbf{,} BYTE \textbf{)}}\par
Puts a \code{BYTE} into the \code{MEM\_ADDR} of the Scratchpad Memory.
\section{Higher-order Function}
\subsection{DO}
\codeline{\textbf{DO(}EXPR0 [\textbf{;} EXPR1]\ldots\textbf{)}}\par
\codeline{\textbf{DO(} EXPR0 [\textbf{;} EXPR1]\ldots\ \textbf{)}}\par
Executes \code{EXPRn}s sequentially.
\subsection{FILTER}
\codeline{NEWLIST \textbf{= FILTER(}FUNCTION \textbf{,} ITERABLE\textbf{)}}\par
\codeline{NEWLIST \textbf{= FILTER(} FUNCTION \textbf{,} ITERABLE \textbf{)}}\par
Returns an array of values from the \code{ITERABLE} that passes the given function. i.e. values that makes \code{FUNCTION(VALUE\_FROM\_ITERABLE)} true.
\subsubsection*{Parameters}
\begin{itemlist}
@@ -226,14 +252,14 @@ Functions are a form of expression that may taks input arguments surrounded by p
\item \code{ITERABLE} is either an array or a generator.
\end{itemlist}
\subsection{FOLD}
\codeline{NEWVALUE \textbf{= FOLD(}FUNCTION \textbf{,} INIT\_VALUE \textbf{,} ITERABLE\textbf{)}}\par
\codeline{NEWVALUE \textbf{= FOLD(} FUNCTION \textbf{,} INIT\_VALUE \textbf{,} ITERABLE \textbf{)}}\par
Iteratively applies given function with accumulator and the value from the \code{ITERABLE}, returning the final accumulator. Accumulator will be set to \code{INIT\_VALUE} before iterating over the iterable. In the first execution, the accumulator will be set to \code{ACC=FUNCTION(ACC,ITERABLE(0))}, and the execution will continue to remaining values within the iterable until all values are consumed. The \code{ITERABLE} will not be modified after the execution.
\subsubsection*{Parameters}
\begin{itemlist}
\item \code{FUNCTION} is a user-defined function with two parameters: first parameter being accumulator and second being a value.
\end{itemlist}
\subsection{MAP}
\codeline{NEWLIST \textbf{= MAP(}FUNCTION \textbf{,} ITERABLE\textbf{)}}\par
\codeline{NEWLIST \textbf{= MAP(} FUNCTION \textbf{,} ITERABLE \textbf{)}}\par
Applies given function onto the every element in the iterable, and returns an array that contains such items. i.e. returns tranformation of \code{ITERABLE} of which the transformation is \code{FUNCTION}. The \code{ITERABLE} will not be modified after the execution.
\subsubsection*{Parameters}
\begin{itemlist}