]> git.lizzy.rs Git - metalua.git/blobdiff - 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
diff --git a/metalua/compiler/parser/lexer.lua b/metalua/compiler/parser/lexer.lua
new file mode 100644 (file)
index 0000000..2b5ff7e
--- /dev/null
@@ -0,0 +1,43 @@
+--------------------------------------------------------------------------------
+-- Copyright (c) 2006-2014 Fabien Fleutot and others.
+--
+-- All rights reserved.
+--
+-- This program and the accompanying materials are made available
+-- under the terms of the Eclipse Public License v1.0 which
+-- accompanies this distribution, and is available at
+-- http://www.eclipse.org/legal/epl-v10.html
+--
+-- This program and the accompanying materials are also made available
+-- under the terms of the MIT public license which accompanies this
+-- distribution, and is available at http://www.lua.org/license.html
+--
+-- Contributors:
+--     Fabien Fleutot - API and implementation
+--
+--------------------------------------------------------------------------------
+
+----------------------------------------------------------------------
+-- Generate a new lua-specific lexer, derived from the generic lexer.
+----------------------------------------------------------------------
+
+local generic_lexer = require 'metalua.grammar.lexer'
+
+return function()
+    local lexer = generic_lexer.lexer :clone()
+
+    local keywords = {
+        "and", "break", "do", "else", "elseif",
+        "end", "false", "for", "function",
+        "goto", -- Lua5.2
+        "if",
+        "in", "local", "nil", "not", "or", "repeat",
+        "return", "then", "true", "until", "while",
+        "...", "..", "==", ">=", "<=", "~=",
+        "::", -- Lua5,2
+        "+{", "-{" } -- Metalua
+
+    for _, w in ipairs(keywords) do lexer :add (w) end
+
+    return lexer
+end
\ No newline at end of file