Переглянути джерело

Add parser description (IN PROGRESS)

Evgeniy Parfenyuk 3 місяців тому
батько
коміт
fec1c39511
1 змінених файлів з 126 додано та 8 видалено
  1. 126 8
      docs/vnrs_specification.md

+ 126 - 8
docs/vnrs_specification.md

@@ -47,7 +47,7 @@ are special characters that end a line.
 Depending of the system, default newline character would be CR (carriage 
 return, `\r`), LF (line feed, `\n`) or even both (CR + LF).  
 *NOTE: All of them are considered valid end of line, but they are replaced
-with LF (`\n`) character.*
+with single LF (`\n`) character.*
 
 **Whitespace characters**  
 are characters which are rendered into whitespace. 
@@ -60,7 +60,11 @@ carriage return, line feed, form feed.*
 **Line**  
 is a sequence of zero or more characters, that ends with newline 
 or End Of File (EOF) condition. Line which has zero characters or only 
-whitespace characters called **empty line**. 
+whitespace characters is called an **empty line**. 
+
+**Paragraph**
+A sequence of lines terminated by an empty line. A paragraph consisting 
+solely of empty lines is called an **empty paragraph**.
 
 **ASCII character**  
 is a character supported by [US-ASCII](https://en.wikipedia.org/wiki/ASCII) 
@@ -68,14 +72,14 @@ encoding. Since any existing encoding is an extension of ASCII,
 characters from ASCII is supported by nearly every computer.
 
 ## 2.2 Visual novels definitions
-(Only techinal definitions goes here)
+(Only technical definitions goes here)
 
-**Visual novel** *(from <vndb.org/d6>)*  
+**Visual novel** *(from [VNDB](vndb.org/d6))*  
 A visual novel can be seen as a combination of a novel and a computer game:
 they're computer games with a large text based storyline and only little 
 interaction of the player.  
-A typical visual novel consists of text over an anime-style background image 
-and is accompanied by background music.  
+A typical visual novel consists of text over on character sprites with 
+anime-style background image.   
 Throughout the game, the player usually has to answer a few questions which 
 will have an effect on the story, thus playing a visual novel a second time 
 while giving other answers may result in an entirely different plot.
@@ -90,7 +94,7 @@ Commonly, VN plays in ADV mode and switch to NVL for monologues.
 **Kinetic** VN  
 is a VN without choices or gameplay. Term was popularised to name games from 
 'KineticNovel' publisher. Games *with* gameplay, but without choices 
-called **liniear plot**.
+called **linear plot**.
 
 **Character points**  
 Points awarded or deducted based on positive or negative interactions 
@@ -98,4 +102,118 @@ with a character. Typically hidden from the player, these points influence
 the storyline.
 
 **Hybrid** VN  
-mix of traditional games (e.g. RPGs) and visual novel. 
+mix of traditional games (e.g. RPGs) and visual novel.
+
+# 3. Parser
+Parser read a chunk of data -- usually paragraph, but it also can be 
+a line, terminated by two spaces. (So, there are *paragraph chunks* 
+and *one-line chunks*).  
+After chunk was read by chunk parser, **it goes to inline parser**, and then
+to display or converter.
+
+## 3.1 Chunk parser
+
+For compatibility and readability reasons, line shouldn't be longer than 
+80 characters. (And parser **MUST** throw a warning if line is longer).
+Since all possible symbols fit in UTF-32 (or any other
+4-byte encoding), we can expect line wouldn't be longer than 80*4=320 bytes. 
+Therefore, line buffer should be 320-512 bytes.
+
+
+**For example ( '__' symbolise two spaces):**
+```
+1   One-line chunk with some text and two spaces:__
+2
+3   Another one-line chunk__
+4
+5
+6   A big paragraph chunk with some Lorem ipsum text:__
+7   Lorem ipsum dolor sit amet, consectetur__
+8   adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore 
+9   aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
+10
+11
+12
+13  It's doesn't matter how much empty lines are between chunks.
+```
+
+## 3.2 Chunk types
+
+### 3.2.1 Dialog (base) chunk 
+Default paragraph and one-line chunk.
+
+**Vinora Screenplay:**
+```
+1   Hello!
+2
+3   Goodbye!
+```
+**HTML:**
+```HTML
+<p>Hello!</p>
+<p>Goodbye!</p>
+```
+
+### 3.2.2 Character name chunk
+To make a *character* say something we have this syntax:
+
+```
+1   @Alex__
+2
+3   This text would be displayed as Alex's words.
+4
+5   This too! And any text chunk after, until we declare new character.
+
+```
+This is *one-line chunk*, so you **MUST** terminate it with two spaces.
+
+Here we combine character and dialog chunks.
+```
+1   @NARRATOR__
+2   Evening in the park. ALICE and BOB sit on a bench.
+3
+4   @ALICE__
+5   Look how beautifully the moon is shining.
+6
+7   @BOB__
+8   Yeah, but your eyes shine brighter.
+9
+10  @ALICE__
+11  Oh, Bob, you're always such a romantic.
+12
+13  But I need to go...
+```
+
+**NARRATOR** is pre-defined character which has no name. You can define 
+your own characters in `characters.ini` file:
+
+*characters.ini*:
+
+```
+[ALICE]
+name = Alice Smith
+
+[BOB]
+name = Bob Doe
+```
+
+**HTML:**
+```HTML
+1   @NARRATOR__
+2   Evening in the park. ALICE and BOB sit on a bench.
+3
+4   @ALICE__
+5   Look how beautifully the moon is shining.
+6
+7   @BOB__
+8   Yeah, but your eyes shine brighter.
+9
+10  @ALICE__
+11  Oh, Bob, you're always such a romantic.
+12
+13  But I need to go...
+```
+
+
+
+## 3.3 Inline parser