Skip to content

Instantly share code, notes, and snippets.

@hejrobin
Created September 1, 2011 11:28
Show Gist options
  • Save hejrobin/1185991 to your computer and use it in GitHub Desktop.
Save hejrobin/1185991 to your computer and use it in GitHub Desktop.
Lexer usage
var lex = new Lingo.Lexer();
lex.setLexicon('foo', new Lingo.Dictionary({
name: 'Rövarspråket',
description: 'Rövarspråket',
lexicon: {
characters: {
'B': 'Bob', 'b': 'bob',
'C': 'Coc', 'c': 'coc',
'D': 'Dod', 'd': 'dod',
'F': 'Fof', 'f': 'fof',
'G': 'Gog', 'g': 'gog',
'H': 'Hot', 'h': 'hot',
'J': 'Joj', 'j': 'joj',
'K': 'Kok', 'k': 'kok',
'L': 'Lol', 'l': 'lol',
'M': 'Mom', 'm': 'mom',
'N': 'Non', 'n': 'non',
'P': 'Pop', 'p': 'pop',
'Q': 'Qoq', 'q': 'qoq',
'R': 'Ror', 'r': 'ror',
'S': 'Sos', 's': 'sos',
'T': 'Tot', 't': 'tot',
'V': 'Vov', 'v': 'vov',
'W': 'Wow', 'w': 'wow',
'X': 'Sosakoksos', 'x': 'sosakoksos',
'Z': 'Zoz', 'z': 'zoz'
},
words: {
'Tack': 'Totakokkok', 'tack': 'totakokkok',
'Sax': 'Sosakoksos', 'sax': 'sosakoksos'
},
numbers: {},
special: {}
}
}));
console.log(lex.define('Hotejoj', 'foo')); // >> Hej
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment