From 8d9258dff311903d90c13f54cbfb4ab63f4fbebd Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 16 Dec 2020 16:47:40 +0900 Subject: [PATCH] basic: manual wip --- .gitignore | 7 ++ assets/tbas/doc/concepts.tex | 22 +++++ assets/tbas/doc/intro.tex | 5 ++ assets/tbas/doc/langguide.tex | 0 assets/tbas/doc/langref.tex | 20 +++++ assets/tbas/doc/statements.tex | 1 - assets/tbas/doc/tbasman.tex | 150 +++++++++++++++++++++++++++++++++ 7 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 assets/tbas/doc/concepts.tex create mode 100644 assets/tbas/doc/intro.tex create mode 100644 assets/tbas/doc/langguide.tex create mode 100644 assets/tbas/doc/langref.tex create mode 100644 assets/tbas/doc/tbasman.tex diff --git a/.gitignore b/.gitignore index e6e7ba5..21836a5 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,10 @@ tmp_* *.index *.threads *_Leak_Suspects.zip + +# TeX outputs +*.aux +*.log +*.out +*.pdf +*.toc diff --git a/assets/tbas/doc/concepts.tex b/assets/tbas/doc/concepts.tex new file mode 100644 index 0000000..7345bab --- /dev/null +++ b/assets/tbas/doc/concepts.tex @@ -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. diff --git a/assets/tbas/doc/intro.tex b/assets/tbas/doc/intro.tex new file mode 100644 index 0000000..4a2985d --- /dev/null +++ b/assets/tbas/doc/intro.tex @@ -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!} diff --git a/assets/tbas/doc/langguide.tex b/assets/tbas/doc/langguide.tex new file mode 100644 index 0000000..e69de29 diff --git a/assets/tbas/doc/langref.tex b/assets/tbas/doc/langref.tex new file mode 100644 index 0000000..387d41f --- /dev/null +++ b/assets/tbas/doc/langref.tex @@ -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} diff --git a/assets/tbas/doc/statements.tex b/assets/tbas/doc/statements.tex index 8d1c8b6..e69de29 100644 --- a/assets/tbas/doc/statements.tex +++ b/assets/tbas/doc/statements.tex @@ -1 +0,0 @@ - diff --git a/assets/tbas/doc/tbasman.tex b/assets/tbas/doc/tbasman.tex new file mode 100644 index 0000000..1f9f2b9 --- /dev/null +++ b/assets/tbas/doc/tbasman.tex @@ -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}