| 1 |
Syntax & Semantic of '/' |
| 2 |
======================== |
| 3 |
|
| 4 |
Notes: |
| 5 |
* This is all by observation and human interpretation. |
| 6 |
* There are helpful tools though (in particular grep and sed). |
| 7 |
|
| 8 |
Source files: |
| 9 |
* src/Language/Ding/Token.hs |
| 10 |
* src/Language/Ding/AlexScanner.hs |
| 11 |
|
| 12 |
|
| 13 |
Definitions |
| 14 |
----------- |
| 15 |
|
| 16 |
word: [[:alpha:]] | abbrev "." |
| 17 |
abbrev: "etw" | "so" | "sb" | "sth" | ... |
| 18 |
|
| 19 |
special: "(" | ")" | ";" | ... |
| 20 |
|
| 21 |
lFree: "(" | "{" | "[" | "<" | " " |
| 22 |
rFree: ")" | "}" | "]" | ">" | " " | interpunctiuation |
| 23 |
rFreeExceptDots: rFree |
| 24 |
- excluding triple dots ("...") |
| 25 |
- examples: |
| 26 |
- positive: ". " |
| 27 |
- negative: "..." |
| 28 |
|
| 29 |
interpunctuation: "." | "," | ":" | "!" | "?" | ";" | ... |
| 30 |
- interpunctuation, that does not require preceding space. |
| 31 |
|
| 32 |
Notes: |
| 33 |
* In AlexScanner, instead of [[:alpha:]], a much larger character set is used. |
| 34 |
* <`- TODO |
| 35 |
* Words in a more general sense, such as usable for '<>', should usually not |
| 36 |
contain a terminating '.'. |
| 37 |
* TODO: `word' may probably contain other chars, such as '-', '_'. |
| 38 |
* TODO: Abbreviations may contain several '.', e.g. "r.-k.". |
| 39 |
|
| 40 |
|
| 41 |
Alternative for single words (strong slashes) |
| 42 |
--------------------------------------------- |
| 43 |
|
| 44 |
No spacing. |
| 45 |
|
| 46 |
single_alt: word ("/" word)+ |
| 47 |
|
| 48 |
|
| 49 |
Alternative for strong-slashed expressions (double slashes) |
| 50 |
----------------------------------------------------------- |
| 51 |
|
| 52 |
No spacing. |
| 53 |
|
| 54 |
double_alt: single_alt ("//" single_alt)+ |
| 55 |
|
| 56 |
Note: In terms of binding sthrength, double slashes are between strong and |
| 57 |
medium slashes. |
| 58 |
|
| 59 |
|
| 60 |
Alternative for groups of words (weak slashes) |
| 61 |
---------------------------------------------- |
| 62 |
|
| 63 |
Has spacing. |
| 64 |
|
| 65 |
group_alt: expression (" "+ "/" " "+ expression)+ |
| 66 |
expression: ? |
| 67 |
|
| 68 |
Notes: |
| 69 |
* Identifying the matching expressions is hard. |
| 70 |
* A work for linguists, probably - or a potentially existing library. |
| 71 |
* One might try to guess at least in certain cases. |
| 72 |
* <`- TODO |
| 73 |
|
| 74 |
|
| 75 |
Enclosing an abbreviation (or several) (opening and closing slashes) |
| 76 |
-------------------------------------------------------------------- |
| 77 |
|
| 78 |
No spacing. |
| 79 |
Surrounded by free context. |
| 80 |
|
| 81 |
encl_abbrev: lFree < "/" wordList "."? "/" > rFreeExceptDots |
| 82 |
| lFree < "/" wordList "."? "/" "s"? > rFree |
| 83 |
wordList: word (";" " "* word)* |
| 84 |
|
| 85 |
Notes: |
| 86 |
* A terminating "s" signifies plural. |
| 87 |
* Currently, it is only recognized for single slash-enclosed words (i.e., no |
| 88 |
<;> separators). This is to allow for catching plural abbreviations at |
| 89 |
the lexer stage. Simply lexing "/s", potentially with a certain context, |
| 90 |
does not suffice, since there are many valid other occurences of "/s". |
| 91 |
* Infrequently, a "," is used instead of ";". |
| 92 |
* I consider this as to be fixed at the preprocessor stage. |
| 93 |
* <`- TODO |
| 94 |
* Note that "," is probably easier to parse. |
| 95 |
* In the current implementation (Alex + Happy), this is not the case, |
| 96 |
since there are distinguished tokens for opening and closing slashes |
| 97 |
in this context. |
| 98 |
* Note that in other contexts (<{}>), a "," means "or" while a ";" |
| 99 |
means "and". |
| 100 |
|
| 101 |
|
| 102 |
Enclosing an abbreviation containing slashes |
| 103 |
-------------------------------------------- |
| 104 |
|
| 105 |
Spacing. |
| 106 |
Surrounded by free context. |
| 107 |
|
| 108 |
encl_abbrev_sl: lFree < "/ " swords " /" > rFree |
| 109 |
swords: sword ("," " "? sword)* |
| 110 |
sword: word ("/" word)+ |
| 111 |
- syntax equal to single_alt, semantics different. |
| 112 |
|
| 113 |
Notes: |
| 114 |
* This is parsed at the lexer stage to avoid later ambiguity. |
| 115 |
* Wherever the encl_abbrev_sl rule matches, it is hence prefered. |
| 116 |
|
| 117 |
|
| 118 |
Enclosing a special char |
| 119 |
------------------------ |
| 120 |
|
| 121 |
Spacing. |
| 122 |
Surrounded by spacing or separators (context). |
| 123 |
|
| 124 |
encl_special: lFree < "/" " "+ special " "+ "/" > rFree |
| 125 |
|
| 126 |
Notes: |
| 127 |
* This is parsed at the lexer stage to avoid later ambiguity. |
| 128 |
* Wherever the encl_abbrev_sl rule matches, it is hence prefered. |
| 129 |
|
| 130 |
|
| 131 |
Enclosing a smiley |
| 132 |
------------------ |
| 133 |
|
| 134 |
Spacing. |
| 135 |
Surrounded by spacing or separators (context). |
| 136 |
|
| 137 |
encl_smiley: lFree < "/" " "+ smiley " "+ "/" > rFree |
| 138 |
smiley: ... (TODO) |
| 139 |
|
| 140 |
Notes: |
| 141 |
* In the original Ding source, smileys are not enclosed in slashes. |
| 142 |
* The enclosing is added in the preprocessor. |
| 143 |
* Very similar to "Enclosing a special char". |
| 144 |
* See also there. |
| 145 |
|
| 146 |
|
| 147 |
Test cases |
| 148 |
---------- |
| 149 |
|
| 150 |
* "Abendrot Schönwetterbot, Morgenrot Schlechtwetter droht. (Bauernregel) :: Red sky at night shepherd's [Br.]/sailor's [Am.] delight, red sky in the morning shepherd's [Br.]/sailor's [Am.] warning. (weather saying)" |
| 151 |
|
| 152 |
|
| 153 |
Exceptions |
| 154 |
---------- |
| 155 |
|
| 156 |
* "AC/DC" -- TODO |
| 157 |
* In 2 of 3 present occurences, this can be transformed to "/ AC/DC /". |
| 158 |
* Bad occurence: "AC/DC converters" |