Started syntactical analyzer

This commit is contained in:
Kyler 2024-02-26 23:20:52 -07:00
parent b307f426bf
commit 160571e171
2 changed files with 75 additions and 7 deletions

View File

@ -1,15 +1,15 @@
# YTD 12-bit Computer # YTD 12-bit Computer
*Yeahbut, aka Kyler Olsen* *Yeahbut, aka Kyler Olsen*
**NOTICE: Most of this document is unfinished.**
It is a custom computer and instruction set architecture. It also has its own It is a custom computer and instruction set architecture. It also has its own
assembly language with assembler written in Python. Custom high level language assembly language with assembler written in Python. Custom high level language
coming soon! coming soon!
## ISA ## ISA
*WIP*
## Assembly Language ## Assembly Language
*WIP*
### Registers ### Registers
@ -69,9 +69,12 @@ About
- Designer: Kyler Olsen - Designer: Kyler Olsen
- Created: *Future* - Created: *Future*
- Typing Discipline: ~~Typeless~~ Static, Weak - Typing Discipline: ~~Typeless~~ Static, Weak
- Platform: ytd 12-bit computer, ytd 12-bit emulator (multi-platform) - Platform: ytd 12-bit computer,
ytd 12-bit emulator (from *pytd12dk*, multi-platform)
- License: *Tentatively MIT* - License: *Tentatively MIT*
- Filename extension: `.ytd12c` - Filename extension: `.ytd12c`
- Compiler Implementations: `pytd12dk` (Python),
`ytd12nc` (*bootstrapped compiler*)
### Lexical ### Lexical
@ -88,6 +91,9 @@ Single-line comments start with `//` and end at the end of a line.
Multi-line comments start with `/*` and end with `*/`. Multi-line comments start with `/*` and end with `*/`.
**pytd12dk implementation detail**: Comments and their content are ultimately
ignored by the lexer after they are tokenized. There are no comments in the
output of the lexer.
#### Identifiers #### Identifiers
@ -167,6 +173,21 @@ Escape Codes
### Syntax ### Syntax
#### ProgramFile
A `ProgramFile` contains a number of `Directives` and `BlockHeaders`.
#### Directives
#### BlockHeaders
A `BlockHeaders` contains a `Header` and a number of `Statements`, `Directives`,
and `BlockHeaders`.
### Semantics
### Scratch Area
#### Operator Operand Counts #### Operator Operand Counts
- Unitary: `++`, `--`, `@`, `$` - Unitary: `++`, `--`, `@`, `$`
@ -186,10 +207,6 @@ Escape Codes
- Increment and decrement: `++`, `--` - Increment and decrement: `++`, `--`
- Reference and dereference: `@`, `$`, `[ ]` - Reference and dereference: `@`, `$`, `[ ]`
### Semantics
### Scratch Area
#### Keywords #### Keywords
- Types: `unsigned`, `int`, `fixed`, `float` - Types: `unsigned`, `int`, `fixed`, `float`
@ -221,3 +238,39 @@ Escape Codes
| `\\` | Backslash | | `\\` | Backslash |
| `\'` | Single Quotation Mark (In char literals) | | `\'` | Single Quotation Mark (In char literals) |
| `\"` | Double Quotation Mark (In str literals) | | `\"` | Double Quotation Mark (In str literals) |
## pytd12dk
`pytd12dk` (Python ytd 12-bit development kit) is a tool set written in Python
to assist in developing software for the ytd 12-bit computer. It includes a
compiler, assembler with linker, and emulator.
### Compiler
### Assembler
### Emulator
## ytd12nc
`ytd12nc` (ytd 12-bit native compiler) is a compiler and assembler with linker
set written in the native high-level programming language and assembly language
to compile software for the ytd 12-bit computer natively.
Currently development of `ytd12nc` has not yet started.
### Bootstrapping
In order to compile the the compiler, we need a compiler to compile it. This
process is called *bootstrapping* as it is like pulling ourselves up by our
bootstraps. This requires writing a compiler in assembly language or another
high-level programming language. In our case we are lucky to have the compiler
that is apart of `pytd12dk`.
| Compiler | *Compiler* Compiler | *Compiler Compiler* Compiler |
| --- | --- | --- |
| `pytd12dk` | `CPython` | `gcc`, `clang`, or other C compiler |
| `ytd12nc` (a) | `pytd12dk` | `CPython` |
| `ytd12nc` (b) | `ytd12nc` (a) | `pytd12dk` |
| `ytd12nc` (c) | `ytd12nc` (b) | `ytd12nc` (a) |
| `ytd12nc` (d) | `ytd12nc` (c) | `ytd12nc` (b) |

View File

@ -0,0 +1,15 @@
# Kyler Olsen
# Feb 2024
from enum import Enum
from typing import ClassVar, Sequence
from .compiler_types import CompilerError, FileInfo
from . import lexer
class Program: pass
class Directive: pass
class BlockHeader: pass
class Statement: pass