mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Merge branch 'master' into script-fixes
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -568,6 +568,9 @@ | |||||||
| [submodule "vendor/grammars/language-ruby"] | [submodule "vendor/grammars/language-ruby"] | ||||||
| 	path = vendor/grammars/language-ruby | 	path = vendor/grammars/language-ruby | ||||||
| 	url = https://github.com/atom/language-ruby | 	url = https://github.com/atom/language-ruby | ||||||
|  | [submodule "vendor/grammars/language-sed"] | ||||||
|  | 	path = vendor/grammars/language-sed | ||||||
|  | 	url = https://github.com/Alhadis/language-sed | ||||||
| [submodule "vendor/grammars/language-shellscript"] | [submodule "vendor/grammars/language-shellscript"] | ||||||
| 	path = vendor/grammars/language-shellscript | 	path = vendor/grammars/language-shellscript | ||||||
| 	url = https://github.com/atom/language-shellscript | 	url = https://github.com/atom/language-shellscript | ||||||
|   | |||||||
| @@ -484,6 +484,8 @@ vendor/grammars/language-ruby: | |||||||
| - source.ruby | - source.ruby | ||||||
| - source.ruby.gemfile | - source.ruby.gemfile | ||||||
| - text.html.erb | - text.html.erb | ||||||
|  | vendor/grammars/language-sed: | ||||||
|  | - source.sed | ||||||
| vendor/grammars/language-shellscript: | vendor/grammars/language-shellscript: | ||||||
| - source.shell | - source.shell | ||||||
| - text.shell-session | - text.shell-session | ||||||
|   | |||||||
| @@ -3386,6 +3386,8 @@ Perl: | |||||||
|   - ".psgi" |   - ".psgi" | ||||||
|   - ".t" |   - ".t" | ||||||
|   filenames: |   filenames: | ||||||
|  |   - Makefile.PL | ||||||
|  |   - Rexfile | ||||||
|   - ack |   - ack | ||||||
|   - cpanfile |   - cpanfile | ||||||
|   interpreters: |   interpreters: | ||||||
| @@ -3409,8 +3411,6 @@ Perl 6: | |||||||
|   - ".pm" |   - ".pm" | ||||||
|   - ".pm6" |   - ".pm6" | ||||||
|   - ".t" |   - ".t" | ||||||
|   filenames: |  | ||||||
|   - Rexfile |  | ||||||
|   interpreters: |   interpreters: | ||||||
|   - perl6 |   - perl6 | ||||||
|   aliases: |   aliases: | ||||||
| @@ -5360,6 +5360,19 @@ reStructuredText: | |||||||
|   codemirror_mode: rst |   codemirror_mode: rst | ||||||
|   codemirror_mime_type: text/x-rst |   codemirror_mime_type: text/x-rst | ||||||
|   language_id: 419 |   language_id: 419 | ||||||
|  | sed: | ||||||
|  |   type: programming | ||||||
|  |   color: "#64b970" | ||||||
|  |   extensions: | ||||||
|  |   - ".sed" | ||||||
|  |   interpreters: | ||||||
|  |   - gsed | ||||||
|  |   - minised | ||||||
|  |   - sed | ||||||
|  |   - ssed | ||||||
|  |   ace_mode: text | ||||||
|  |   tm_scope: source.sed | ||||||
|  |   language_id: 847830017 | ||||||
| wdl: | wdl: | ||||||
|   type: programming |   type: programming | ||||||
|   color: "#42f1f4" |   color: "#42f1f4" | ||||||
|   | |||||||
							
								
								
									
										100
									
								
								samples/Perl/Any.pm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								samples/Perl/Any.pm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,100 @@ | |||||||
