[svn] horrid .svns copied accidentally

This commit is contained in:
goatchurch
2009-06-28 21:26:35 +01:00
parent db5e315db0
commit 16b7404d9b
45 changed files with 8750 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
Copyright (c) 2009, Franciszek Wawrzak
All rights reserved.
This software is provided for use in connection with the
CodeMirror suite of modules and utilities, hosted and maintained
at http://marijn.haverbeke.nl/codemirror/.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,59 @@
.editbox {
margin: .4em;
padding: 0;
font-family: monospace;
font-size: 10pt;
color: black;
}
pre.code, .editbox {
color: #666666;
}
.editbox p {
margin: 0;
}
span.lua-comment {
color: #BB9977;
}
span.lua-keyword {
font-weight: bold;
color: blue;
}
span.lua-string {
color: #AA2222;
}
span.lua-stdfunc {
font-weight: bold;
color: #077;
}
span.lua-customfunc {
font-weight: bold;
color: #0AA;
}
span.lua-identifier {
color: black;
}
span.lua-number {
color: #3A3;
}
span.lua-token {
color: #151;
}
span.lua-error {
color: #FFF;
background-color: #F00;
}

View File

@@ -0,0 +1,68 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../../js/codemirror.js" type="text/javascript"></script>
<title>CodeMirror: Lua demonstration</title>
</head>
<body style="padding: 20px;">
<p>This page demonstrates <a href="../../index.html">CodeMirror</a>'s
Lua parser. Written by <a href="http://francio.pl/">Franciszek
Wawrzak</a>, released under a BSD-style <a
href="LICENSE">license</a>.</p>
<div style="border: 1px solid black; padding: 0px;">
<textarea id="code" cols="120" rows="30">
--[[
example useless code to show lua syntax highlighting
this is multiline comment
]]
function blahblahblah(x)
local table = {
"asd" = 123,
"x" = 0.34,
}
if x ~= 3 then
print( x )
elseif x == "string"
my_custom_function( 0x34 )
else
unknown_function( "some string" )
end
--single line comment
end
function blablabla3()
for k,v in ipairs( table ) do
--abcde..
y=[=[
x=[[
x is a multi line string
]]
but its definition is iside a highest level string!
]=]
print(" \"\" ")
--this marks a parser error:
s = [== asdasdasd]]
s = math.sin( x )
end
end
</textarea>
</div>
<script type="text/javascript">
var editor = CodeMirror.fromTextArea('code', {
height: "350px",
parserfile: "../contrib/lua/js/parselua.js",
stylesheet: "css/luacolors.css",
path: "../../js/"
});
</script>
</body>
</html>

View File

