Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<!doctype html>
<title>CodeMirror: Swift mode</title>
<meta charset="utf-8" />
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="./swift.js"></script>
<style>
.CodeMirror {
border: 2px inset #dee;
}
</style>
<div id=nav>
<a href="http://codemirror.net">
<h1>CodeMirror</h1>
<img id=logo src="../../doc/logo.png">
</a>
<ul>
<li>
<a href="../../index.html">Home</a>
<li>
<a href="../../doc/manual.html">Manual</a>
<li>
<a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li>
<a href="../index.html">Language modes</a>
<li>
<a class=active href="#">Swift</a>
</ul>
</div>
<article>
<h2>Swift mode</h2>
<form>
<textarea id="code" name="code"> // // TipCalculatorModel.swift // TipCalculator // // Created by Main Account on 12/18/14. // Copyright (c) 2014 Razeware LLC. All rights reserved. // import Foundation class TipCalculatorModel { var total: Double var taxPct: Double var subtotal:
Double { get { return total / (taxPct + 1) } } init(total: Double, taxPct: Double) { self.total = total self.taxPct = taxPct } func calcTipWithTipPct(tipPct: Double) -> Double { return subtotal * tipPct } func returnPossibleTips() -> [Int:
Double] { let possibleTipsInferred = [0.15, 0.18, 0.20] let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20] var retval = [Int: Double]() for possibleTip in possibleTipsInferred { let intPct = Int(possibleTip*100) retval[intPct] = calcTipWithTipPct(possibleTip)
} return retval } } </textarea>
</form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"),
{
lineNumbers: true,
matchBrackets: true,
mode: "text/x-swift"
});
</script>
<p>A simple mode for Swift</p>
<p>
<strong>MIME types defined:</strong> <code>text/x-swift</code> (Swift code)</p>
</article>

View File

