mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 21d7f99a4e | ||
|  | 24b368a30c | ||
|  | 7c8bc8561d | ||
|  | ce37cd665d | ||
|  | bd0f4f6f78 | ||
|  | 4867db8831 | 
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -698,3 +698,6 @@ | ||||
| [submodule "vendor/grammars/grace"] | ||||
| 	path = vendor/grammars/grace | ||||
| 	url = https://github.com/zmthy/grace-tmbundle | ||||
| [submodule "vendor/grammars/nix"] | ||||
| 	path = vendor/grammars/nix | ||||
| 	url = https://github.com/wmertens/sublime-nix | ||||
|   | ||||
| @@ -414,6 +414,8 @@ vendor/grammars/nesC: | ||||
| - source.nesc | ||||
| vendor/grammars/ninja.tmbundle: | ||||
| - source.ninja | ||||
| vendor/grammars/nix: | ||||
| - source.nix | ||||
| vendor/grammars/objective-c.tmbundle: | ||||
| - source.objc | ||||
| - source.objc++ | ||||
|   | ||||
| @@ -127,6 +127,14 @@ module Linguist | ||||
|         Language["ECL"] | ||||
|       end | ||||
|     end | ||||
|      | ||||
|     disambiguate ".es" do |data| | ||||
|       if /^\s*(?:%%|main\s*\(.*?\)\s*->)/.match(data) | ||||
|         Language["Erlang"] | ||||
|       elsif /(?:\/\/|("|')use strict\1|export\s+default\s|\/\*.*?\*\/)/m.match(data) | ||||
|         Language["JavaScript"] | ||||
|       end | ||||
|     end | ||||
|  | ||||
|     disambiguate ".for", ".f" do |data| | ||||
|       if /^: /.match(data) | ||||
|   | ||||
| @@ -1694,6 +1694,7 @@ JavaScript: | ||||
|   - .js | ||||
|   - ._js | ||||
|   - .bones | ||||
|   - .es | ||||
|   - .es6 | ||||
|   - .frag | ||||
|   - .gs | ||||
| @@ -2373,7 +2374,7 @@ Nix: | ||||
|   - .nix | ||||
|   aliases: | ||||
|   - nixos | ||||
|   tm_scope: none | ||||
|   tm_scope: source.nix | ||||
|   ace_mode: nix | ||||
|  | ||||
| Nu: | ||||
|   | ||||
| @@ -1,3 +1,3 @@ | ||||
| module Linguist | ||||
|   VERSION = "4.8.1" | ||||
|   VERSION = "4.8.2" | ||||
| end | ||||
|   | ||||
							
								
								
									
										26
									
								
								samples/Erlang/170-os-daemons.es
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								samples/Erlang/170-os-daemons.es
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| #! /usr/bin/env escript | ||||
|  | ||||
| % Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||||
| % use this file except in compliance with the License. You may obtain a copy of | ||||
| % the License at | ||||
| % | ||||
| %   http://www.apache.org/licenses/LICENSE-2.0 | ||||
| % | ||||
| % Unless required by applicable law or agreed to in writing, software | ||||
| % distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
| % WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
| % License for the specific language governing permissions and limitations under | ||||
| % the License. | ||||
|  | ||||
| loop() -> | ||||
| 	loop(io:read("")). | ||||
|  | ||||
| loop({ok, _}) -> | ||||
| 	loop(io:read("")); | ||||
| loop(eof) -> | ||||
| 	stop; | ||||
| loop({error, Reason}) -> | ||||
| 	throw({error, Reason}). | ||||
|  | ||||
| main([]) -> | ||||
| 	loop(). | ||||
							
								
								
									
										1
									
								
								samples/Erlang/release
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										1
									
								
								samples/Erlang/release
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -119,4 +119,3 @@ execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) -> | ||||
|  | ||||
| exit_code(ExitCode) -> | ||||
|     erlang:halt(ExitCode, [{flush, true}]). | ||||
|  | ||||
|   | ||||
							
								
								
									
										104
									
								
								samples/Erlang/single-context.es
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										104
									
								
								samples/Erlang/single-context.es
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,104 @@ | ||||
| #! /usr/bin/env escript | ||||
| % This file is part of Emonk released under the MIT license.  | ||||
| % See the LICENSE file for more information. | ||||
|  | ||||
| main([]) -> | ||||
| 	start(64, 1000); | ||||
| main([N]) -> | ||||
| 	start(list_to_integer(N), 1000); | ||||
| main([N, M]) -> | ||||
| 	start(list_to_integer(N), list_to_integer(M)). | ||||
|  | ||||
|  | ||||
| start(N, M) -> | ||||
| 	code:add_pathz("test"), | ||||
| 	code:add_pathz("ebin"), | ||||
| 	{ok, Ctx} = emonk:create_ctx(), | ||||
| 	{ok, undefined} = emonk:eval(Ctx, js()), | ||||
| 	run(Ctx, N, M), | ||||
| 	wait(N). | ||||
|  | ||||
| run(_, 0, _) -> | ||||
| 	ok; | ||||
| run(Ctx, N, M) -> | ||||
| 	Self = self(), | ||||
| 	Pid = spawn(fun() -> do_js(Self, Ctx, M) end), | ||||
| 	io:format("Spawned: ~p~n", [Pid]), | ||||
| 	run(Ctx, N-1, M). | ||||
|  | ||||
| wait(0) -> | ||||
| 	ok; | ||||
| wait(N) -> | ||||
| 	receive | ||||
| 		{finished, Pid} -> ok | ||||
| 	end, | ||||
| 	io:format("Finished: ~p~n", [Pid]), | ||||
| 	wait(N-1). | ||||
|  | ||||
| do_js(Parent, _, 0) -> | ||||
| 	Parent ! {finished, self()}; | ||||
| do_js(Parent, Ctx, M) -> | ||||
| 	io:format("Running: ~p~n", [M]), | ||||
| 	Test = random_test(), | ||||
| 	{ok, [Resp]} = emonk:call(Ctx, <<"f">>, [Test]), | ||||
| 	Sorted = sort(Resp), | ||||
| 	true = Test == Sorted, | ||||
| 	do_js(Parent, Ctx, M-1). | ||||
|  | ||||
| js() ->  | ||||
| 	<<"var f = function(x) {return [x];};">>. | ||||
|  | ||||
| random_test() -> | ||||
| 	Tests = [ | ||||
| 		null, | ||||
| 		true, | ||||
| 		false, | ||||
| 		1, | ||||
| 		-1, | ||||
| 		3.1416, | ||||
| 		-3.1416, | ||||
| 		12.0e10, | ||||
| 		1.234E+10, | ||||
| 		-1.234E-10, | ||||
| 		10.0, | ||||
| 		123.456, | ||||
| 		10.0, | ||||
| 		<<"foo">>, | ||||
| 		<<"foo", 5, "bar">>, | ||||
| 		<<"">>, | ||||
| 		<<"\n\n\n">>, | ||||
| 		<<"\" \b\f\r\n\t\"">>, | ||||
| 		{[]}, | ||||
| 		{[{<<"foo">>, <<"bar">>}]}, | ||||
| 		{[{<<"foo">>, <<"bar">>}, {<<"baz">>, 123}]}, | ||||
| 		[], | ||||
| 		[[]], | ||||
| 		[1, <<"foo">>], | ||||
| 		{[{<<"foo">>, [123]}]}, | ||||
| 		{[{<<"foo">>, [1, 2, 3]}]}, | ||||
| 		{[{<<"foo">>, {[{<<"bar">>, true}]}}]}, | ||||
| 		{[ | ||||
| 			{<<"foo">>, []}, | ||||
| 			{<<"bar">>, {[{<<"baz">>, true}]}}, {<<"alice">>, <<"bob">>} | ||||
| 		]}, | ||||
| 		[-123, <<"foo">>, {[{<<"bar">>, []}]}, null] | ||||
| 	], | ||||
| 	{_, [Test | _]} = lists:split(random:uniform(length(Tests)) - 1, Tests), | ||||
| 	sort(Test). | ||||
|  | ||||
| sort({Props}) -> | ||||
| 	objsort(Props, []); | ||||
| sort(List) when is_list(List) -> | ||||
| 	lstsort(List, []); | ||||
| sort(Other) -> | ||||
| 	Other. | ||||
|  | ||||
| objsort([], Acc) -> | ||||
| 	{lists:sort(Acc)}; | ||||
| objsort([{K,V} | Rest], Acc) -> | ||||
| 	objsort(Rest, [{K, sort(V)} | Acc]). | ||||
|  | ||||
| lstsort([], Acc) -> | ||||
| 	lists:reverse(Acc); | ||||
| lstsort([Val | Rest], Acc) -> | ||||
| 	lstsort(Rest, [sort(Val) | Acc]). | ||||
							
								
								
									
										13
									
								
								samples/JavaScript/axios.es
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								samples/JavaScript/axios.es
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| import axios from "axios"; | ||||
|  | ||||
| export default { | ||||
| 	async getIndex(prefix) { | ||||
| 		const {data} = await axios.get((prefix || "") + "/index.json"); | ||||
| 		return data; | ||||
| 	}, | ||||
| 	 | ||||
| 	async getContent(path, prefix) { | ||||
| 		const {data} = await axios.get((prefix || "") + "/" + path + ".json"); | ||||
| 		return data; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										35
									
								
								samples/JavaScript/index.es
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								samples/JavaScript/index.es
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| import config from "../webpack.config"; | ||||
| import webpackDevMiddleware from "webpack-dev-middleware"; | ||||
| import webpackHot from "webpack-hot-middleware"; | ||||
| import webpack from "webpack"; | ||||
| import express from "express"; | ||||
|  | ||||
| app.use(webpackDevMiddleware(compiler, { | ||||
| 	noInfo: false, | ||||
| 	quiet: false, | ||||
| 	publicPath: config.output.publicPath, | ||||
| 	hot: true, | ||||
| 	historyApiFallback: true | ||||
| })); | ||||
| 	 | ||||
| app.get("/(:root).json", (req, resp) => { | ||||
| 	resp.send(indexer.index(req.params.root)); | ||||
| }); | ||||
|  | ||||
| export default function(){ | ||||
| 	const server = http.createServer(app); | ||||
| 	 | ||||
| 	server.listen(3000); | ||||
| 	 | ||||
| 	const wss = new WebSocketServer({server}); | ||||
| 	 | ||||
| 	let id = 1; | ||||
| 	wss.on("connection", (ws) => { | ||||
| 		console.log("Hello", " world"); | ||||
| 		let wsId = id++; | ||||
| 		sessions[wsId] = ws; | ||||
| 		ws.on("close", () => { | ||||
| 			delete sessions[wsId] | ||||
| 		}); | ||||
| 	}); | ||||
| }; | ||||
| @@ -83,6 +83,13 @@ class TestHeuristcs < Minitest::Test | ||||
|       "ECLiPSe" => all_fixtures("ECLiPSe", "*.ecl") | ||||
|     }) | ||||
|   end | ||||
|    | ||||
|   def test_es_by_heuristics | ||||
|     assert_heuristics({ | ||||
|       "Erlang" => all_fixtures("Erlang", "*.es"), | ||||
|       "JavaScript" => all_fixtures("JavaScript", "*.es") | ||||
|     }) | ||||
|   end | ||||
|  | ||||
|   def test_f_by_heuristics | ||||
|     assert_heuristics({ | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/grammars/SublimePuppet
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/SublimePuppet
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/SublimePuppet updated: 88df07785b...2eab0a7679
									
								
							
							
								
								
									
										2
									
								
								vendor/grammars/atom-language-purescript
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/atom-language-purescript
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/atom-language-purescript updated: bd2b59f14e...a84db1fd17
									
								
							
							
								
								
									
										2
									
								
								vendor/grammars/elixir-tmbundle
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/elixir-tmbundle
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/elixir-tmbundle updated: a7aa16e349...6ee8051a75
									
								
							
							
								
								
									
										2
									
								
								vendor/grammars/language-less
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/language-less
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/language-less updated: a4ded2608c...30c6864d5d
									
								
							
							
								
								
									
										2
									
								
								vendor/grammars/language-python
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/language-python
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/language-python updated: 75f0d2b061...e44c37a2ed
									
								
							
							
								
								
									
										2
									
								
								vendor/grammars/language-shellscript
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/language-shellscript
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/language-shellscript updated: be4dbbf19a...ef3c7d2091
									
								
							
							
								
								
									
										1
									
								
								vendor/grammars/nix
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/grammars/nix
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/grammars/nix added at cf33194bcc
									
								
							
							
								
								
									
										2
									
								
								vendor/grammars/ruby-slim.tmbundle
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								vendor/grammars/ruby-slim.tmbundle
									
									
									
									
										vendored
									
									
								
							 Submodule vendor/grammars/ruby-slim.tmbundle updated: 741ccd5620...599768b404
									
								
							
							
								
								
									
										13
									
								
								vendor/licenses/grammar/nix.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								vendor/licenses/grammar/nix.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| --- | ||||
| type: grammar | ||||
| name: nix | ||||
| license: mit | ||||
| --- | ||||
| The MIT License (MIT) | ||||
| Copyright (c) 2016 Wout Mertens | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
		Reference in New Issue
	
	Block a user