mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
basic: manual wip
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -42,3 +42,10 @@ tmp_*
|
||||
*.index
|
||||
*.threads
|
||||
*_Leak_Suspects.zip
|
||||
|
||||
# TeX outputs
|
||||
*.aux
|
||||
*.log
|
||||
*.out
|
||||
*.pdf
|
||||
*.toc
|
||||
|
||||
22
assets/tbas/doc/concepts.tex
Normal file
22
assets/tbas/doc/concepts.tex
Normal file
@@ -0,0 +1,22 @@
|
||||
This chapter describes the basic concepts of the language.
|
||||
|
||||
|
||||
\section{Values and Types}
|
||||
|
||||
BASIC is a \emph{Dynamically Typed Language}, which means variables do not know which group they should barge in; only values of the variable do. In fact, there is no type definition in the language: We do want our variables to feel themselves awkward.
|
||||
|
||||
There are five basic types: \emph{undefined}, \emph{boolean}, \emph{number}, \emph{string}, \emph{array}, \emph{generator} and \emph{function}.
|
||||
|
||||
\emph{Undefined} is the type of the literal value \textbf{undefined}, who likes to possess nothing (I think he's secretly a buddhist).
|
||||
|
||||
\emph{Boolean} is the type of the values that is either \textbf{TRUE} or \textbf{FALSE}, he knows no in-between. \textbf{undefined}, \emph{number 0} and \textbf{FALSE} makes condition \emph{false}.
|
||||
|
||||
\emph{Number} represents real (double-precision floating-point or \emph{actually rational}) numbers. Operations on numbers follow the same rules of the underlying virtual machine\footnote{if you are not a computer person, just disregard}, and such machines must follow the IEEE 754 standard\footnote{ditto.}.
|
||||
|
||||
\emph{String} represents immutable\footnote{cannot be altered directly} sequences of bytes. However, you can't weave them to make something like \emph{string array}\footnote{future feature\ldots maybe\ldots? Probably not\ldots}.
|
||||
|
||||
\emph{Array} represents collection of numbers in 1-- or more dimensions.
|
||||
|
||||
\emph{Generator} represents a value that automatically counts up/down whenever they have been called in For-Next loop.
|
||||
|
||||
\emph{Functions} are, well\ldots functions\footnote{This is no {\lambda}-expression; there is no way you can define local-- or anonymous variable in BASIC.}, especially user-defined ones. Functions are \emph{type} because some built-in functions will actually take \emph{functions} as arguments.
|
||||
5
assets/tbas/doc/intro.tex
Normal file
5
assets/tbas/doc/intro.tex
Normal file
@@ -0,0 +1,5 @@
|
||||
\tbas{} is a BASIC dialect and its interpreter. \tbas emulates most of the common BASIC syntax while adds more advanced and up-to-date concepts gracefully, such as user-defined function that can \emph{actually} recurse, arbitrary list construction using CONS-operator and some of the features on functional programming such as \code{MAP} and \code{FOLD}.
|
||||
|
||||
This is the documentation for \tbas{} \tbasver{}.
|
||||
|
||||
\small\emph{Henceforward this documentation will use more friendly and sometimes vulgar language because that's more fun to write!}
|
||||
0
assets/tbas/doc/langguide.tex
Normal file
0
assets/tbas/doc/langguide.tex
Normal file
20
assets/tbas/doc/langref.tex
Normal file
20
assets/tbas/doc/langref.tex
Normal file
@@ -0,0 +1,20 @@
|
||||
This chapter descibes the \tbas{} language.
|
||||
|
||||
\section{Metasyntax}
|
||||
|
||||
In the descriptions of BASIC syntax, this conventions apply.
|
||||
\\
|
||||
|
||||
\begin{itemize}
|
||||
\item \codebf{"VERBATIM"} --- Type exactly as shown
|
||||
\item \code{IDENTIFIER} --- Replace \emph{identifier} with appropriate metavariable
|
||||
\item \code{[a]} --- Words within square brackets are optional
|
||||
\item \code{\{a|b\}} --- Choose either \code{a} or \code{b}
|
||||
\item \code{[a|b]} --- Optional version of above
|
||||
\item \code{a...} --- The preceding entity can be repeated
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\section{Syntax In EBNF}
|
||||
|
||||
\small\verbatiminput{syntax.txt}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
150
assets/tbas/doc/tbasman.tex
Normal file
150
assets/tbas/doc/tbasman.tex
Normal file
@@ -0,0 +1,150 @@
|
||||
|
||||
% !TEX TS-program = LuaLaTeX
|
||||
|
||||
%% Copyright (c) 2016 Torvald (minjaesong) and the contributors. Freely available under the terms of the MIT License.
|
||||
|
||||
\documentclass[10pt, stock, openany]{memoir}
|
||||
|
||||
|
||||
\usepackage{fontspec}
|
||||
\setmainfont[Ligatures=TeX]{TeX Gyre Heros}
|
||||
\newfontfamily\condensedfont{TeX Gyre Heros Cn}
|
||||
\newfontfamily\monofont{TeX Gyre Cursor}
|
||||
|
||||
|
||||
|
||||
|
||||
\usepackage{fapapersize}
|
||||
\usefapapersize{148mm,210mm,15mm,15mm,20mm,15mm} % A5 paper
|
||||
\usepackage{afterpage}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{ltablex}
|
||||
\usepackage{parskip}
|
||||
\usepackage{multicol}
|
||||
\usepackage{soul}
|
||||
\usepackage{verbatim}
|
||||
|
||||
\usepackage{lineno} % debug
|
||||
|
||||
|
||||
\makeatletter
|
||||
\newlength{\mytextsize}
|
||||
\setlength{\mytextsize}{\f@size pt}
|
||||
\newlength{\mybaselineskip}
|
||||
\setlength{\mybaselineskip}{1.3\mytextsize}
|
||||
\makeatother
|
||||
\setlength{\baselineskip}{\mybaselineskip}
|
||||
|
||||
\usepackage[fontsize=\mytextsize,baseline=\baselineskip,lines=38]{grid}
|
||||
|
||||
\frenchspacing
|
||||
\setlength{\parindent}{0pt}
|
||||
\setlength{\parskip}{10pt}
|
||||
\setsecnumdepth{subsection}
|
||||
|
||||
|
||||
%% Idioms %%
|
||||
\hyphenation{Com-put-er-Craft}
|
||||
\hyphenation{O-pen-Com-put-ers}
|
||||
\hyphenation{T-BASIC}
|
||||
|
||||
|
||||
\newcommand\forceindent{\hskip1.5em}
|
||||
|
||||
|
||||
% Title styling
|
||||
\pretitle{\begin{flushright}}
|
||||
\posttitle{\par\end{flushright}}
|
||||
\preauthor{\begin{flushright}}
|
||||
\postauthor{\par\end{flushright}}
|
||||
|
||||
% new sections are new page
|
||||
%\let\oldsection\chapter
|
||||
%\renewcommand\chapter{\clearpage\oldsection}
|
||||
|
||||
% chapter title -- no now page after
|
||||
\renewcommand\chapterheadstart{} % kill the drop
|
||||
\renewcommand\afterchapternum{\vskip 0.5em} % space between number and title
|
||||
\setlength{\afterchapskip}{\baselineskip} % reduce space after chapter title
|
||||
\makeatletter
|
||||
\renewcommand\memendofchapterhook{%
|
||||
\m@mindentafterchapter\@afterheading}
|
||||
\makeatother
|
||||
|
||||
% section/chapter header spacing
|
||||
\let\oldsection\section
|
||||
\renewcommand{\section}[1]{\oldsection{#1} \vskip\baselineskip}
|
||||
|
||||
|
||||
\definecolor{lgrey}{HTML}{eeeeee}
|
||||
\sethlcolor{lgrey}
|
||||
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
|
||||
\newcommand{\code}[1]{{\monofont\hl{#1}}}
|
||||
\newcommand{\codebf}[1]{{\monofont \textbf{\hl{#1}}}}
|
||||
|
||||
|
||||
%\aliaspagestyle{part}{empty}
|
||||
%\aliaspagestyle{chapter}{empty}
|
||||
|
||||
|
||||
% The title
|
||||
\newcommand{\tbas}{Terran BASIC}
|
||||
\newcommand{\tbasver}{1.0}
|
||||
\newcommand{\theedition}{First Edition}
|
||||
\newcommand{\oreallypress}{\large\textbf{O'REALLY\raisebox{1ex}{\scriptsize ?}} \normalsize Press}
|
||||
|
||||
\title{\HUGE\textbf{TERRAN BASIC \\ REFERENCE MANUAL} \\ \Large \vspace{1em} For Version \tbasver \\ \vspace{7mm} \theedition}
|
||||
\date{}
|
||||
\author{}
|
||||
\hypersetup{
|
||||
pdfauthor={Torvald et al.},
|
||||
pdftitle={\tbas{} Reference Manual, \theedition{} (BASIC version \tbasver{})},
|
||||
unicode=true
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
\begin{titlingpage}
|
||||
\maketitle{}
|
||||
\vfill
|
||||
\oreallypress
|
||||
\end{titlingpage}
|
||||
|
||||
\setcounter{page}{3}
|
||||
|
||||
\tableofcontents*
|
||||
|
||||
|
||||
%\linenumbers % debug
|
||||
|
||||
\openright
|
||||
\chapter{Introduction}
|
||||
\input{intro}
|
||||
|
||||
\openany
|
||||
\chapter{Basic Concepts}
|
||||
\input{concepts}
|
||||
|
||||
\chapter{Language Guide}
|
||||
\input{langguide}
|
||||
|
||||
\chapter{Language Reference}
|
||||
\input{langref}
|
||||
|
||||
\chapter{Implementation}
|
||||
\input{implementation}
|
||||
\input{theinterpreter}
|
||||
|
||||
%% Bibliography %%
|
||||
% https://robhagemans.github.io/pcbasic/doc/2.0/
|
||||
|
||||
|
||||
\chapter{Index}
|
||||
|
||||
|
||||
|
||||
|
||||
\afterpage{\pagestyle{empty}\null\newpage}
|
||||
|
||||
\end{document}
|
||||
Reference in New Issue
Block a user