@@ -0,0 +1,253 @@
/*
Simple parser for LUA
Written for Lua 5.1, based on parsecss and other parsers.
features: highlights keywords, strings, comments (no leveling supported! ("[==[")),tokens, basic indenting
to make this parser highlight your special functions pass table with this functions names to parserConfig argument of creator,
parserConfig: ["myfunction1","myfunction2"],
*/
function findFirstRegexp(words) {
return new RegExp("^(?:" + words.join("|") + ")", "i");
}
function matchRegexp(words) {
return new RegExp("^(?:" + words.join("|") + ")$", "i");
}
var luaCustomFunctions= matchRegexp([]);
function configureLUA(parserConfig){
if(parserConfig)
luaCustomFunctions= matchRegexp(parserConfig);
}
//long list of standard functions from lua manual
var luaStdFunctions = matchRegexp([
"_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall",
"coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",
"debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback",
"close","flush","lines","read","seek","setvbuf","write",
"io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write",
"math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh",
"os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname",
"package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall",
"string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper",
"table.concat","table.insert","table.maxn","table.remove","table.sort"
]);
var luaKeywords = matchRegexp(["and","break","elseif","false","nil","not","or","return",
"true","function", "end", "if", "then", "else", "do",
"while", "repeat", "until", "for", "in", "local" ]);
var luaIndentKeys = matchRegexp(["function", "if","repeat","for","while", "[\(]", "{"]);
var luaUnindentKeys = matchRegexp(["end", "until", "[\)]", "}"]);
var luaUnindentKeys2 = findFirstRegexp(["end", "until", "[\)]", "}"]);
var luaMiddleKeys = findFirstRegexp(["else","elseif"]);
var LUAParser = Editor.Parser = (function() {
var tokenizeLUA = (function() {
function normal(source, setState) {
var ch = source.next();
if (ch == "-" && source.equals("-")) {
source.next();
setState(inSLComment);
return null;
}
else if (ch == "\"" || ch == "'") {
setState(inString(ch));
return null;
}
if (ch == "[" && (source.equals("[") || source.equals("="))) {
var level = 0;
while(source.equals("=")){
level ++;
source.next();
}
if(! source.equals("[") )
return "lua-error";
setState(inMLSomething(level,"lua-string"));
return null;
}
else if (ch == "=") {
if (source.equals("="))
source.next();
return "lua-token";
}
else if (ch == ".") {
if (source.equals("."))
source.next();
if (source.equals("."))
source.next();
return "lua-token";
}
else if (ch == "+" || ch == "-" || ch == "*" || ch == "/" || ch == "%" || ch == "^" || ch == "#" ) {
return "lua-token";
}
else if (ch == ">" || ch == "<" || ch == "(" || ch == ")" || ch == "{" || ch == "}" || ch == "[" ) {
return "lua-token";
}
else if (ch == "]" || ch == ";" || ch == ":" || ch == ",") {
return "lua-token";
}
else if (source.equals("=") && (ch == "~" || ch == "<" || ch == ">")) {
source.next();
return "lua-token";
}
else if (/\d/.test(ch)) {
source.nextWhileMatches(/[\w.%]/);
return "lua-number";
}
else {
source.nextWhileMatches(/[\w\\\-_.]/);
return "lua-identifier";
}
}
function inSLComment(source, setState) {
var start = true;
var count=0;
while (!source.endOfLine()) {
var ch = source.next();
var level = 0;
if ((ch =="[") && start)
while(source.equals("=")){
source.next();
level++;
}
if (source.equals("[")){
setState(inMLSomething(level,"lua-comment"));
return null;
}
start = false;
}
setState(normal);
return "lua-comment";
}
function inMLSomething(level,what) {
//wat sholud be "lua-string" or "lua-comment", level is the number of "=" in opening mark.
return function(source, setState){
var dashes = 0;
while (!source.endOfLine()) {
var ch = source.next();
if (dashes == level+1 && ch == "]" ) {
setState(normal);
break;
}
if (dashes == 0)
dashes = (ch == "]") ? 1:0;
else
dashes = (ch == "=") ? dashes + 1 : 0;
}
return what;
}
}
function inString(quote) {
return function(source, setState) {
var escaped = false;
while (!source.endOfLine()) {
var ch = source.next();
if (ch == quote && !escaped)
break;
escaped = !escaped && ch == "\\";
}
if (!escaped)
setState(normal);
return "lua-string";
};
}
return function(source, startState) {
return tokenizer(source, startState || normal);
};
})();
function indentLUA(indentDepth, base) {
return function(nextChars) {
var closing = (luaUnindentKeys2.test(nextChars) || luaMiddleKeys.test(nextChars));
return base + ( indentUnit * (indentDepth - (closing?1:0)) );
};
}
function parseLUA(source,basecolumn) {
basecolumn = basecolumn || 0;
var tokens = tokenizeLUA(source);
var indentDepth = 0;
var iter = {
next: function() {
var token = tokens.next(), style = token.style, content = token.content;
if (style == "lua-identifier" && luaKeywords.test(content)){
token.style = "lua-keyword";
}
if (style == "lua-identifier" && luaStdFunctions.test(content)){
token.style = "lua-stdfunc";
}
if (style == "lua-identifier" && luaCustomFunctions.test(content)){
token.style = "lua-customfunc";
}
if (luaIndentKeys.test(content))
indentDepth++;
else if (luaUnindentKeys.test(content))
indentDepth--;
if (content == "\n")
token.indentation = indentLUA( indentDepth, basecolumn);
return token;
},
copy: function() {
var _tokenState = tokens.state, _indentDepth = indentDepth;
return function(source) {
tokens = tokenizeLUA(source, _tokenState);
indentDepth = _indentDepth;
return iter;
};
}
};
return iter;
}
return {make: parseLUA, configure:configureLUA, electricChars: "delf})"}; //en[d] els[e] unti[l] elsei[f] // this should be taken from Keys keywords
})();