Skip to content

Commit

Permalink
Adjust parsing and base to facilitate ASCII-parser for nl2.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Jul 22, 2024
1 parent 44521ce commit 5e36bb2
Show file tree
Hide file tree
Showing 29 changed files with 647 additions and 42 deletions.
2 changes: 1 addition & 1 deletion base.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ ctr_object* ctr_object_case_do( ctr_object* myself, ctr_argument* argumentList )
compareArguments->next = NULL;
if (
ctr_internal_cast2bool(
ctr_send_message( myself, "=", 1, compareArguments )
ctr_send_message( myself, CTR_DICT_SYMBOL_EQUALS, strlen(CTR_DICT_SYMBOL_EQUALS), compareArguments )
)->value.bvalue == 1) {
block->info.sticky = 1;
int sticky = myself->info.sticky;
Expand Down
196 changes: 196 additions & 0 deletions i18n/nl2/dictionary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
#define CTR_DICT_CODEGEN_MAP_NEW "(Lijst nieuw) "
#define CTR_DICT_CODEGEN_MAP_PUT "zet:"
#define CTR_DICT_CODEGEN_MAP_PUT_AT " bij:"
#define CTR_DICT_CODEGEN_ARRAY_NEW "Reeks nieuw "
#define CTR_DICT_CODEGEN_ARRAY_NEW_PUSH "Reeks << "
#define CTR_DICT_END_OF_LINE "."
#define CTR_DICT_NIL "Niets"
#define CTR_DICT_BOOLEAN "Boolean"
#define CTR_DICT_TRUE "Ja"
#define CTR_DICT_FALSE "Nee"
#define CTR_DICT_NUMBER "Getal"
#define CTR_DICT_STRING "Tekst"
#define CTR_DICT_TASK "Taak"
#define CTR_DICT_OBJECT "Object"
#define CTR_DICT_ARRAY_OBJECT "Reeks"
#define CTR_DICT_MAP_OBJECT "Lijst"
#define CTR_DICT_PROGRAM "Programma"
#define CTR_DICT_FILE "Bestand"
#define CTR_DICT_MOMENT "Moment"
#define CTR_DICT_VAR_ICON "var"
#define CTR_DICT_ME_ICON "zelf"
#define CTR_DICT_MY_ICON "eigen"
#define CTR_DICT_BULLET "~"
#define CTR_DICT_SYMBOL_EQUALS "=="
#define CTR_DICT_PLUS "+"
#define CTR_DICT_MINUS "-"
#define CTR_DICT_MULTIPLIER "*"
#define CTR_DICT_DIVISION "/"
#define CTR_DICT_GREATER ">"
#define CTR_DICT_LESS "<"
#define CTR_DICT_AT_SYMBOL "?"
#define CTR_DICT_PEN_ICON "Uit"
#define CTR_DICT_NEW_ARRAY_AND_PUSH_SYMBOL "<<"
#define CTR_DICT_GREATER_OR_EQUAL_SYMBOL ">="
#define CTR_DICT_LESS_OR_EQUAL_SYMBOL "<="
#define CTR_DICT_UNEQUALS_SYMBOL "!="
#define CTR_DICT_NEW "nieuw"
#define CTR_DICT_EQUALS "gelijk:"
#define CTR_DICT_AND "en:"
#define CTR_DICT_OR "of:"
#define CTR_DICT_MODULO "modulo:"
#define CTR_DICT_NOR "noch:"
#define CTR_DICT_ONDO "bij:doen:"
#define CTR_DICT_TYPE "type"
#define CTR_DICT_ISNIL "Niets?"
#define CTR_DICT_MYSELF "mijzelf"
#define CTR_DICT_DO "doen"
#define CTR_DICT_DONE "klaar"
#define CTR_DICT_IFFALSE "nee:"
#define CTR_DICT_IFTRUE "ja:"
#define CTR_DICT_WHILE "zolang:"
#define CTR_DICT_MESSAGEARGS "bericht:argumenten:"
#define CTR_DICT_MESSAGE "bericht:"
#define CTR_DICT_LEARN "leer:betekent:"
#define CTR_DICT_BREAK "afbreken"
#define CTR_DICT_CONTINUE "doorgaan"
#define CTR_DICT_ELSE "anders:"
#define CTR_DICT_NOT "niet"
#define CTR_DICT_TONUMBER "getal"
#define CTR_DICT_ITONUMBER "intergetal"
#define CTR_DICT_TOSTRING "tekst"
#define CTR_DICT_CHAR_AT_SET "letter:"
#define CTR_DICT_EITHEROR "of:of:"
#define CTR_DICT_BY_SET "per:"
#define CTR_DICT_FLOOR "laag"
#define CTR_DICT_CEIL "hoog"
#define CTR_DICT_ROUND "afgerond"
#define CTR_DICT_ABS "absoluut"
#define CTR_DICT_SQRT "vierkantswortel"
#define CTR_DICT_POWER "macht:"
#define CTR_DICT_MIN "minimum"
#define CTR_DICT_MAX "maximum"
#define CTR_DICT_ODD "oneven?"
#define CTR_DICT_EVEN "even?"
#define CTR_DICT_POS "positief?"
#define CTR_DICT_NEG "negatief?"
#define CTR_DICT_TOBOOL "bool"
#define CTR_DICT_RANDOM_NUM_BETWEEN "tussen:en:"
#define CTR_DICT_LENGTH "lengte"
#define CTR_DICT_FROM_LENGTH "van:lengte:"
#define CTR_DICT_TRIM "kern"
#define CTR_DICT_AT "bij:"
#define CTR_DICT_POSITION_SET "positie:"
#define CTR_DICT_INDEX_OF "zoek:"
#define CTR_DICT_LAST_INDEX_OF "laatste:"
#define CTR_DICT_REPLACE_WITH "vervang:door:"
#define CTR_DICT_SPLIT "opsplitsen:"
#define CTR_DICT_SKIP "overslaan:"
#define CTR_DICT_RUN "start"
#define CTR_DICT_APPLY_TO "toepassen:"
#define CTR_DICT_APPLY_TO_AND "toepassen:en:"
#define CTR_DICT_VALUE_SET "gebruik:waarde:"
#define CTR_DICT_ERROR "fout:"
#define CTR_DICT_CATCH "afhandelen:"
#define CTR_DICT_PUSH_SYMBOL ";"
#define CTR_DICT_SHIFT "lknip"
#define CTR_DICT_COUNT "aantal"
#define CTR_DICT_JOIN "samenvoegen:"
#define CTR_DICT_POP "rknip"
#define CTR_DICT_SORT "sorteren:"
#define CTR_DICT_PUT_AT "zet:bij:"
#define CTR_DICT_MAP "lijst:"
#define CTR_DICT_EACH "elk:"
#define CTR_DICT_WRITE "schrijf:"
#define CTR_DICT_PATH "pad"
#define CTR_DICT_READ "lezen"
#define CTR_DICT_APPEND "toevoegen:"
#define CTR_DICT_PREPEND "invoegen:"
#define CTR_DICT_EXISTS "bestaat"
#define CTR_DICT_SIZE "grootte"
#define CTR_DICT_DELETE "verwijderen"
#define CTR_DICT_USE_SET "gebruik:"
#define CTR_DICT_ARRAY "reeks:"
#define CTR_DICT_END "einde"
#define CTR_DICT_ARGUMENT "argument:"
#define CTR_DICT_ARGUMENT_COUNT "aantal argumenten"
#define CTR_DICT_WAIT_FOR_PASSW "vraag wachtwoord"
#define CTR_DICT_WAIT_FOR_INPUT "vraag"
#define CTR_DICT_INPUT "invoer"
#define CTR_DICT_FLUSH "spoelen"
#define CTR_DICT_WAIT "wacht:"
#define CTR_DICT_TIME "tijd"
#define CTR_DICT_RESPOND_TO "reageer:"
#define CTR_DICT_RESPOND_TO_AND "reageer:en:"
#define CTR_DICT_SHELL "opdrachtregel:"
#define CTR_DICT_SWEEP "vegen"
#define CTR_DICT_MEMORY_LIMIT "geheugen:"
#define CTR_DICT_MEMORY "geheugen"
#define CTR_DICT_GC_MODE "geheugenbeheer:"
#define CTR_DICT_HASH_WITH_KEY "kluts:"
#define CTR_DICT_CHARACTERS "letters"
#define CTR_DICT_QUALIFIER_SET "kwalificering:"
#define CTR_DICT_QUALIFIER "kwalificering"
#define CTR_DICT_NEW_SET "nieuw:"
#define CTR_DICT_HOUR "uur"
#define CTR_DICT_HOUR_SET "uur:"
#define CTR_DICT_MINUTE_SET "minuut:"
#define CTR_DICT_MINUTE "minuut"
#define CTR_DICT_SECOND_SET "seconde:"
#define CTR_DICT_SECOND "seconde"
#define CTR_DICT_DAY "dag"
#define CTR_DICT_DAY_SET "dag:"
#define CTR_DICT_WEEK "week"
#define CTR_DICT_WEEK_SET "week:"
#define CTR_DICT_MONTH "maand"
#define CTR_DICT_MONTH_SET "maand:"
#define CTR_DICT_YEAR "jaar"
#define CTR_DICT_RAW "ruw"
#define CTR_DICT_YEAR_SET "jaar:"
#define CTR_DICT_WEEK_DAY "weekdag"
#define CTR_DICT_YEAR_DAY "jaardag"
#define CTR_DICT_ZONE "zone"
#define CTR_DICT_ZONE_SET "zone:"
#define CTR_DICT_ADD_SET "optellen:"
#define CTR_DICT_SUBTRACT_SET "aftrekken:"
#define CTR_DICT_MULTIPLIER_SET "keer:"
#define CTR_DICT_DIVIDER_SET "gedeeld:"
#define CTR_DICT_LAST "laatste"
#define CTR_DICT_FIRST "eerste"
#define CTR_DICT_SECOND_LAST "voorlaatste"
#define CTR_DICT_FILL_WITH "vul:met:"
#define CTR_DICT_SPLICE "vervang:lengte:door:"
#define CTR_DICT_VALUES "waarden"
#define CTR_DICT_ENTRIES "ingangen"
#define CTR_DICT_COMPARE_SET "vergelijk:"
#define CTR_DICT_HAS "heeft:"
#define CTR_DICT_COPY "kopieer"
#define CTR_DICT_CASE_DO "geval:doen:"
#define CTR_DICT_STOP "stop"
#define CTR_DICT_ASCII_UPPER_CASE "hoofdletters"
#define CTR_DICT_ASCII_LOWER_CASE "kleine-letters"
#define CTR_DICT_CONTAINS "bevat:"
#define CTR_DICT_APPLY_TO_AND_AND "toepassen:en:en:"
#define CTR_DICT_ENVIRONMENT_VARIABLE "instelling:"
#define CTR_DICT_SET_ENVIRONMENT_VARIABLE "instelling:is:"
#define CTR_DICT_RESPOND_TO_AND_AND "reageer:en:en:"
#define CTR_DICT_RESPOND_TO_AND_AND_AND "reageer:en:en:en:"
#define CTR_DICT_CURRENT_TASK "deze-taak"
#define CTR_DICT_NUM_DEC_SEP ","
#define CTR_DICT_NUM_THO_SEP "."
#define CTR_DICT_QUOT_OPEN "['"
#define CTR_DICT_QUOT_CLOSE "']"
#define CTR_DICT_MESSAGE_CHAIN ","
#define CTR_DICT_ASSIGN ":="
#define CTR_DICT_PAREN_OPEN "("
#define CTR_DICT_PAREN_CLOSE ")"
#define CTR_DICT_BLOCK_START "{"
#define CTR_DICT_BLOCK_END "}"
#define CTR_DICT_PARAMETER_PREFIX ":"
#define CTR_DICT_RETURN "antw"
#define CTR_DICT_CODE "code"
#define CTR_DICT_PROCEDURE "procedure"
#define CTR_DICT_TOOBJECT "object"
#define CTR_DICT_PATH_OBJECT "Bestandslocatie"
#define CTR_DICT_CMD_OBJECT "Instructie"
#define CTR_DICT_RECURSIVE "recursief"
12 changes: 12 additions & 0 deletions i18n/nl2/extra.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
s "respond:and:and:and:" "reageer:en:en:en:"
s "respond:and:and:" "reageer:en:en:"
s "respond:and:" "reageer:en:"
s "respond:" "reageer:"
t "color" "kleur"
s "tests/assets/includetesten.ctr" "tests/assets/includetestnl.ctr"
s "add:" "optellen:"
s "subtract:" "aftrekken:"
s "size" "grootte"
s "new" "nieuw"
s "file" "bestand"
s "type" "type"
12 changes: 12 additions & 0 deletions i18n/nl2/extra_reverse.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
s "reageer:en:en:en:" "respond:and:and:and:"
s "reageer:en:en:" "respond:and:and:"
s "reageer:en:" "respond:and:"
s "reageer:" "respond:"
t "kleur" "color"
s "tests/assets/includetestnl.ctr" "tests/assets/includetesten.ctr"
s "optellen:" "add:"
s "aftrekken:" "subtract:"
s "grootte" "size"
s "nieuw" "new"
s "bestand" "file"
s "type" "type"
83 changes: 83 additions & 0 deletions i18n/nl2/msg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#define CTR_MSG_LANG_CODE "nl"
#define CTR_MSG_WELCOME "De Programmeertaal Citrine/NL\n"
#define CTR_MSG_COPYRIGHT "Geschreven door Gabor de Mooij ©, BSD Licentie.\n"
#define CTR_MSG_USAGE_G "Niet genoeg argumenten. Gebruik alsvolgt: ctr -g bestand1.h bestand2.h"
#define CTR_MSG_USAGE_T "Niet genoeg argumenten. Gebruik alsvolgt: ctr -t d.dict programma.ctr"
#define CTR_ERR_LEX "%s op regel: %d. \n"
#define CTR_ERR_TOKBUFF "Token buffer verbruikt. Tokens mogen niet langer zijn dan 255 bytes"
#define CTR_ERR_OOM "Te weinig geheugen."
#define CTR_ERR_SYNTAX "Taalfout, onverwacht symbool: %s ( %s: %d )\n"
#define CTR_ERR_LONG "Bericht te lang.\n"
#define CTR_ERR_EXP_COLON "Dubbele punt verwacht.\n"
#define CTR_ERR_EXP_MSG "Bericht verwacht.\n"
#define CTR_ERR_EXP_PCLS "Verwacht: ).\n"
#define CTR_ERR_EXP_DOT "Punt verwacht (.).\n"
#define CTR_ERR_EXP_KEY "Sleutel moet altijd worden gevolgd door objecteigenschap.\n"
#define CTR_ERR_EXP_VAR "Aanwijzer moet gevolgd worden door variabele!\n"
#define CTR_ERR_EXP_RCP "Verwacht ontvanger voor bericht.\n"
#define CTR_ERR_EXP_MSG2 "Ontvanger kan niet worden gevolgd door dubbele punt.\n"
#define CTR_ERR_INV_LAS "Ongeldige linkerhelft van toekenning.\n"
#define CTR_ERR_EXP_BLK "Verwacht codeblok."
#define CTR_ERR_EXP_ARR "Verwacht reeks."
#define CTR_ERR_EXP_NUM "Verwacht getal."
#define CTR_ERR_EXP_STR "Verwacht tekst."
#define CTR_ERR_DIVZERO "Deling door nul."
#define CTR_ERR_REGEX "Kon reguliere expressie niet compileren."
#define CTR_ERR_BOUNDS "Index valt buiten bereik."
#define CTR_ERR_SIPHKEY "Sleutel moet exact 16 bytes lang zijn."
#define CTR_SYM_OBJECT "[Object]"
#define CTR_SYM_BLOCK "[Taak]"
#define CTR_SYM_FILE "[Bestand (geen pad)]"
#define CTR_ERR_OPEN "Kan niet openen: %s."
#define CTR_ERR_DELETE "Kan niet verwijderen."
#define CTR_ERR_FOPENED "Bestand is reeds geopend."
#define CTR_ERR_SEEK "Kan niet zoeken."
#define CTR_ERR_LOCK "Kan niet vergrendelen."
#define CTR_ERR_RET "Ongeldige terugkeeruitdrukking.\n"
#define CTR_ERR_SEND "Kan geen bericht verzenden naar object van het type: %d \n"
#define CTR_ERR_KEYINX "Sleutelindexering verbruikt."
#define CTR_ERR_ANOMALY "Afwijking gevonden op berichtniveau.\n"
#define CTR_ERR_UNCAUGHT "Onafgehandelde fout opgetreden.\n"
#define CTR_ERR_NODE "Uitvoeringsfout, ongeldige instructie gevonden: %d %s \n"
#define CTR_ERR_MISSING "Ontbrekende instructie.\n"
#define CTR_ERR_FOPEN "Kan bestand niet openen.\n"
#define CTR_ERR_RNUM "Moet antwoorden met een getal."
#define CTR_ERR_RSTR "Moet antwoorden met een tekst."
#define CTR_ERR_RBOOL "Moet antwoorden met een waarheid."
#define CTR_ERR_NESTING "Teveel geneste aanroepen."
#define CTR_ERR_KNF "Sleutel niet gevonden: "
#define CTR_ERR_ASSIGN "Kan geen waarde toekennen aan onbekende variabele: "
#define CTR_ERR_EXEC "Kan opdracht niet uitvoeren."
#define CTR_MSG_DSC_FILE "bestand"
#define CTR_MSG_DSC_FLDR "map"
#define CTR_MSG_DSC_SLNK "symlink"
#define CTR_MSG_DSC_CDEV "tekstapparaat"
#define CTR_MSG_DSC_BDEV "blokapparaat"
#define CTR_MSG_DSC_SOCK "aansluiting"
#define CTR_MSG_DSC_NPIP "benoemde pijp"
#define CTR_MSG_DSC_OTHR "anders"
#define CTR_MSG_DSC_TYPE "type"
#define CTR_TERR_LMISMAT "Taal komt niet overeen."
#define CTR_TERR_LONG "Vertaalfout, bericht te lang."
#define CTR_TERR_DICT "Fout bij openen woordenboek."
#define CTR_TERR_KMISMAT "Fout: sleutel komt niet overeen %s %s op regel %d\n"
#define CTR_TERR_ELONG "Woordenboekingang te lang."
#define CTR_TERR_AMWORD "Ambigu woord gevonden: %s."
#define CTR_TERR_AMTRANS "Ambigue vertaling: %s."
#define CTR_TERR_TMISMAT "Bericht type komt niet overeen:"
#define CTR_TERR_BUFF "Kan niet naar buffer kopieren."
#define CTR_TERR_WARN "Waarchuwing, niet vertaald: "
#define CTR_TERR_TOK "Tokenlengte overschrijdt bufferruimte"
#define CTR_TERR_PART "Deel van sleutelwoordbericht past niet in buffer."
#define CTR_TERR_COLONS "Verschillend aantal dubbele punten."
#define CTR_MSG_ERROR "Algemene fout."
#define CTR_MERR_OOM "Geen geheugen meer, kon geen %lu bytes aanvragen.\n"
#define CTR_MERR_MALLOC "Geen geheugen meer, kon geen %lu bytes aanvragen (malloc faalde). \n"
#define CTR_MERR_POOL "Kon geen geheugenbank aanleggen.\n"
#define CTR_STDDATEFRMT "%d-%m-%Y %H.%M:%S"
#define CTR_STDTIMEZONE "Europe/Amsterdam"





17 changes: 5 additions & 12 deletions lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,10 @@ uint8_t ctr_clex_is_delimiter( char* code ) {
if (strncmp(code, CTR_DICT_END_OF_LINE, ctr_clex_keyword_eol_len) == 0) {
return 1;
}
if (strncmp(code, CTR_DICT_ASSIGN, ctr_clex_keyword_assignment_len) == 0) {
return 1;
}
if (strncmp(code, CTR_DICT_QUOT_OPEN, ctr_clex_keyword_qo_len) == 0 ) {
return 1;
}
if (strncmp(code, CTR_DICT_RETURN, ctr_clex_keyword_return_len) == 0 ) {
if (strncmp(code, CTR_DICT_ASSIGN, ctr_clex_keyword_assignment_len) == 0) {
return 1;
}
if (strncmp(code, CTR_DICT_MESSAGE_CHAIN, ctr_clex_keyword_chain_len) == 0 ) {
Expand Down Expand Up @@ -267,21 +264,17 @@ int ctr_clex_tok() {
return CTR_TOKEN_ASSIGNMENT;
}
if (c == ctr_clex_param_prefix_char) { ctr_code++; return CTR_TOKEN_COLON; }
if ( ( ctr_code + 2) < ctr_eofcode
&& (uint8_t) c == 0xE2
&& ( (uint8_t) *(ctr_code+1)==0x86)
&& ( (uint8_t) *(ctr_code+2)==0xB2) ) {
ctr_code += 3;
if (strncmp(ctr_code, CTR_DICT_RETURN, ctr_clex_keyword_return_len)==0
&& *(ctr_code+ctr_clex_keyword_return_len)==' '
) {
ctr_code += ctr_clex_keyword_return_len;
return CTR_TOKEN_RET;
}

if (strncmp(ctr_code, CTR_DICT_QUOT_OPEN, ctr_clex_keyword_qo_len)==0) {
ctr_code+=ctr_clex_keyword_qo_len;
return CTR_TOKEN_QUOTE;
}

eol = ( strncmp(ctr_code,CTR_DICT_END_OF_LINE,ctr_clex_keyword_eol_len)==0 );

if ((c == '-' && (ctr_code+1)<ctr_eofcode && isdigit(*(ctr_code+1))) || isdigit(c)) {
if (c == '-') {
ctr_clex_buffer[i] = c; ctr_clex_tokvlen++;
Expand Down
7 changes: 1 addition & 6 deletions plugins/media/i18n/nl/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
#define CTR_DICT_LINK_SET "koppel:"
#define CTR_DICT_SAY_SET "zeg:"
#define CTR_DICT_SELECTION "selectie"
#define CTR_DICT_FETCH_TEXT_MESSAGES "tekstberichten"
#define CTR_DICT_SEND_TEXT_MESSAGE "tekst:naar:"
#define CTR_DICT_NETWORK_PORT "netwerkpoort"
#define CTR_DICT_DIGRAPH_LIGATURE_SET "digraaf:ligatuur:"
#define CTR_DICT_RED "rood"
#define CTR_DICT_GREEN "groen"
#define CTR_DICT_BLUE "blauw"
Expand All @@ -37,7 +34,6 @@
#define CTR_DICT_FRICTION_SET "weerstand:"
#define CTR_DICT_COLLISION_SET "bots:"
#define CTR_DICT_ON_CLICK "klik"
#define CTR_DICT_ON_HOVER "beweeg over:"
#define CTR_DICT_ANIMATIONS_SET "animaties:"
#define CTR_DICT_CUT "knip"
#define CTR_DICT_EDITABLE_SET "beschrijfbaar:"
Expand All @@ -64,5 +60,4 @@
#define CTR_DICT_CLIPBOARD_SET "klembord:"
#define CTR_DICT_FROM_TO_SET "vanuit:naar:"
#define CTR_DICT_RED_GREEN_BLUE_SET "rood:groen:blauw:"
#define CTR_DICT_TRANSPARENCY_SET "transparantie:"
#define CTR_DICT_QUOTES "Aanhalingstekens"
#define CTR_DICT_TRANSPARENCY_SET "transparantie:"
5 changes: 5 additions & 0 deletions plugins/media/i18n/nl2/assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rm -rf /tmp/translated_assets
mkdir /tmp/translated_assets
cp plugins/media/examples/*.png /tmp/translated_assets/
cp plugins/media/examples/*.ttf /tmp/translated_assets/
cp plugins/media/examples/*.ogg /tmp/translated_assets/
Loading

0 comments on commit 5e36bb2

Please sign in to comment.