|  | use strict; #-*-cperl-*- | ||||||
|  | use warnings; | ||||||
|  |  | ||||||
|  | use lib qw( ../../../../lib ); | ||||||
|  |  | ||||||
|  | =encoding utf8 | ||||||
|  |  | ||||||
|  | =head1 NAME | ||||||
|  |  | ||||||
|  | Algorithm::Evolutionary::Fitness::Any - Façade for any function so that it can be used as fitness | ||||||
|  |  | ||||||
|  | =head1 SYNOPSIS | ||||||
|  |  | ||||||
|  |    use Algorithm::Evolutionary::Utils qw( string_decode ) | ||||||
|  |  | ||||||
|  |    sub squares { | ||||||
|  |      my $chrom = shift; | ||||||
|  |      my @values = string_decode( $chrom, 10, -1, 1 ); | ||||||
|  |      return $values[0] * $values[1]; | ||||||
|  |    } | ||||||
|  |  | ||||||
|  |    my $any_eval = new Algorithm::Evolutionary::Fitness::Any \&squares; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | =head1 DESCRIPTION | ||||||
|  |  | ||||||
|  | Turns any subroutine or closure into a fitness function. Useful mainly | ||||||
|  | if you want results cached; it's not really needed otherwise. | ||||||
|  |  | ||||||
|  | =head1 METHODS | ||||||
|  |  | ||||||
|  | =cut | ||||||
|  |  | ||||||
|  | package Algorithm::Evolutionary::Fitness::Any; | ||||||
|  |  | ||||||
|  | use Carp; | ||||||
|  |  | ||||||
|  | use base 'Algorithm::Evolutionary::Fitness::Base'; | ||||||
|  |  | ||||||
|  | our $VERSION =  '3.2'; | ||||||
|  |  | ||||||
|  | =head2 new( $function ) | ||||||
|  |  | ||||||
|  | Assigns default variables | ||||||
|  |  | ||||||
|  | =cut  | ||||||
|  |  | ||||||
|  | sub new { | ||||||
|  |   my $class = shift; | ||||||
|  |   my $self = { _function => shift || croak "No functiona rray" }; | ||||||
|  |   bless $self, $class; | ||||||
|  |   $self->initialize(); | ||||||
|  |   return $self; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | =head2 apply( $individual ) | ||||||
|  |  | ||||||
|  | Applies the instantiated problem to a chromosome. It is actually a | ||||||
|  | wrapper around C<_apply>. | ||||||
|  |  | ||||||
|  | =cut | ||||||
|  |  | ||||||
|  | sub apply { | ||||||
|  |     my $self = shift; | ||||||
|  |     my $individual = shift || croak "Nobody here!!!"; | ||||||
|  |     $self->{'_counter'}++; | ||||||
|  |     return $self->_apply( $individual ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | =head2 _apply( $individual ) | ||||||
|  |  | ||||||
|  | This is the one that really does the stuff. It applies the defined | ||||||
|  | function to each individual. Itis cached for efficiency. | ||||||
|  |  | ||||||
|  | =cut | ||||||
|  |  | ||||||
|  | sub _apply { | ||||||
|  |   my $self = shift; | ||||||
|  |   my $individual = shift || croak "Nobody here!"; | ||||||
|  |   my $chrom = $individual->Chrom(); | ||||||
|  |   my $cache = $self->{'_cache'}; | ||||||
|  |   if ( $cache->{$chrom} ) { | ||||||
|  |     return $cache->{$chrom}; | ||||||
|  |   } | ||||||
|  |   my $result = $self->{'_function'}->($chrom); | ||||||
|  |   if ( (scalar $chrom ) eq $chrom ) { | ||||||
|  |     $cache->{$chrom} = $result; | ||||||
|  |   } | ||||||
|  |   return $result; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | =head1 Copyright | ||||||
|  |    | ||||||
|  |   This file is released under the GPL. See the LICENSE file included in this distribution, | ||||||
|  |   or go to http://www.fsf.org/licenses/gpl.txt | ||||||
|  |  | ||||||
|  | =cut | ||||||
|  |  | ||||||
|  | "What???"; | ||||||
							
								
								
									
										20
									
								
								samples/Perl/filenames/Makefile.PL
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								samples/Perl/filenames/Makefile.PL
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | use strict; | ||||||
|  | use warnings; | ||||||
|  | use ExtUtils::MakeMaker; | ||||||
|  |  | ||||||
|  | WriteMakefile( | ||||||
|  |     NAME                => 'Algorithm::Evolutionary::Simple', | ||||||
|  |     AUTHOR              => 'JJ Merelo <jj@merelo.net>', | ||||||
|  |     VERSION_FROM        => 'lib/Algorithm/Evolutionary/Simple.pm', | ||||||
|  |     ABSTRACT_FROM       => 'lib/Algorithm/Evolutionary/Simple.pm', | ||||||
|  |     LICENSE => 'gpl', | ||||||
|  |     EXE_FILES => [ 'script/simple-EA.pl',  'script/maxones.pl'], | ||||||
|  |     PREREQ_PM => { | ||||||
|  |         'Test::More' => 0, | ||||||
|  | 	'Carp' => 0, | ||||||
|  | 	'Exporter' => 0, | ||||||
|  | 	'Sort::Key::Top' => 0 | ||||||
|  |     }, | ||||||
|  |     dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, | ||||||
|  |     clean               => { FILES => 'Algorithm-Evolutionary-Simple-*' }, | ||||||
|  | ); | ||||||
							
								
								
									
										9
									
								
								samples/Perl/filenames/Rexfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								samples/Perl/filenames/Rexfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | use Rex -feature => ['1.0']; | ||||||
|  |  | ||||||
|  | user "eleccionesugr"; | ||||||
|  | group eleccionesugr => "elecciones-ugr.cloudapp.net"; | ||||||
|  |  | ||||||
|  | desc "Install perlbrew"; | ||||||
|  | task "perlbrew", group => "eleccionesugr", sub { | ||||||
|  | }; | ||||||
|  |  | ||||||
							
								
								
									
										103
									
								
								samples/sed/hanoi.sed
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								samples/sed/hanoi.sed
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,103 @@ | |||||||
|  | # Towers of Hanoi in sed. | ||||||
|  | # | ||||||
|  | #	@(#)hanoi.sed	8.1 (Berkeley) 6/6/93 | ||||||
|  | # $FreeBSD$ | ||||||
|  | # | ||||||
|  | # | ||||||
|  | # Ex: | ||||||
|  | # Run "sed -f hanoi.sed", and enter: | ||||||
|  | # | ||||||
|  | #	:abcd: : :<CR> | ||||||
|  | # | ||||||
|  | # note -- TWO carriage returns were once required, this will output the | ||||||
|  | # sequence of states involved in moving 4 rings, the largest called "a" and | ||||||
|  | # the smallest called "d", from the first to the second of three towers, so | ||||||
|  | # that the rings on any tower at any time are in descending order of size. | ||||||
|  | # You can start with a different arrangement and a different number of rings, | ||||||
|  | # say :ce:b:ax: and it will give the shortest procedure for moving them all | ||||||
|  | # to the middle tower.  The rules are: the names of the rings must all be | ||||||
|  | # lower-case letters, they must be input within 3 fields (representing the | ||||||
|  | # towers) and delimited by 4 colons, such that the letters within each field | ||||||
|  | # are in alphabetical order (i.e. rings are in descending order of size). | ||||||
|  | # | ||||||
|  | # For the benefit of anyone who wants to figure out the script, an "internal" | ||||||
|  | # line of the form | ||||||
|  | #		b:0abx:1a2b3 :2   :3x2 | ||||||
|  | # has the following meaning: the material after the three markers :1, :2, | ||||||
|  | # and :3 represents the three towers; in this case the current set-up is | ||||||
|  | # ":ab :   :x  :".  The numbers after a, b and x in these fields indicate | ||||||
|  | # that the next time it gets a chance, it will move a to tower 2, move b | ||||||
|  | # to tower 3, and move x to tower 2.  The string after :0 just keeps track | ||||||
|  | # of the alphabetical order of the names of the rings.  The b at the | ||||||
|  | # beginning means that it is now dealing with ring b (either about to move | ||||||
|  | # it, or re-evaluating where it should next be moved to). | ||||||
|  | # | ||||||
|  | # Although this version is "limited" to 26 rings because of the size of the | ||||||
|  | # alphabet, one could write a script using the same idea in which the rings | ||||||
|  | # were represented by arbitrary [strings][within][brackets], and in place of | ||||||
|  | # the built-in line of the script giving the order of the letters of the | ||||||
|  | # alphabet, it would accept from the user a line giving the ordering to be | ||||||
|  | # assumed, e.g. [ucbvax][decvax][hplabs][foo][bar]. | ||||||
|  | # | ||||||
|  | #			George Bergman | ||||||
|  | #			Math, UC Berkeley 94720 USA | ||||||
|  |  | ||||||
|  | # cleaning, diagnostics | ||||||
|  | s/  *//g | ||||||
|  | /^$/d | ||||||
|  | /[^a-z:]/{a\ | ||||||
|  | Illegal characters: use only a-z and ":".  Try again. | ||||||
|  | d | ||||||
|  | } | ||||||
|  | /^:[a-z]*:[a-z]*:[a-z]*:$/!{a\ | ||||||
|  | Incorrect format: use\ | ||||||
|  | \	: string1 : string2 : string3 :<CR>\ | ||||||
|  | Try again. | ||||||
|  | d | ||||||
|  | } | ||||||
|  | /\([a-z]\).*\1/{a\ | ||||||
|  | Repeated letters not allowed.  Try again. | ||||||
|  | d | ||||||
|  | } | ||||||
|  | # initial formatting | ||||||
|  | h | ||||||
|  | s/[a-z]/ /g | ||||||
|  | G | ||||||
|  | s/^:\( *\):\( *\):\( *\):\n:\([a-z]*\):\([a-z]*\):\([a-z]*\):$/:1\4\2\3:2\5\1\3:3\6\1\2:0/ | ||||||
|  | s/[a-z]/&2/g | ||||||
|  | s/^/abcdefghijklmnopqrstuvwxyz/ | ||||||
|  | :a | ||||||
|  | s/^\(.\).*\1.*/&\1/ | ||||||
|  | s/.// | ||||||
|  | /^[^:]/ba | ||||||
|  | s/\([^0]*\)\(:0.*\)/\2\1:/ | ||||||
|  | s/^[^0]*0\(.\)/\1&/ | ||||||
|  | :b | ||||||
|  | # outputting current state without markers | ||||||
|  | h | ||||||
|  | s/.*:1/:/ | ||||||
|  | s/[123]//gp | ||||||
|  | g | ||||||
|  | :c | ||||||
|  | # establishing destinations | ||||||
|  | /^\(.\).*\1:1/td | ||||||
|  | /^\(.\).*:1[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/ | ||||||
|  | /^\(.\).*:1[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/ | ||||||
|  | /^\(.\).*:1[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/ | ||||||
|  | /^\(.\).*:2[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/ | ||||||
|  | /^\(.\).*:2[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/ | ||||||
|  | /^\(.\).*:2[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/ | ||||||
|  | /^\(.\).*:3[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/ | ||||||
|  | /^\(.\).*:3[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/ | ||||||
|  | /^\(.\).*:3[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/ | ||||||
|  | bc | ||||||
|  | # iterate back to find smallest out-of-place ring | ||||||
|  | :d | ||||||
|  | s/^\(.\)\(:0[^:]*\([^:]\)\1.*:\([123]\)[^:]*\1\)\4/\3\2\4/ | ||||||
|  | td | ||||||
|  | # move said ring (right, resp. left) | ||||||
|  | s/^\(.\)\(.*\)\1\([23]\)\(.*:\3[^ ]*\) /\1\2 \4\1\3/ | ||||||
|  | s/^\(.\)\(.*:\([12]\)[^ ]*\) \(.*\)\1\3/\1\2\1\3\4 / | ||||||
|  | tb | ||||||
|  | s/.*/Done!  Try another, or end with ^D./p | ||||||
|  | d | ||||||
							
								
								
									
										9
									
								
								test/fixtures/Perl 6/chromosome.pl
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								test/fixtures/Perl 6/chromosome.pl
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | class Chromosome { | ||||||
|  |   has Seq $.chromosome is rw; | ||||||
|  |   has $.fitness is rw; | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | my $len = 32; | ||||||
|  | my $this-chromosome = Chromosome.new( chromosome => map( { rand >= 0.5 ?? True !! False }, 1..$len )  ); | ||||||
|  | say $this-chromosome.chromosome(); | ||||||
							
								
								
									
										1
									
								
								vendor/README.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/README.md
									
									
									
									
										vendored
									
									
								
							| @@ -329,6 +329,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting | |||||||
| - **Scheme:** [textmate/scheme.tmbundle](https://github.com/textmate/scheme.tmbundle) | - **Scheme:** [textmate/scheme.tmbundle](https://github.com/textmate/scheme.tmbundle) | ||||||
| - **Scilab:** [textmate/scilab.tmbundle](https://github.com/textmate/scilab.tmbundle) | - **Scilab:** [textmate/scilab.tmbundle](https://github.com/textmate/scilab.tmbundle) | ||||||
| - **SCSS:** [MarioRicalde/SCSS.tmbundle](https://github.com/MarioRicalde/SCSS.tmbundle) | - **SCSS:** [MarioRicalde/SCSS.tmbundle](https://github.com/MarioRicalde/SCSS.tmbundle) | ||||||
|  | - **sed:** [Alhadis/language-sed](https://github.com/Alhadis/language-sed) | ||||||
| - **ShaderLab:** [tgjones/shaders-tmLanguage](https://github.com/tgjones/shaders-tmLanguage) | - **ShaderLab:** [tgjones/shaders-tmLanguage](https://github.com/tgjones/shaders-tmLanguage) | ||||||
| - **Shell:** [atom/language-shellscript](https://github.com/atom/language-shellscript) | - **Shell:** [atom/language-shellscript](https://github.com/atom/language-shellscript) | ||||||
| - **ShellSession:** [atom/language-shellscript](https://github.com/atom/language-shellscript) | - **ShellSession:** [atom/language-shellscript](https://github.com/atom/language-shellscript) | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								vendor/grammars/language-sed
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/grammars/language-sed
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/grammars/language-sed added at f651f8bb9c
									
								
							
							
								
								
									
										18
									
								
								vendor/licenses/grammar/language-sed.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								vendor/licenses/grammar/language-sed.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | |||||||
|  | --- | ||||||
|  | type: grammar | ||||||
|  | name: language-sed | ||||||
|  | license: isc | ||||||
|  | --- | ||||||
|  | Copyright (c) 2018, John Gardner | ||||||
|  |  | ||||||
|  | Permission to use, copy, modify, and/or distribute this software for any | ||||||
|  | purpose with or without fee is hereby granted, provided that the above | ||||||
|  | copyright notice and this permission notice appear in all copies. | ||||||
|  |  | ||||||
|  | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||||
|  | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||||
|  | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||||
|  | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||||
|  | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||||
|  | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||||
|  | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||||
		Reference in New Issue
	
	Block a user