]> git.lizzy.rs Git - metalua.git/blob - metalua/compiler/parser/lexer.lua
Merge branch 'master' of ssh://git.eclipse.org/gitroot/koneki/org.eclipse.koneki...
[metalua.git] / metalua / compiler / parser / lexer.lua
1 --------------------------------------------------------------------------------
2 -- Copyright (c) 2006-2014 Fabien Fleutot and others.
3 --
4 -- All rights reserved.
5 --
6 -- This program and the accompanying materials are made available
7 -- under the terms of the Eclipse Public License v1.0 which
8 -- accompanies this distribution, and is available at
9 -- http://www.eclipse.org/legal/epl-v10.html
10 --
11 -- This program and the accompanying materials are also made available
12 -- under the terms of the MIT public license which accompanies this
13 -- distribution, and is available at http://www.lua.org/license.html
14 --
15 -- Contributors:
16 --     Fabien Fleutot - API and implementation
17 --
18 --------------------------------------------------------------------------------
19
20 ----------------------------------------------------------------------
21 -- Generate a new lua-specific lexer, derived from the generic lexer.
22 ----------------------------------------------------------------------
23
24 local generic_lexer = require 'metalua.grammar.lexer'
25
26 return function()
27     local lexer = generic_lexer.lexer :clone()
28
29     local keywords = {
30         "and", "break", "do", "else", "elseif",
31         "end", "false", "for", "function",
32         "goto", -- Lua5.2
33         "if",
34         "in", "local", "nil", "not", "or", "repeat",
35         "return", "then", "true", "until", "while",
36         "...", "..", "==", ">=", "<=", "~=",
37         "::", -- Lua5,2
38         "+{", "-{" } -- Metalua
39
40     for _, w in ipairs(keywords) do lexer :add (w) end
41
42     return lexer
43 end