@@ -0,0 +1,203 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Swift mode created by Michael Kaminsky https://github.com/mkaminsky11
(function(mod) {
if (typeof exports == "object" && typeof module == "object")
mod(require("../../lib/codemirror"))
else if (typeof define == "function" && define.amd)
define(["../../lib/codemirror"], mod)
else
mod(CodeMirror)
})(function(CodeMirror) {
"use strict"
function trim(str) { return /^\s*(.*?)\s*$/.exec(str)[1] }
var separators = [" ","\\\+","\\\-","\\\(","\\\)","\\\*","/",":","\\\?","\\\<","\\\>"," ","\\\."]
var tokens = new RegExp(separators.join("|"),"g")
function getWord(string, pos) {
var index = -1, count = 1
var words = string.split(tokens)
for (var i = 0; i < words.length; i++) {
for(var j = 1; j <= words[i].length; j++) {
if (count==pos) index = i
count++
}
count++
}
var ret = ["", ""]
if (pos == 0) {
ret[1] = words[0]
ret[0] = null
} else {
ret[1] = words[index]
ret[0] = words[index-1]
}
return ret
}
CodeMirror.defineMode("swift", function() {
var keywords=["var","let","class","deinit","enum","extension","func","import","init","let","protocol","static","struct","subscript","typealias","var","as","dynamicType","is","new","super","self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case","continue","default","do","else","fallthrough","if","in","for","return","switch","where","while","associativity","didSet","get","infix","inout","left","mutating","none","nonmutating","operator","override","postfix","precedence","prefix","right","set","unowned","unowned(safe)","unowned(unsafe)","weak","willSet"]
var commonConstants=["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null","this","super"]
var types=["String","bool","int","string","double","Double","Int","Float","float","public","private","extension"]
var numbers=["0","1","2","3","4","5","6","7","8","9"]
var operators=["+","-","/","*","%","=","|","&","<",">"]
var punc=[";",",",".","(",")","{","}","[","]"]
var delimiters=/^(?:[()\[\]{},:`=;]|\.\.?\.?)/
var identifiers=/^[_A-Za-z$][_A-Za-z$0-9]*/
var properties=/^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/
var regexPrefixes=/^(\/{3}|\/)/
return {
startState: function() {
return {
prev: false,
string: false,
escape: false,
inner: false,
comment: false,
num_left: 0,
num_right: 0,
doubleString: false,
singleString: false
}
},
token: function(stream, state) {
if (stream.eatSpace()) return null
var ch = stream.next()
if (state.string) {
if (state.escape) {
state.escape = false
return "string"
} else {
if ((ch == "\"" && (state.doubleString && !state.singleString) ||
(ch == "'" && (!state.doubleString && state.singleString))) &&
!state.escape) {
state.string = false
state.doubleString = false
state.singleString = false
return "string"
} else if (ch == "\\" && stream.peek() == "(") {
state.inner = true
state.string = false
return "keyword"
} else if (ch == "\\" && stream.peek() != "(") {
state.escape = true
state.string = true
return "string"
} else {
return "string"
}
}
} else if (state.comment) {
if (ch == "*" && stream.peek() == "/") {
state.prev = "*"
return "comment"
} else if (ch == "/" && state.prev == "*") {
state.prev = false
state.comment = false
return "comment"
}
return "comment"
} else {
if (ch == "/") {
if (stream.peek() == "/") {
stream.skipToEnd()
return "comment"
}
if (stream.peek() == "*") {
state.comment = true
return "comment"
}
}
if (ch == "(" && state.inner) {
state.num_left++
return null
}
if (ch == ")" && state.inner) {
state.num_right++
if (state.num_left == state.num_right) {
state.inner=false
state.string=true
}
return null
}
var ret = getWord(stream.string, stream.pos)
var the_word = ret[1]
var prev_word = ret[0]
if (operators.indexOf(ch + "") > -1) return "operator"
if (punc.indexOf(ch) > -1) return "punctuation"
if (typeof the_word != "undefined") {
the_word = trim(the_word)
if (typeof prev_word != "undefined") prev_word = trim(prev_word)
if (the_word.charAt(0) == "#") return null
if (types.indexOf(the_word) > -1) return "def"
if (commonConstants.indexOf(the_word) > -1) return "atom"
if (numbers.indexOf(the_word) > -1) return "number"
if ((numbers.indexOf(the_word.charAt(0) + "") > -1 ||
operators.indexOf(the_word.charAt(0) + "") > -1) &&
numbers.indexOf(ch) > -1) {
return "number"
}
if (keywords.indexOf(the_word) > -1 ||
keywords.indexOf(the_word.split(tokens)[0]) > -1)
return "keyword"
if (keywords.indexOf(prev_word) > -1) return "def"
}
if (ch == '"' && !state.doubleString) {
state.string = true
state.doubleString = true
return "string"
}
if (ch == "'" && !state.singleString) {
state.string = true
state.singleString = true
return "string"
}
if (ch == "(" && state.inner)
state.num_left++
if (ch == ")" && state.inner) {
state.num_right++
if (state.num_left == state.num_right) {
state.inner = false
state.string = true
}
return null
}
if (stream.match(/^-?[0-9\.]/, false)) {
if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) ||
stream.match(/^-?\d+\.\d*/) ||
stream.match(/^-?\.\d+/)) {
if (stream.peek() == ".") stream.backUp(1)
return "number"
}
if (stream.match(/^-?0x[0-9a-f]+/i) ||
stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) ||
stream.match(/^-?0(?![\dx])/i))
return "number"
}
if (stream.match(regexPrefixes)) {
if (stream.current()!="/" || stream.match(/^.*\//,false)) return "string"
else stream.backUp(1)
}
if (stream.match(delimiters)) return "punctuation"
if (stream.match(identifiers)) return "variable"
if (stream.match(properties)) return "property"
return "variable"
}
}
}
})
CodeMirror.defineMIME("text/x-swift","swift")
})

View File

@@ -0,0 +1,149 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "swift");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
// Ensure all number types are properly represented.
MT("numbers",
"[keyword var] [def a] [operator =] [number 17]",
"[keyword var] [def b] [operator =] [number -0.5]",
"[keyword var] [def c] [operator =] [number 0.3456e-4]",
"[keyword var] [def d] [operator =] [number 345e2]",
"[keyword var] [def e] [operator =] [number 0o7324]",
"[keyword var] [def f] [operator =] [number 0b10010]",
"[keyword var] [def g] [operator =] [number -0x35ade]",
"[keyword var] [def h] [operator =] [number 0xaea.ep-13]",
"[keyword var] [def i] [operator =] [number 0x13ep6]");
// Variable/class/etc definition.
MT("definition",
"[keyword var] [def a] [operator =] [number 5]",
"[keyword let] [def b][punctuation :] [variable-2 Int] [operator =] [number 10]",
"[keyword class] [def C] [punctuation {] [punctuation }]",
"[keyword struct] [def D] [punctuation {] [punctuation }]",
"[keyword enum] [def E] [punctuation {] [punctuation }]",
"[keyword extension] [def F] [punctuation {] [punctuation }]",
"[keyword protocol] [def G] [punctuation {] [punctuation }]",
"[keyword func] [def h][punctuation ()] [punctuation {] [punctuation }]",
"[keyword import] [def Foundation]",
"[keyword typealias] [def NewString] [operator =] [variable-2 String]",
"[keyword associatedtype] [def I]",
"[keyword for] [def j] [keyword in] [number 0][punctuation ..][operator <][number 3] [punctuation {] [punctuation }]");
// Strings and string interpolation.
MT("strings",
"[keyword var] [def a][punctuation :] [variable-2 String] [operator =] [string \"test\"]",
"[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]");
// Comments.
MT("comments",
"[comment // This is a comment]",
"[comment /* This is another comment */]",
"[keyword var] [def a] [operator =] [number 5] [comment // Third comment]");
// Atoms.
MT("atoms",
"[keyword class] [def FooClass] [punctuation {]",
" [keyword let] [def fooBool][punctuation :] [variable-2 Bool][operator ?]",
" [keyword let] [def fooInt][punctuation :] [variable-2 Int][operator ?]",
" [keyword func] [keyword init][punctuation (][variable fooBool][punctuation :] [variable-2 Bool][punctuation ,] [variable barBool][punctuation :] [variable-2 Bool][punctuation )] [punctuation {]",
" [atom super][property .init][punctuation ()]",
" [atom self][property .fooBool] [operator =] [variable fooBool]",
" [variable fooInt] [operator =] [atom nil]",
" [keyword if] [variable barBool] [operator ==] [atom true] [punctuation {]",
" [variable print][punctuation (][string \"True!\"][punctuation )]",
" [punctuation }] [keyword else] [keyword if] [variable barBool] [operator ==] [atom false] [punctuation {]",
" [keyword for] [atom _] [keyword in] [number 0][punctuation ...][number 5] [punctuation {]",
" [variable print][punctuation (][string \"False!\"][punctuation )]",
" [punctuation }]",
" [punctuation }]",
" [punctuation }]",
"[punctuation }]");
// Types.
MT("types",
"[keyword var] [def a] [operator =] [variable-2 Array][operator <][variable-2 Int][operator >]",
"[keyword var] [def b] [operator =] [variable-2 Set][operator <][variable-2 Bool][operator >]",
"[keyword var] [def c] [operator =] [variable-2 Dictionary][operator <][variable-2 String][punctuation ,][variable-2 Character][operator >]",
"[keyword var] [def d][punctuation :] [variable-2 Int64][operator ?] [operator =] [variable-2 Optional][punctuation (][number 8][punctuation )]",
"[keyword func] [def e][punctuation ()] [operator ->] [variable-2 Void] [punctuation {]",
" [keyword var] [def e1][punctuation :] [variable-2 Float] [operator =] [number 1.2]",
"[punctuation }]",
"[keyword func] [def f][punctuation ()] [operator ->] [variable-2 Never] [punctuation {]",
" [keyword var] [def f1][punctuation :] [variable-2 Double] [operator =] [number 2.4]",
"[punctuation }]");
// Operators.
MT("operators",
"[keyword var] [def a] [operator =] [number 1] [operator +] [number 2]",
"[keyword var] [def b] [operator =] [number 1] [operator -] [number 2]",
"[keyword var] [def c] [operator =] [number 1] [operator *] [number 2]",
"[keyword var] [def d] [operator =] [number 1] [operator /] [number 2]",
"[keyword var] [def e] [operator =] [number 1] [operator %] [number 2]",
"[keyword var] [def f] [operator =] [number 1] [operator |] [number 2]",
"[keyword var] [def g] [operator =] [number 1] [operator &] [number 2]",
"[keyword var] [def h] [operator =] [number 1] [operator <<] [number 2]",
"[keyword var] [def i] [operator =] [number 1] [operator >>] [number 2]",
"[keyword var] [def j] [operator =] [number 1] [operator ^] [number 2]",
"[keyword var] [def k] [operator =] [operator ~][number 1]",
"[keyword var] [def l] [operator =] [variable foo] [operator ?] [number 1] [punctuation :] [number 2]",
"[keyword var] [def m][punctuation :] [variable-2 Int] [operator =] [variable-2 Optional][punctuation (][number 8][punctuation )][operator !]");
// Punctuation.
MT("punctuation",
"[keyword let] [def a] [operator =] [number 1][punctuation ;] [keyword let] [def b] [operator =] [number 2]",
"[keyword let] [def testArr][punctuation :] [punctuation [[][variable-2 Int][punctuation ]]] [operator =] [punctuation [[][variable a][punctuation ,] [variable b][punctuation ]]]",
"[keyword for] [def i] [keyword in] [number 0][punctuation ..][operator <][variable testArr][property .count] [punctuation {]",
" [variable print][punctuation (][variable testArr][punctuation [[][variable i][punctuation ]])]",
"[punctuation }]");
// Identifiers.
MT("identifiers",
"[keyword let] [def abc] [operator =] [number 1]",
"[keyword let] [def ABC] [operator =] [number 2]",
"[keyword let] [def _123] [operator =] [number 3]",
"[keyword let] [def _$1$2$3] [operator =] [number 4]",
"[keyword let] [def A1$_c32_$_] [operator =] [number 5]",
"[keyword let] [def `var`] [operator =] [punctuation [[][number 1][punctuation ,] [number 2][punctuation ,] [number 3][punctuation ]]]",
"[keyword let] [def square$] [operator =] [variable `var`][property .map] [punctuation {][variable $0] [operator *] [variable $0][punctuation }]",
"$$ [number 1][variable a] $[atom _] [variable _$] [variable __] `[variable a] [variable b]`");
// Properties.
MT("properties",
"[variable print][punctuation (][variable foo][property .abc][punctuation )]",
"[variable print][punctuation (][variable foo][property .ABC][punctuation )]",
"[variable print][punctuation (][variable foo][property ._123][punctuation )]",
"[variable print][punctuation (][variable foo][property ._$1$2$3][punctuation )]",
"[variable print][punctuation (][variable foo][property .A1$_c32_$_][punctuation )]",
"[variable print][punctuation (][variable foo][property .`var`][punctuation )]",
"[variable print][punctuation (][variable foo][property .__][punctuation )]");
// Instructions or other things that start with #.
MT("instructions",
"[keyword if] [builtin #available][punctuation (][variable iOS] [number 9][punctuation ,] [operator *][punctuation )] [punctuation {}]",
"[variable print][punctuation (][builtin #file][punctuation ,] [builtin #function][punctuation )]",
"[variable print][punctuation (][builtin #line][punctuation ,] [builtin #column][punctuation )]",
"[builtin #if] [atom true]",
"[keyword import] [def A]",
"[builtin #elseif] [atom false]",
"[keyword import] [def B]",
"[builtin #endif]",
"[builtin #sourceLocation][punctuation (][variable file][punctuation :] [string \"file.swift\"][punctuation ,] [variable line][punctuation :] [number 2][punctuation )]");
// Attributes; things that start with @.
MT("attributes",
"[attribute @objc][punctuation (][variable objcFoo][punctuation :)]",
"[attribute @available][punctuation (][variable iOS][punctuation )]");
// Property/number edge case.
MT("property_number",
"[variable print][punctuation (][variable foo][property ._123][punctuation )]",
"[variable print][punctuation (]")
// TODO: correctly identify when multiple variables are being declared
// by use of a comma-separated list.
// TODO: correctly identify when variables are being declared in a tuple.
// TODO: identify protocols as types when used before an extension?
})();