swahili-lang
Version:
A new programming language with semantics borrowed from the Swahili language to help teach programming concepts to Swahili speaking students.
52 lines (51 loc) • 980 B
JavaScript
/** base level units to check for */
module.exports = {
digits: /[0-9]/,
alpha: /[A-Za-z_]/,
dot: /\./,
doubleQuotes: /"/,
plus: /\+/,
hyphen: /\-/,
asterisk: /\*/,
modulo: /%/,
forwardSlash: /\//,
backSlash: /\\/,
caret: /\^/,
leftParen: /\(/,
rightParen: /\)/,
leftSquare: /\[/,
rightSquare: /\]/,
leftCurly: /\{/,
rightCurly: /\}/,
col: /:/,
comma: /,/,
ampersand: /&/,
pipe: /\|/,
exclamation: /!/,
equals: /=/,
leftArrow: /</,
rightArrow: />/,
semi: /;/g,
line: /\r?\n/g,
lineEndings: /@/, // as far as lexer is concerned
spacesAndTabs: /\s|\t/, // ignored
keywords: {
let: 'wacha',
if: 'kama',
elif: 'au',
else: 'sivyo',
for: 'kwa',
to: 'mpaka',
in: 'katika',
step: 'hatua',
while: 'ambapo',
function: 'shughuli',
try: 'jaribu',
catch: 'iwapo',
finally: 'mwishowe',
return: 'rudisha',
continue: 'endelea',
break: 'ondoka',
throw: 'tupa',
},
};