mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
basicdoc: keycodes, latex code cleanup, split long table
This commit is contained in:
@@ -101,11 +101,7 @@ Functions are a form of expression that may taks input arguments surrounded by p
|
||||
Clears all declared variables.
|
||||
\subsection{DATA}
|
||||
\codeline{\textbf{DATA} CONST0 [\textbf{,} CONST1]\ldots}\par
|
||||
Adds data that can be read by \code{READ} function.
|
||||
\subsubsection*{Notes}
|
||||
\begin{itemlist}
|
||||
\item \code{DATA} declarations need not be reacheable in the program flow.
|
||||
\end{itemlist}
|
||||
Adds data that can be read by \code{READ} function. \code{DATA} declarations need not be reacheable in the program flow.
|
||||
\subsection{END}
|
||||
\codeline{\textbf{END}}\par
|
||||
Stops program execution and returns control to the user.
|
||||
@@ -158,7 +154,7 @@ Functions are a form of expression that may taks input arguments surrounded by p
|
||||
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
|
||||
@@ -177,12 +173,10 @@ Functions are a form of expression that may taks input arguments surrounded by p
|
||||
Specifies at which number the array/string/pixel indices begin.
|
||||
\subsection{OPTIONDEBUG}
|
||||
\codeline{\textbf{OPTIONDEBUG} \{\textbf{0}|\textbf{1}\}}\par
|
||||
Specifies whether or not the debugging messages should be printed out.\par
|
||||
The messages will be printed out to the \emph{serial debugging console}, or to the stdout.
|
||||
Specifies whether or not the debugging messages should be printed out. The messages will be printed out to the \emph{serial debugging console}, or to the stdout.
|
||||
\subsection{OPTIONTRACE}
|
||||
\codeline{\textbf{OPTIONTRACE} \{\textbf{0}|\textbf{1}\}}\par
|
||||
Specifies whether or not the line numbers should be printed out.\par
|
||||
The messages will be printed out to the \emph{serial debugging console}, or to the stdout.
|
||||
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.
|
||||
|
||||
\section{System}
|
||||
|
||||
|
||||
@@ -1,2 +1,123 @@
|
||||
\label{implementation}
|
||||
Keycodes follow LWJGL2 lol
|
||||
|
||||
This chapter explains implementation details of \tbas{} running on TSVM.
|
||||
|
||||
\section{Keycodes}
|
||||
|
||||
This is a keycodes recognised by LibGDX, a framework that TSVM runs on.
|
||||
|
||||
\begin{longtable}{*{2}{m{\textwidth}}}\hline
|
||||
\endfirsthead
|
||||
\endhead
|
||||
|
||||
\endfoot
|
||||
\hline
|
||||
\endlastfoot
|
||||
\centering
|
||||
\begin{tabulary}{\textwidth}{rl}
|
||||
Key & Code \\
|
||||
\hline
|
||||
\ttfamily{1} & 8 \\
|
||||
\ttfamily{2} & 9 \\
|
||||
\ttfamily{3} & 10 \\
|
||||
\ttfamily{4} & 11 \\
|
||||
\ttfamily{5} & 12 \\
|
||||
\ttfamily{6} & 13 \\
|
||||
\ttfamily{7} & 14 \\
|
||||
\ttfamily{8} & 15 \\
|
||||
\ttfamily{9} & 16 \\
|
||||
\ttfamily{0} & 17 \\
|
||||
$\hookleftarrow$ & 66 \\
|
||||
\condensedfont{BkSp} & 67 \\
|
||||
\condensedfont{Tab} & 61 \\
|
||||
\ttfamily{`} & 68 \\
|
||||
\ttfamily{'} & 75 \\
|
||||
\ttfamily{;} & 43 \\
|
||||
\ttfamily{,} & 55 \\
|
||||
\ttfamily{.} & 56 \\
|
||||
\ttfamily{/} & 76 \\
|
||||
\ttfamily{[}\hspace*{0.083em} & 71 \\
|
||||
\ttfamily{]}\hspace*{-0.083em} & 72 \\
|
||||
\ttfamily{-} & 69 \\
|
||||
\end{tabulary}
|
||||
\begin{tabulary}{\textwidth}{rl}
|
||||
Key & Code \\
|
||||
\hline
|
||||
\ttfamily{+} & 70 \\
|
||||
\ttfamily{A} & 29 \\
|
||||
\ttfamily{B} & 30 \\
|
||||
\ttfamily{C} & 31 \\
|
||||
\ttfamily{D} & 32\\
|
||||
\ttfamily{E} & 33 \\
|
||||
\ttfamily{F} & 34 \\
|
||||
\ttfamily{G} & 35 \\
|
||||
\ttfamily{H} & 36 \\
|
||||
\ttfamily{I} & 37 \\
|
||||
\ttfamily{J} & 38 \\
|
||||
\ttfamily{K} & 39 \\
|
||||
\ttfamily{L} & 40 \\
|
||||
\ttfamily{M} & 41 \\
|
||||
\ttfamily{N} & 42 \\
|
||||
\ttfamily{O} & 43 \\
|
||||
\ttfamily{P} & 44 \\
|
||||
\ttfamily{Q} & 45 \\
|
||||
\ttfamily{R} & 46 \\
|
||||
\ttfamily{S} & 47 \\
|
||||
\ttfamily{T} & 48 \\
|
||||
\ttfamily{U} & 49 \\
|
||||
\end{tabulary}
|
||||
\begin{tabulary}{\textwidth}{rl}
|
||||
Key & Code \\
|
||||
\hline
|
||||
\ttfamily{V} & 50 \\
|
||||
\ttfamily{W} & 51 \\
|
||||
\ttfamily{X} & 52 \\
|
||||
\ttfamily{Y} & 53 \\
|
||||
\ttfamily{Z} & 54 \\
|
||||
\condensedfont{LCtrl} & 57 \\
|
||||
\condensedfont{RCtrl} & 58 \\
|
||||
\condensedfont{LShift} & 59 \\
|
||||
\condensedfont{RShift} & 60 \\
|
||||
\condensedfont{LAlt} & 129 \\
|
||||
\condensedfont{RAlt} & 130 \\
|
||||
$\uparrow$ & 19 \\
|
||||
$\downarrow$ & 20 \\
|
||||
$\leftarrow$ & 21 \\
|
||||
$\rightarrow$ & 22 \\
|
||||
\condensedfont{Ins} & 133 \\
|
||||
\condensedfont{Del} & 112 \\
|
||||
\condensedfont{PgUp} & 92 \\
|
||||
\condensedfont{PgDn} & 93 \\
|
||||
\condensedfont{Home} & 3 \\
|
||||
\condensedfont{End} & 132 \\
|
||||
F1 & 244 \\
|
||||
\end{tabulary}
|
||||
\begin{tabulary}{\textwidth}{rl}
|
||||
Key & Code \\
|
||||
\hline
|
||||
F2 & 245 \\
|
||||
F3 & 246 \\
|
||||
F4 & 247 \\
|
||||
F5 & 248 \\
|
||||
F6 & 249 \\
|
||||
F7 & 250 \\
|
||||
F8 & 251 \\
|
||||
F9 & 252 \\
|
||||
F10 & 253 \\
|
||||
F11 & 254 \\
|
||||
\condensedfont{Num} \ttfamily{0} & 144 \\
|
||||
\condensedfont{Num} \ttfamily{1} & 145 \\
|
||||
\condensedfont{Num} \ttfamily{2} & 146 \\
|
||||
\condensedfont{Num} \ttfamily{3} & 147 \\
|
||||
\condensedfont{Num} \ttfamily{4} & 148 \\
|
||||
\condensedfont{Num} \ttfamily{5} & 149 \\
|
||||
\condensedfont{Num} \ttfamily{6} & 150 \\
|
||||
\condensedfont{Num} \ttfamily{7} & 151 \\
|
||||
\condensedfont{Num} \ttfamily{8} & 152 \\
|
||||
\condensedfont{Num} \ttfamily{9} & 153 \\
|
||||
\condensedfont{NumLk} & 78 \\
|
||||
\ttfamily{*} & 17 \\
|
||||
\end{tabulary}
|
||||
\end{longtable}
|
||||
|
||||
Keys not listed on the table may not be available depending on the system, for example, F12 may not be recognised.
|
||||
|
||||
@@ -85,21 +85,43 @@ Float & $ \pm 4.9406564584124654 \times 10^{-324} $ -- $ \pm 1.7976931348623157
|
||||
|
||||
The order of precedence of the operators is as shown below, lower numbers means they have higher precedence (more tightly bound)
|
||||
|
||||
\begin{tabulary}{\textwidth}{cCc|cCc}
|
||||
Order & Op & Associativity & Order & Op & Associativity \\
|
||||
\hline
|
||||
1 & \basicexp & Right & 11 & \condensedfont{BXOR} & Left \\
|
||||
2 & \ast \quad $/$ \quad $\backslash$ & Left & 12 & \condensedfont{BOR} & Left \\
|
||||
3 & \condensedfont{MOD} & Left & 13 & \condensedfont{AND} & Left \\
|
||||
4 & $+$ \quad $-$ & Left & 14 & \condensedfont{OR} & Left \\
|
||||
5 & \condensedfont{NOT} \enskip \condensedfont{BNOT} & Left & 15 & \condensedfont{TO} \enskip \condensedfont{STEP} & Left \\
|
||||
6 & <\!< \quad >\!> & Left & 16 & ! & Right \\
|
||||
7 & < \enskip > \enskip <\!= \enskip =\!< \enskip >\!= \enskip =\!> & Left & 17 & \sim & Left\\
|
||||
8 & == \quad <\!> \quad >\!< & Left & 18 & \# & Left \\
|
||||
9 & \condensedfont{MIN} \enskip \condensedfont{MAX} & Left & 19 & \basiccurry & Right \\
|
||||
10 & \condensedfont{BAND} & Left & 20 & = & Right \\
|
||||
\end{tabulary}
|
||||
\begin{longtable}{*{2}{m{\textwidth}}}\hline
|
||||
\endfirsthead
|
||||
\endhead
|
||||
|
||||
\endfoot
|
||||
\hline
|
||||
\endlastfoot
|
||||
\centering
|
||||
\begin{tabulary}{\textwidth}{cCc}
|
||||
Order & Op & Associativity \\
|
||||
\hline
|
||||
1 & \basicexp & Right \\
|
||||
2 & \ast\quad$/$\quad$\backslash$ & Left \\
|
||||
3 & \condensedfont{MOD} & Left \\
|
||||
4 & $+$\quad$-$ & Left \\
|
||||
5 & \condensedfont{NOT}\quad\condensedfont{BNOT} & Left \\
|
||||
6 & <\!<\quad>\!> & Left \\
|
||||
7 & <\enskip>\enskip=\!<\enskip<\!=\enskip=\!>\enskip>\!= & Left \\
|
||||
8 & ==\quad<\!>\quad>\!< & Left \\
|
||||
9 & \condensedfont{MIN}\quad\condensedfont{MAX} & Left \\
|
||||
10 & \condensedfont{BAND} & Left \\
|
||||
\end{tabulary}
|
||||
\begin{tabulary}{\textwidth}{cCc}
|
||||
Order & Op & Associativity \\
|
||||
\hline
|
||||
11 & \condensedfont{BXOR} & Left \\
|
||||
12 & \condensedfont{BOR} & Left \\
|
||||
13 & \condensedfont{AND} & Left \\
|
||||
14 & \condensedfont{OR} & Left \\
|
||||
15 & \condensedfont{TO}\quad\condensedfont{STEP} & Left \\
|
||||
16 & ! & Right \\
|
||||
17 & \sim & Left\\
|
||||
18 & \# & Left \\
|
||||
19 & \basiccurry & Right \\
|
||||
20 & = & Right \\
|
||||
\end{tabulary}
|
||||
\end{longtable}
|
||||
|
||||
\subsubsection*{Examples}
|
||||
\begin{itemlist}
|
||||
@@ -227,7 +249,7 @@ Code & Operation & Result \\
|
||||
%{[}\emph{x},\,\emph{y}\ldots{]} \basicclosure{} \emph{e} & Closure & Creates a closure (anonymous function) from one or more parameters \emph{x},\,\emph{y}\ldots\ and an expression \emph{e} \\
|
||||
\end{tabulary}
|
||||
|
||||
\emph{Currying} is an operation that returns derivative of the function that has given value applied to its first parameter.\footnote{Do \emph{not} believe in that this is \emph{the} definition of currying. In the wild, currying is applied to cascades of \lambda-expressions and the behaviour is different to \tbas{}'s, even though it seems equivalent if you compare the function that two curries would produce.} See \ref{currying101} for tutorials.
|
||||
\emph{Currying} is an operation that returns new function that has given value applied to the original function's first parameter. See \ref{currying101} for tutorials.
|
||||
|
||||
\section{Syntax In EBNF}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ A Program line is composed of a line number and one or more statements. Multiple
|
||||
|
||||
\codeline{\textbf{IF} TRUTH\_VALUE \textbf{THEN} TRUE\_EXPRESSION [\textbf{ELSE} FALSE\_EXPERSSION]}
|
||||
|
||||
If \code{TRUTH\_VALUE} is truthy, executes \code{TRUE\_EXPRESSION}; if \code{TRUTH\_VALUE} is falsy and \code{FALSE\_EXPERSSION} is used, executes that expression, otherwise next line or next statement will be executed.
|
||||
If \code{TRUTH\_VALUE} is truthy, executes \code{TRUE\_EXPRESSION}. If \code{TRUTH\_VALUE} is falsy and \code{FALSE\_EXPERSSION} is specified, executes that expression; otherwise next line or next statement will be executed.
|
||||
|
||||
\subsubsection*{Notes}
|
||||
|
||||
@@ -20,7 +20,7 @@ If \code{TRUTH\_VALUE} is truthy, executes \code{TRUE\_EXPRESSION}; if \code{TRU
|
||||
|
||||
\codeline{\textbf{ON} INDEX\_EXPRESSION \{\textbf{GOTO}|\textbf{GOSUB}\} LINE0 [\textbf{,} LINE1]\ldots}
|
||||
|
||||
Jumps to \code{INDEX\_EXPRESSION}-th line number in the argements. If \code{INDEX\_EXPRESSION} is outside of range of the arguments, no jump will be performed.
|
||||
Jumps to the line number returned by the \code{INDEX\_EXPRESSION}. If the result is outside of range of the arguments, no jump will be performed.
|
||||
|
||||
\subsubsection*{Parameters}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
%% Copyright (c) 2020 CuriousTorvald and the contributors.
|
||||
|
||||
\documentclass[10pt, stock, openany]{memoir}
|
||||
\documentclass[10pt, stock, openany, chapter]{memoir}
|
||||
|
||||
|
||||
\usepackage{fontspec}
|
||||
@@ -20,6 +20,7 @@
|
||||
\usepackage{hyperref}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{tabulary}
|
||||
\usepackage{longtable}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{ltablex}
|
||||
\usepackage{parskip}
|
||||
@@ -29,6 +30,7 @@
|
||||
\usepackage{etoolbox}
|
||||
\usepackage[most]{tcolorbox}
|
||||
\usepackage{listings}
|
||||
\usepackage{amsmath,amssymb}
|
||||
|
||||
\usepackage{lineno} % debug
|
||||
|
||||
@@ -129,8 +131,9 @@
|
||||
tabsize=3
|
||||
}
|
||||
|
||||
%\aliaspagestyle{part}{empty}
|
||||
%\aliaspagestyle{chapter}{empty}
|
||||
\addtocontents{toc}{\protect\thispagestyle{empty}} % no page number for the TOC header page
|
||||
\aliaspagestyle{part}{empty} % aliasing PART as empty so that page number would not be printed
|
||||
\aliaspagestyle{chapter}{section} % aliasing CHAPTER as section so that page numbering style would be the same as section
|
||||
|
||||
|
||||
% The title
|
||||
@@ -157,7 +160,6 @@
|
||||
\end{titlingpage}
|
||||
|
||||
\setcounter{page}{3}
|
||||
|
||||
\tableofcontents*
|
||||
|
||||
|
||||
@@ -193,8 +195,6 @@
|
||||
\chapter{Implementation Details}
|
||||
\input{Implementation}
|
||||
|
||||
\chapter{Index}
|
||||
|
||||
\chapter{Bibliography}
|
||||
\input{bibliography}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ This section describes all use cases of \code{BasicVar}.
|
||||
|
||||
When a variable is \code{resolve}d, an object with instance of \code{BasicVar} is returned. A \code{bvType} of Javascript value is determined using \code{JStoBASICtype}.
|
||||
|
||||
\begin{tabulary}{\textwidth}{RLL}
|
||||
\begin{tabulary}{\textwidth}{R|LL}
|
||||
Typical User Input & TYPEOF(\textbf{Q}) & Instanceof \\
|
||||
\hline
|
||||
\code{\textbf{Q}=42.195} & {\ttfamily num} & \emph{primitive} \\
|
||||
|
||||
Reference in New Issue
Block a user