Compare commits

...

917 Commits

Author SHA1 Message Date
Arfon Smith
b8f3078966 Bumping version to v4.3.1 2015-02-04 08:31:36 -06:00
Arfon Smith
d496aaae55 Grammar update 2015-02-04 08:28:55 -06:00
Brandon Keepers
87e60cfd78 Merge pull request #2063 from larsbrinkhoff/modeline
'Text' shouldn't qualify as a valid modeline language.
2015-02-04 09:18:38 -05:00
Lars Brinkhoff
2077fa3837 'Text' doesn't qualify as a valid modeline language. 2015-02-04 08:20:19 +01:00
Arfon Smith
95bedf0bfc Merge pull request #2072 from larsbrinkhoff/4TH
Add .4TH Forth extension.
2015-02-03 19:49:46 -06:00
Lars Brinkhoff
3a1b17f1f9 Add .4TH Forth extension. 2015-02-03 13:04:06 +01:00
Arfon Smith
bdec1ac64d Merge pull request #2064 from pchaigno/new-grammars
Grammars for 8 languages
2015-02-01 14:09:42 -08:00
Paul Chaignon
36a0d760e9 Grammar for J from Sublime Text package 2015-02-01 21:52:24 +01:00
Paul Chaignon
a901e85c3c Sample for J 2015-02-01 21:50:34 +01:00
Paul Chaignon
6e9dc2339d Grammar for Golo from Sublime Text package 2015-02-01 21:41:22 +01:00
Paul Chaignon
3864e712ef Grammar for GDScript from Sublime Text package 2015-02-01 21:37:07 +01:00
Paul Chaignon
8376f1e4a4 Grammar for Creole from Sublime Text package 2015-02-01 21:34:10 +01:00
Paul Chaignon
1b0fd752d3 Grammar for CLIPS from Sublime Text package 2015-02-01 21:29:03 +01:00
Paul Chaignon
bef473a48b Samples for CLIPS 2015-02-01 21:27:14 +01:00
Paul Chaignon
0c60078d27 Grammar for APL from Sublime Text package 2015-02-01 21:16:45 +01:00
Arfon Smith
2f65462ce0 Trailing slash fix. 2015-02-01 11:39:59 -08:00
Arfon Smith
ace6156c65 Merge pull request #2058 from pchaigno/move-autohotkey-grammar
Update URL for AutoHotkey grammar
2015-02-01 11:24:54 -08:00
Paul Chaignon
ada8feba34 Merge branch 'master' into move-autohotkey-grammar 2015-02-01 20:12:22 +01:00
Arfon Smith
75d685a7f4 Merge pull request #2000 from jayphelps/patch-2
Added `htmlbars` as an alias for Handlebars
2015-02-01 11:03:13 -08:00
Arfon Smith
6b7f20323b Merge pull request #2057 from steinwaywhw/master
Adding ATS language support by converting existing SublimeText syntax def
2015-01-31 19:03:05 -06:00
Steinway Wu
c2ab5bc09d Merge remote-tracking branch 'upstream/master'
Conflicts:
	.gitmodules
2015-01-31 17:24:23 -05:00
Arfon Smith
95d5b8bdbc Merge pull request #2059 from pchaigno/modelica
Support of Modelica language
2015-01-31 15:17:38 -06:00
Steinway Wu
da7b3182e8 update to newer ats-mode-sublime 2015-01-31 16:00:00 -05:00
Paul Chaignon
08790f2f0a Grammar for Modelica 2015-01-31 13:44:11 +01:00
Paul Chaignon
896270e617 Support for Modelica 2015-01-31 13:37:42 +01:00
Paul Chaignon
fb40ee986f Update URL for AutoHotkey grammar 2015-01-31 12:16:41 +01:00
Paul Chaignon
20b82e4bc9 Remove grammar for AutoHotkey 2015-01-31 12:14:36 +01:00
Steinway Wu
513347911e update ats grammar to the latest commits 2015-01-30 13:25:22 -05:00
Arfon Smith
1a3960e95d Merge pull request #2056 from github/cut-release-v4.3.0
Cut release v4.3.0
2015-01-30 12:15:55 -06:00
Steinway Wu
7d9a47b7c3 remove atxt support 2015-01-30 13:02:37 -05:00
Steinway Wu
c80d085e33 revise git module 2015-01-30 12:56:17 -05:00
Steinway Wu
98518e5c8c add ats mode from sublime package 2015-01-30 12:52:38 -05:00
Arfon Smith
2b7a488d64 Bumping version to 4.3.0 2015-01-30 11:25:50 -06:00
Arfon Smith
25aa6669be Updating grammars 2015-01-30 11:17:13 -06:00
Arfon Smith
ef9e1c4e4f Merge pull request #2055 from github/cp-cpp
Adding cp as a C++ extension
2015-01-30 11:04:21 -06:00
Arfon Smith
cf483c28e3 Adding cp as a C++ extension 2015-01-30 10:56:06 -06:00
Arfon Smith
fecc39d97d Merge pull request #1652 from github/objc-mercury
Disambiguate Matlab, Objective-C, Mathematica, M, and Mercury
2015-01-30 08:51:51 -06:00
Arfon Smith
339370a703 Extracting ObjectiveC regex into a constant 2015-01-30 08:48:26 -06:00
Arfon Smith
359e5157a8 Merge branch 'master' into objc-mercury 2015-01-30 08:34:50 -06:00
Arfon Smith
207bd8d77c Merge pull request #2001 from rusthon/master
added Rusthon to languages list for syntax highlighting in md.
2015-01-30 08:28:27 -06:00
Arfon Smith
ba5454808e Merge pull request #1916 from Mailaender/dot-desktop-files
Added support for Linux .desktop and .emacs.desktop files
2015-01-30 08:24:27 -06:00
Arfon Smith
9196ba91bb Merge pull request #2041 from github/emacs-vim-mode-lines
Emacs vim modelines
2015-01-29 20:12:47 -06:00
Arfon Smith
5ff1b02e49 1.9.3 reprieve 2015-01-29 20:03:18 -06:00
Brandon Keepers
4f92d620eb Simplify detect 2015-01-29 16:28:54 -06:00
Brandon Keepers
e7f5779659 Break modelines into two regular expressions
This makes them easier to read and maintains Ruby 1.9 compatibility
2015-01-29 16:28:54 -06:00
Arfon Smith
512cfc4858 Dropping 1.9.3 2015-01-29 15:45:07 -06:00
Brandon Keepers
437ba70b9e Find modeline anywhere in the data 2015-01-29 13:14:06 -06:00
Brandon Keepers
fadca563bc Move regex to a constant 2015-01-29 13:09:12 -06:00
Brandon Keepers
7a601b196e Fix regex syntax 2015-01-29 13:07:18 -06:00
Arfon Smith
bf6bd246fd Syntax tweak 2015-01-28 16:52:26 -06:00
Arfon Smith
168ff4c050 Merge pull request #2048 from infininight/master
Update Swift grammar
2015-01-28 07:02:49 -06:00
Arfon Smith
d6fdbafa3c Merge pull request #2047 from vors/powershell
Replace vendor powershell.tmBundle by SublimeText powershell
2015-01-28 07:00:18 -06:00
Michael Sheets
3e1570a716 Update Swift grammar 2015-01-28 04:12:05 -06:00
Sergei Vorobev
160c0b4ac0 Replace vendor powershell.tmBundle by SublimeText powershell. Improve samples for PS. 2015-01-27 18:31:17 -08:00
Arfon Smith
cf0bc3914f Merge pull request #2044 from pchaigno/liquid-grammar
Grammar for Liquid
2015-01-27 09:45:24 -06:00
Arfon Smith
96154627d3 Clearer regex 2015-01-27 09:42:24 -06:00
Arfon Smith
6f07b62a3f New year. 2015-01-27 08:18:34 -06:00
Paul Chaignon
cae17b91b8 Grammar (TextMate bundle) for Liquid 2015-01-27 13:02:13 +01:00
Arfon Smith
69b68f3a44 Extracting common methods into helper. 2015-01-26 16:22:55 -06:00
Arfon Smith
20a3e7e4b8 Update docs 2015-01-26 16:12:20 -06:00
Arfon Smith
119a8fff1e Emacs modeline fixtures 2015-01-26 15:38:19 -06:00
Arfon Smith
8094b1bd92 Test strategy and language 2015-01-26 15:38:07 -06:00
Arfon Smith
98fc4d78aa Slightly reworked regex. 2015-01-26 15:37:45 -06:00
Arfon Smith
d773c2e90d Escape the * 2015-01-26 15:18:40 -06:00
Arfon Smith
7929e7ab9c Adding Emacs modes 2015-01-26 15:11:55 -06:00
Arfon Smith
e8e95f113c Modeline should come first (as it's an override) 2015-01-26 15:03:22 -06:00
Arfon Smith
429c791377 Testing Vim modeline support 2015-01-26 14:39:07 -06:00
Arfon Smith
e536eea5b6 Basic Vim modeline detection strategy 2015-01-26 14:22:09 -06:00
Adam Roben
0a5b5eadeb Merge pull request #1986 from pchaigno/remove-lexer
Remove last mentions of lexer
2015-01-26 10:28:11 -05:00
Arfon Smith
12351d3a8a Merge pull request #2037 from pchaigno/asp-tm_scope
Change TextMate scope for ASP
2015-01-25 19:24:15 -06:00
Paul Chaignon
7421b2e553 Change TextMate scope for ASP 2015-01-25 19:04:00 +01:00
Arfon Smith
8aa4dce6f4 Merge pull request #1723 from techhat/pythonmultiline
Python also supports triple single-quotes for comments
2015-01-24 10:54:30 -06:00
Joseph Hall
feeceefe99 Merge pull request #1 from pchaigno/pythonmultiline
Multiline comments for Python during tokenization
2015-01-24 09:00:00 -07:00
Arfon Smith
60483e3216 Merge pull request #1143 from pchaigno/newlisp
NewLisp language added with some heuristics
2015-01-24 08:58:07 -06:00
Arfon Smith
49837e0c20 Merge pull request #2031 from pchaigno/fix-pascal-samples
Better samples for Pascal
2015-01-24 08:51:26 -06:00
Paul Chaignon
c7668ad882 Better samples for Pascal 2015-01-24 01:32:56 +01:00
Paul Chaignon
4f37563be1 Remove mention of lexer for GAP in languages.yml 2015-01-24 01:02:58 +01:00
Paul Chaignon
9c3ab95048 Merge branch 'master' into remove-lexer 2015-01-24 00:57:20 +01:00
Paul Chaignon
bf5651e127 Merge branch 'master' into newlisp 2015-01-24 00:15:52 +01:00
Arfon Smith
f854a12043 Merge pull request #2025 from hyperair/scad
Specify ace_mode for OpenSCAD
2015-01-23 15:29:57 -06:00
Arfon Smith
dd09f02f53 Adding some samples to verify new heuristics 2015-01-23 15:25:36 -06:00
Arfon Smith
268f43d668 Merge pull request #2030 from github/tst
GAP and Scilab
2015-01-23 14:50:31 -06:00
Arfon Smith
d95b7504ab Merge branch 'master' into tst
Conflicts:
	lib/linguist/heuristics.rb
	lib/linguist/language.rb
	lib/linguist/languages.yml
2015-01-23 14:35:27 -06:00
Arfon Smith
4d2b6ee99e Updating heuristic order 2015-01-23 13:22:45 -06:00
Arfon Smith
6ad6984fe7 Merge branch 'master' into mmmmmm
Conflicts:
	lib/linguist/heuristics.rb
2015-01-23 11:02:25 -06:00
Chow Loong Jin
97d48a204a Specify ace_mode for OpenSCAD 2015-01-23 14:14:15 +08:00
Arfon Smith
cc56ddb354 Merge pull request #2015 from github/cut-release-v4.2.7
Cut release v4.2.7
2015-01-20 10:40:38 -06:00
Arfon Smith
3ce527b0b9 Updating version.rb 2015-01-20 09:29:26 -06:00
Arfon Smith
94d4d92cc0 Merge branch 'master' into cut-release-v4.2.7 2015-01-20 09:22:55 -06:00
Arfon Smith
72b268b253 Updating grammars 2015-01-20 09:17:46 -06:00
Arfon Smith
2c7885bbc1 Merge pull request #2014 from github/revert-1976-path-for-fileblob
Revert "Use path for Generated?"
2015-01-20 09:12:33 -06:00
Arfon Smith
36120a9122 Revert "Use path for Generated?" 2015-01-20 08:58:11 -06:00
Arfon Smith
6305ec3f31 Merge pull request #2005 from JJ/master
Adds Rexfile
2015-01-18 08:44:00 -06:00
Juan Julián Merelo Guervós
b319731a2d Adds Rexfile
That's a Vagrantfile-like file for the Rex provisioning tool.
2015-01-18 13:16:33 +01:00
Arfon Smith
885740dad6 Merge pull request #1944 from pchaigno/revert-1438
Revert #1438: add file extensions with multiple segments
2015-01-17 16:12:56 -06:00
hartsantler
b178268cbc changed to make rusthon a python alias.
https://github.com/github/linguist/pull/2001
2015-01-17 13:34:12 -08:00
Arfon Smith
3ae556893f Merge pull request #1900 from dalehenrich/master
Use source.smalltalk to hightlight STON file
2015-01-17 09:15:57 -06:00
Arfon Smith
43b297636d Merge pull request #2003 from pchaigno/cs-heuristics
Heuristics for .cs files: C# and Smalltalk
2015-01-17 09:10:58 -06:00
Paul Chaignon
8cd17698fe Slightly improve heuristic for C# 2015-01-17 13:34:06 +01:00
hartsantler
7abcc39c8c added Rusthon to languages list for syntax highlighting in md. 2015-01-16 04:32:52 -08:00
Jay Phelps
a5b915d571 Added htmlbars as an alias for Handlebars
See tildeio/htmlbars
2015-01-15 22:13:06 -08:00
Arfon Smith
0fcdca653a Merge pull request #1995 from phuicy/master
Support for web ontology language (OWL)
2015-01-15 20:26:19 -06:00
Adam Roben
9ec801d495 Merge pull request #1976 from github/path-for-fileblob
Use path for Generated?
2015-01-15 21:20:00 -05:00
Arfon Smith
4ccbdcb93c Merge pull request #1999 from github/more-relative-paths
More relative paths
2015-01-15 16:41:36 -06:00
Arfon Smith
53f909f2a1 Merge pull request #1998 from Frigolit/master
Added interpreter "pike" for Pike.
2015-01-15 16:07:22 -06:00
Pontus Rodling
f8603705a8 Added shebang sample for Pike. 2015-01-16 09:56:13 +13:00
Pontus Rodling
3bc1b97a68 Added interpreter "pike" for Pike. 2015-01-16 09:18:55 +13:00
Arfon Smith
27ed17e62e Merge pull request #1996 from aoetk/fxml
Add FXML to languages.yml
2015-01-15 09:30:02 -06:00
Arfon Smith
f3d5090d51 Merge pull request #1841 from danmichaelo/turtle
Add support for Turtle and SPARQL
2015-01-15 09:28:26 -06:00
AOE Takashi
d030f9be99 Add support for FXML files. 2015-01-15 17:42:47 +09:00
Dan Michael O. Heggø
774d18ed8f Add support for Turtle and SPARQL 2015-01-14 23:45:25 +01:00
Guy Burroughes
d39f5eedf1 Fixed issues for web ontology to pass tests 2015-01-14 19:18:25 +00:00
phuicy
1a1e21f344 Added Web Ontology Language Support
As syntax is only xml, it is a very simple fix.
2015-01-14 18:11:33 +00:00
Adam Roben
96c7bc30d8 Simplify blob tests
Now that FileBlobs with relative paths can still access their files on
disk, we can use relative paths for all FileBlobs in the test. This more
closely matches the behavior in github.com's codebase, where all blobs
use relative paths.
2015-01-14 08:57:53 -05:00
Adam Roben
0328b1cb3c Use the original FileBlob path for filesystem access
FileBlob now remembers the full path that was passed to its constructor,
and uses that for performing filesystem access. FileBlob#path continues
to return a relative path as before. This ensures that you can call
methods like #size and #mode on FileBlobs with relative paths,
regardless of the current working directory.
2015-01-14 08:54:49 -05:00
Arfon Smith
ad0cc7f39d Merge pull request #1989 from davidabian/patch-1
Update languages.yml with *.sagews
2015-01-12 08:12:45 -06:00
David Abián
42a491ab8b Merge branch 'patch-1' of https://github.com/davidabian/linguist into patch-1 2015-01-11 22:09:48 +01:00
David Abián
ef4b25591b Sample sagews file, as requested 2015-01-11 22:08:56 +01:00
David Abián
fbc99cf7e6 Update languages.yml with *.sagews 2015-01-11 19:43:20 +01:00
Paul Chaignon
5d0e9484ce Remove last mentions of lexer 2015-01-11 10:02:52 +01:00
Brandon Keepers
1bc6a6dfe5 Merge pull request #1955 from pchaigno/zephir-generated-samples
Reclassify three samples files generated from Zephir code
2015-01-10 10:43:00 -08:00
Arfon Smith
30be3265fb Merge pull request #1982 from pchaigno/racket-grammar
New grammar for Racket
2015-01-10 09:18:45 -06:00
Paul Chaignon
ecaad7979f New grammar for Racket 2015-01-10 14:40:58 +01:00
Paul Chaignon
d638edbeae Remove grammar for Racket 2015-01-10 13:10:04 +01:00
Brandon Keepers
91779b6de9 Merge pull request #1978 from larsbrinkhoff/cmake_samples
More CMake samples
2015-01-09 15:53:25 -08:00
Adam Roben
3abb0e80d5 Merge pull request #1963 from github/aroben-patch-1
Recommend updating grammars when releasing
2015-01-09 16:20:30 -05:00
Arfon Smith
f4c1cc576b Modifying BlobHelper and FileBlob to use path 2015-01-09 15:15:34 -06:00
Paul Chaignon
986235dce7 Sample file for .cmake.in 2015-01-09 20:02:01 +01:00
Lars Brinkhoff
1f0c88a934 Restore the .cmake.in extension. 2015-01-09 20:02:01 +01:00
Lars Brinkhoff
94f7dd2238 More CMake samples. 2015-01-09 20:02:01 +01:00
Arfon Smith
79fd12eb75 Merge branch 'master' into path-for-fileblob 2015-01-09 11:56:11 -06:00
Arfon Smith
05a98be1e5 Merge pull request #1977 from github/auto
Auto
2015-01-09 11:50:01 -06:00
Arfon Smith
24eb1d3fe2 Updating file regex to support unlicense.txt 2015-01-09 11:43:34 -06:00
Brandon Keepers
75d1bcdc69 Merge pull request #1912 from 0a-/master
vendor.yml: improved & added more regex for auto-generated stylesheets
2015-01-09 08:09:57 -08:00
Arfon Smith
7549eff9c1 Merge branch 'master' into auto
Conflicts:
	.gitmodules
2015-01-08 17:00:45 -06:00
Arfon Smith
6e2b4f7514 Updating ref to include license 2015-01-08 16:59:43 -06:00
Arfon Smith
846cff5721 Remove pry 2015-01-08 15:10:05 -06:00
Arfon Smith
efd25ec4d2 Start using path with LazyBlob 2015-01-08 15:08:28 -06:00
Arfon Smith
5c94b50386 Merge pull request #1975 from github/http
Http
2015-01-08 14:19:38 -06:00
Arfon Smith
c0fbc9ef8c Updating Sublime-HTTP reference 2015-01-08 14:11:04 -06:00
Arfon Smith
1f429fb488 Whitespace 2015-01-08 14:06:00 -06:00
Arfon Smith
ec28ea299f Use path for Generated? 2015-01-08 14:03:35 -06:00
Arfon Smith
08558aa118 Merge branch 'master' into http
Conflicts:
	.gitmodules
2015-01-08 13:13:07 -06:00
Adam Roben
7e319b797f Merge pull request #1970 from larsbrinkhoff/fr
Add missing ^ in regexp for Frege heuristic
2015-01-08 13:43:14 -05:00
Lars Brinkhoff
3957a11f25 Add to sample to show that a false positive goes away. 2015-01-08 19:35:02 +01:00
Adam Roben
743922d45a Merge pull request #1974 from github/hy-grammar
Update Hy support by adding a reference to an Atom grammar.
2015-01-08 11:13:59 -05:00
Bob Tolbert
5f70776cf3 Update Hy support by adding a reference to an Atom grammar. 2015-01-08 11:09:28 -05:00
Adam Roben
289f91997c Merge pull request #1973 from github/nit-grammar
Add a language grammar for Nit
2015-01-08 11:01:05 -05:00
Lucas Bajolet
163ea9ecdd Added a few samples for the Nit language
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
2015-01-08 10:52:45 -05:00
Lucas Bajolet
9be941acc8 Added support for the nit language in grammars.yml, updated languages.yml for .nit source files highlighting
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
2015-01-08 10:51:51 -05:00
Adam Roben
e95314f072 Recognize WTFPL-licensed grammars 2015-01-08 10:49:54 -05:00
Adam Roben
6fef6b578a Fix script/convert-grammars --add 2015-01-08 10:49:01 -05:00
Adam Roben
dd59814563 Merge pull request #1905 from joaquincasares/cql_support
Add support for cql and ddl files
2015-01-08 10:45:15 -05:00
Adam Roben
b704b20695 Merge pull request #1888 from MattDMo/master
reorganized Sublime Text extensions, added some
2015-01-08 10:42:56 -05:00
Lars Brinkhoff
71885b8a79 Add missing ^ in Frege heuristic regexp. 2015-01-08 13:02:04 +01:00
Adam Roben
59a6963a89 Say that you should commit the submodule update 2015-01-07 14:26:23 -05:00
Adam Roben
6e9dfdff30 Recommend updating grammars when releasing
This will help ensure we keep pulling in fixes from the grammar repos.
2015-01-07 14:16:23 -05:00
Adam Roben
470419d732 Merge pull request #1962 from github/bump-4.2.6
Bump to v4.2.6
2015-01-07 10:57:29 -05:00
Adam Roben
5b05653881 Bump to v4.2.6 2015-01-07 10:30:51 -05:00
Adam Roben
899dc07883 Merge pull request #1938 from floscher/carto-grammar
Add grammar for CartoCSS
2015-01-07 09:31:34 -05:00
Florian M. Schäfer
83dfd408e9 Update carto-grammar to current version (2ec5a89) 2015-01-07 15:27:40 +01:00
Florian M. Schäfer
417171cfe1 Don't pass JSON-files through csonc 2015-01-07 15:27:40 +01:00
Florian Schäfer
e8e82a1ca3 Add grammar for CartoCSS 2015-01-07 15:27:40 +01:00
Florian Schäfer
6843aa7cc8 Enable file extension .json for grammar files 2015-01-07 15:27:40 +01:00
Adam Roben
952acc983d Merge pull request #1958 from floscher/fix-convert-script
Fixes script/convert-grammars: require thread-gem and solve problem with visibility of variable p
2015-01-07 08:58:34 -05:00
Adam Roben
650f267be7 Merge pull request #1959 from floscher/licence
Allow British-English spelled LICENCE-files
2015-01-07 08:56:20 -05:00
Florian M. Schäfer
3ace4c57f7 Allow British-English LICENCE-files 2015-01-06 22:51:08 +01:00
Florian M. Schäfer
ab1b603c78 Require thread-gem and solve problem with visibility of variable p in convert-grammars
* The `thread`-gem is required for the script, because otherwise Ruby throws an error that `Queue` in line 259 is an uninitialized constant
* The variable `p` was previously in the same method with the status message saying `OK ‹path› ‹converted scopes›`. But `p` is now defined in load_grammars() and thus not visible when showing the OK-message in install_grammars(). This was solved by adding a path-parameter to install_grammars().
2015-01-06 22:06:55 +01:00
Adam Roben
8430f694e5 Merge pull request #1954 from github/test-grammar-licenses
Test that all grammar submodules have an appropriate license
2015-01-06 13:59:52 -05:00
Adam Roben
71f0cafc78 Update all submodules
This was done via `git submodule update --remote`.

Since Scalate.tmbundle now has a license we can remove it from the
whitelist.

* vendor/grammars/NimLime 9cef4b6...a7067c6 (1):
  > Added 'nim' to tmpl sublimetext highlighting

* vendor/grammars/Scalate.tmbundle 4f85314...0307535 (1):
  > Merge pull request #3 from aroben/patch-1

* vendor/grammars/fsharpbinding d097476...99d2e9a (2):
  > Merge pull request #917 from 7sharp9/CleanMacProjects
  > Merge pull request #916 from 7sharp9/ToolTipsLessBlocky

* vendor/grammars/language-clojure d649d9f...bae6eee (2):
  > Prepare 0.10.0 release
  > Rename scoped-properties/ to settings/

* vendor/grammars/language-coffee-script c6e8d33...d86c896 (2):
  > Prepare 0.39.0 release
  > Rename scoped-properties/ to settings/

* vendor/grammars/language-gfm 7b62290...6af44a0 (2):
  > Remove unneeded newline
  > Merge pull request #65 from braver/line-break

* vendor/grammars/language-javascript 6690feb...5157519 (2):
  > Prepare 0.53.0 release
  > Rename scoped-properties/ to settings/

* vendor/grammars/language-python f518e49...46072e3 (2):
  > Prepare 0.29.0 release
  > Rename scoped-properties/ to settings/

* vendor/grammars/language-shellscript cbec163...9839719 (2):
  > Prepare 0.12.0 release
  > Rename scoped-properties/ to settings/

* vendor/grammars/language-yaml eddd079...ce8b441 (2):
  > Prepare 0.22.0 release
  > Rename scoped-properties/ to settings/
2015-01-06 13:46:04 -05:00
Adam Roben
4614287a55 Test that all grammar submodules have an appropriate license
We require all grammars to have a license that permits redistribution. A
few existing grammars have been grandfathered in without a license (and
we're working to remedy that), but no new grammars should be added
without a license.
2015-01-06 13:44:11 -05:00
Adam Roben
f477f811df Extract TestGrammars#submodule_paths method 2015-01-06 13:43:50 -05:00
Adam Roben
95bb5a1ae4 Switch to the master branch of tenbits/sublime-mask
The master branch contains a license while the release branch does not.
Other than that they're nearly identical.
2015-01-06 13:43:37 -05:00
Adam Roben
70699037ae Merge pull request #1909 from github/scopes-test
Test that grammars.yml lists the right scopes for each submodule
2015-01-06 13:41:44 -05:00
Adam Roben
7edddec920 Make convert-grammars a little quieter
No need to say "Done" at the end. We're obviously done; the script is
exiting.
2015-01-06 13:39:18 -05:00
Adam Roben
8f3779c94c Update grammars.yml to match submodules
I should have done this in 2c2c4740a8.
2015-01-06 13:36:51 -05:00
Adam Roben
917bc48348 Use File.directory? to test for local directories
Some of our submodules end in ".tmLanguage", which we used to think
meant it was a file rather than a directory.
2015-01-06 13:31:26 -05:00
Adam Roben
581dc36c47 Ruby 1.9 compatibility for convert-grammars 2015-01-06 13:28:26 -05:00
Adam Roben
a4286ba950 Show stderr output when running convert-grammars
This will let us see why it's failing.
2015-01-06 13:28:26 -05:00
Adam Roben
5fa85f268f Ruby 1.9 compatibility 2015-01-06 13:28:26 -05:00
Adam Roben
ada6f6882a Test that grammars.yml lists the right scopes for each submodule
convert-grammars now supports a few flags that we can use to make it
dump out the YAML just for the local grammar submodules. We can then
compare this to the YAML that's actually in grammars.yml to check that
they're the same. If they aren't, grammars.yml needs to be updated.
This will help catch mistakes like using the wrong scope name.
2015-01-06 13:28:25 -05:00
Adam Roben
78a0030d46 download-grammars -> convert-grammars
Downloading is only a small part of what this script does. The main
thing it does is convert grammars to JSON.
2015-01-06 13:28:25 -05:00
Adam Roben
e2d6aecd81 Merge pull request #1956 from github/new-sass-grammar
Switch Sass grammar to nathos/sass-textmate-bundle
2015-01-06 13:26:09 -05:00
Patrik Affentranger
a2e99e8ddb Switch Sass grammar to nathos/sass-textmate-bundle
This provides better highlighting in many cases than the previous
grammar. See https://github.com/github/linguist/pull/1852.
2015-01-06 13:18:30 -05:00
Adam Roben
b499a074cf Merge pull request #1931 from github/travis-container
Opt in to container-based Travis CI builds
2015-01-06 13:02:53 -05:00
Adam Roben
188e579df7 Use a single git fetch invocation in CI 2015-01-06 12:56:08 -05:00
Adam Roben
d82e4801ff Use --with-icu-dir everywhere but Ruby 2.0
--with-icu-dir is broken on Ruby 2.0 due to
https://bugs.ruby-lang.org/issues/8074. Specifying
--with-icu-include/--with-icu-lib is broken on Ruby 2.1 and newer due to
https://github.com/bundler/bundler/pull/3338. So now we use
--with-icu-dir everywhere but Ruby 2.0.
2015-01-06 12:44:39 -05:00
Adam Roben
d258d146b8 Move before_install steps to a separate script 2015-01-06 12:44:14 -05:00
Paul Chaignon
96e6b3f53e Reclassify samples generated from Zephir code 2015-01-06 17:00:16 +01:00
Adam Roben
ae6b0f0d40 Merge pull request #1953 from github/update-grammars
Update all grammar submodules
2015-01-06 10:18:52 -05:00
Adam Roben
2c2c4740a8 Update all grammar submodules
This was performed via `git submodule update --remote`.

* vendor/grammars/Agda.tmbundle 784f435...68a218c (1):
  > Merge pull request #1 from aroben/patch-1

* vendor/grammars/IDL-Syntax 9473b7f...3baeaea (1):
  > Merge pull request #3 from aroben/patch-1

* vendor/grammars/NimLime 7a2fb4e...9cef4b6 (4):
  > Updated command names
  > Updated generated documentation
  > renamed more from nimrod to nim
  > Renamed several files

* vendor/grammars/SCSS.tmbundle d6188e5...4147502 (1):
  > Merge pull request #181 from redgluten/master

* vendor/grammars/Sublime-VimL 6ab7e19...366fdc6 (1):
  > Merge pull request #2 from yous/fix-single-quoted-string

* vendor/grammars/factor 2dc5590...2453a78 (38):
  > json.writer: make sure we make hex values two digits zero padded.
  > json.writer: support escaping unicode > 0x10000.  Thanks @jonenst!
  > mason.git: fix status check.
  > compiler.cfg.*: new unit test vocabs
  > compiler.cfg.*: more docs
  > compiler.cfg.*: refactoring away the compute-global-sets word
  > compiler.cfg.*: docs and more tests
  > compiler.cfg.stacks.local: refactoring making stack-changes and height-changes take and return stuff instead of using variables and the make building
  > compiler.cfg.parallel-copy: docs
  > compiler.cfg.stacks.height: these words are unused
  > compiler.cfg.*: more compiler docs
  > compiler.cfg.stacks.finalize: initial docs
  > io.launcher: fix stack effects.
  > io.launcher: fix docs for with-process-reader and with-process-writer.
  > io.launcher: add versions of with-process that preserve process and status.
  > mason.git: fix use.
  > mason.git: fix for rename.
  > io.launcher: cleanup public interface, make some things private or internal.
  > gopher: set 1 minute timeout by default.
  > brainfuck: cleanup tests.
  > json.writer: don't escape spaces, thats weird.
  > unix: some using cleanups.
  > python: rename startup/shutdown hooks.
  > math.extras: adding the Möbius function.
  > alien.c-types: move definitions of stdint.h from unix.types.
  > gopher: use contents now that it works.
  > io.ports: Make buffered-port not have a length because of Linux virtual files and TCP sockets. Related to issues #1256 and #1259.
  > tools.deploy.backend: add word for deleting cached staging images.
  > command-line: save the executable in a variable so that people don't use (command-line) directly if possible.
  > bootstrap: fix this use of (command-line).
  > tools.deploy.shaker: set the rest of the args to preserve current behavior.
  > vm: store full command-line including executable first argument.
  > gopher: fix bug where empty lines weren't printed properly in menus.
  > gopher: simplify.
  > gopher: change gopher-text to use split1.
  > io.encodings.detect: simplify prolog-tag.
  > gopher: add way to get result without converting to objects.
  > tools.disassembler: allow disassemble of compose and curry.

* vendor/grammars/fsharpbinding af755c8...d097476 (24):
  > Merge pull request #909 from cbowdon/issue877-vim-73-support
  > Merge pull request #913 from 7sharp9/Move_GetColourizations_toBg
  > Merge pull request #912 from 7sharp9/TryFind_opt
  > Merge pull request #911 from 7sharp9/FoldingParser
  > Merge pull request #908 from 7sharp9/TooltipOverhaul_AutoParamFix
  > Merge pull request #907 from 7sharp9/Movegetdefinestomodule
  > Merge pull request #906 from 7sharp9/tooltipfixforclosures
  > Merge pull request #905 from 7sharp9/ResolverProvider_singletimeout
  > Merge pull request #904 from fsharp/revert-903-ResolverProvider_singletimeout
  > Merge pull request #903 from 7sharp9/ResolverProvider_singletimeout
  > Merge pull request #902 from 7sharp9/ParameterCompletion_gatherTimeout
  > Merge pull request #901 from 7sharp9/Changed_invalidate_project
  > Merge pull request #900 from 7sharp9/Syntaxmode_removeextraoperation
  > Merge pull request #899 from 7sharp9/tooltips_ensureTimout
  > Merge pull request #898 from 7sharp9/pathextension_useAddRange
  > Merge pull request #897 from 7sharp9/resolverprovider_ensuretimout
  > Merge pull request #896 from 7sharp9/completion_ensuretimout
  > Merge pull request #895 from cbowdon/894-Vim-fix-for-no-completions-stacktrace
  > Merge pull request #890 from wangzq/gotodecl
  > Merge pull request #893 from 7sharp9/fixfortooltipvaltypes
  > Merge pull request #892 from 7sharp9/fixforprojecttypechecking
  > Added correct indentation
  > Merge pull request #891 from 7sharp9/ImproveImplementInterface
  > Merge pull request #888 from VincentDondain/master

* vendor/grammars/haxe-sublime-bundle 58cad47...e2613bb (4):
  > fixed goto definition / find type
  > clean
  > adaptations for toplevel completion
  > first test

* vendor/grammars/language-gfm c6df027...7b62290 (7):
  > Prepare 0.59.0 release
  > scoped-properties -> settings
  > Prepare 0.58.0 release
  > Merge pull request #67 from davidcelis/master
  > Prepare 0.57.0 release
  > Prepare 0.56.0 release
  > Merge pull request #64 from atom/mb-new-cpp-scope-name

* vendor/grammars/language-javascript 15dc5d1...6690feb (5):
  > Prepare 0.52.0 release
  > Merge pull request #82 from Hurtak/feature/snippets-for
  > Merge pull request #80 from Hurtak/feature/snippets-querySelector
  > Merge pull request #79 from Hurtak/feature/snippets-switch-indentation-fix
  > Merge pull request #81 from Hurtak/feature/snippets-iife

* vendor/grammars/language-python 476a353...f518e49 (5):
  > Prepare 0.28.0 release
  > Use trailing scope name
  > Merge pull request #48 from msabramo/patch-1
  > Prepare 0.27.0 release
  > Add pattern for nonlocal keyword

* vendor/grammars/language-sass 064a8b5...33efa33 (2):
  > Prepare 0.29.0 release
  > Allow + and - in selector argument

* vendor/grammars/language-shellscript e2d62af...cbec163 (2):
  > Prepare 0.11.0 release
  > Merge pull request #4 from hd-deman/patch-1

* vendor/grammars/latex.tmbundle 682c4b7...52b2251 (42):
  > Replaced `python` with `python2.7` in shebangs
  > Make the preferences compatible with Python 3
  > Handle manual spacing in “Reformat” (Table)
  > Fix: Reformatting of table containing empty cells
  > Use more descriptive variable names in `format`
  > Add documentation to `reformat`
  > Fix doctest in `refresh_viewer`
  > Add tests for `reformat`
  > Ignore “exit discard” status in `cramtests`
  > Remove print statements from `reformat` function
  > Fix: Close log window option ignored
  > Automatically scroll to bottom in “HTML Output”
  > Handle “\” signs in the notification window
  > Fix missing logname in default error message
  > Extend list of auxiliary files
  > Remove unused code from `latex_watch`
  > Display default message in notification window
  > Sort error messages by line number
  > Do not store duplicate error messages anymore
  > Close notification window on cleanup
  > Improve reopening of closed notification windows
  > Improve rewrap code in `texparser`
  > Improve readability of verbose log output
  > Only parse log file if there were changes
  > Remove unnecessary function call in “LaTeX Watch”
  > Properly close file in `guess_tex_engine`
  > Handle log messages containing double quotes
  > Left justify severity in notification window
  > Handle manual closing of notification window
  > Add additional information to notification window
  > Remove unused code from `texparser`
  > Close notification when typesetting succeeds
  > Add support for notifications to “LaTeX Watch”
  > Update bundle preference values instantly
  > Make “Reformat” (Table) compatible with Ruby 2
  > Ignore escaped ampersand `\&` in “Format” (Table)
  > Remove warnings reported by `RuboCop`
  > Format code for “Reformat” (Table)
  > Move code for “Reformat” into separate script
  > Save “Reformat” command with TextMate 2
  > Remove unused import
  > Use explicit import in “Itemize Lines In Selection”

* vendor/grammars/mercury-tmlanguage b5a4fd6...eaef0b0 (8):
  > Add require_* and some, all keywords
  > Highlight %f format specifiers, `` as op
  > Correct implementation of '''', """" and 0'<char>
  > README.md: Mention GitHub grammar compatability
  > README.md: add resources and demonstration
  > reformatted whitespace; added foreign mods; missing keywords
  > Highlight variables, determ decls, more pragmas
  > no highlighting of variables, function names, type names, inst's, etc.

* vendor/grammars/sublime-mask 2f59519...632ff3c (4):
  > v0.8.7
  > v0.8.7
  > + expression in component nodes
  < v0.8.6

* vendor/grammars/swift.tmbundle 81a0164...3c7eac5 (9):
  > Use constant scope for booleans
  > Use storage scope instead of keyword
  > Correct typo in include
  > Revamp string literal matching
  > Improve punctuation scopes
  > Allow for functions without a body
  > Add simple folding markers for swift
  > Improved matching of capture specifiers
  > Add Support for UInt, Int[8|16|32|64] & Float80
2015-01-06 10:09:53 -05:00
Paul Chaignon
14740e8a89 Grammar for HTTP 2015-01-06 11:57:28 +01:00
Paul Chaignon
b357257f4d Grammar for AutoHotkey 2015-01-06 09:51:51 +01:00
Adam Roben
4428e62b99 Merge pull request #1950 from github/upstream-c-bundle
Switch back to textmate/c.tmbundle
2015-01-05 15:24:42 -05:00
Adam Roben
575ad0d8a2 Switch back to textmate/c.tmbundle
We were using a fork to get the fix for
https://github.com/textmate/c.tmbundle/pull/24 before it was merged
upstream. Now it's been merged so we can go back to the upstream
repository.
2015-01-05 15:07:28 -05:00
Joaquin Casares
5ad9deb199 Added sample files 2015-01-05 13:50:54 -06:00
MattDMo
e99f6edb56 Put .sublime_* after .sublime-* 2015-01-05 13:41:58 -05:00
MattDMo
3149d1232b Moved .sublime_metrics after .sublime-mousemap due to failing Travis test 2015-01-05 13:36:57 -05:00
Paul Chaignon
3c6218f20e Heuristics for .cs files: Smalltalk and C# 2015-01-04 22:07:29 +01:00
Matthias Mailänder
68f04a50aa add support for Emacs desktop files 2015-01-03 19:22:54 +01:00
Arfon Smith
ec01672f6c Merge pull request #1866 from github/cpp-c-improvements
Better C++ regex
2015-01-03 11:23:20 -06:00
Arfon Smith
be6b1bb3ee Merge branch 'master' into cpp-c-improvements 2015-01-03 11:12:55 -06:00
Arfon Smith
6f4557a103 Updating Objective-C matchers and adding a sample C++ file 2015-01-03 11:10:24 -06:00
Matthias Mailänder
dc96f62f9e add support for Linux .desktop files 2015-01-03 14:00:07 +01:00
Paul Chaignon
2f86bd8bda Sample file for .html.hl 2015-01-03 09:37:50 +01:00
Paul Chaignon
fbe43b61d4 Sample file for .cmake.in 2015-01-03 09:37:40 +01:00
Paul Chaignon
546d4163a9 Remove unnecessary file extensions 2015-01-03 09:27:43 +01:00
Arfon Smith
55132f2955 Merge pull request #1945 from thotypous/bluespec
Add Bluespec SystemVerilog grammar
2015-01-02 21:14:52 -06:00
Paulo Matias
ebdd2d4a23 Add Bluespec SystemVerilog Sublime Text grammar 2015-01-03 00:55:19 -02:00
Arfon Smith
4c63827517 Merge pull request #1942 from pchaigno/xml.dist
Add .xml.dist as a XML file extension
2015-01-02 17:07:32 -06:00
Paul Chaignon
401067f637 Revert #1438: add file extensions with multiple segments 2015-01-02 22:57:20 +01:00
Paul Chaignon
8e6609c192 .xml.dist as an XML file extension 2015-01-02 22:29:44 +01:00
Adam Roben
1f1ffcbfa6 Merge pull request #1930 from github/minitest
Switch to Minitest::Test instead of Test::Unit::TestCase
2015-01-02 16:27:43 -05:00
Adam Roben
065dd713c1 Assert that generated files are detected correctly 2015-01-02 16:15:55 -05:00
Arfon Smith
71132d48ff Merge pull request #1922 from Mailaender/patch-2
Added support for Mono .dll.config XML files
2015-01-02 11:10:46 -06:00
Matthias Mailänder
d77e0c62c1 add a DllMap example file
www.mono-project.com/docs/advanced/pinvoke/dllmap/#example
2015-01-02 17:28:37 +01:00
Matthias Mailänder
e853c36039 Update languages.yml
add support for Mono .dll.config XML files
2015-01-02 17:28:36 +01:00
Brandon Keepers
2be3220824 Merge pull request #1940 from github/fix-multiple-extensions
Fix for extensions with multiple segments
2015-01-02 10:59:30 -05:00
Lars Brinkhoff
6ae39e50ae Fix #1731 to allow samples with multiple file extension segments. 2015-01-02 10:41:22 -05:00
Arfon Smith
c783acc973 Merge pull request #1937 from github/hack-highlighting
Update languages.yml for Hack syntax-highlighting
2015-01-02 07:38:24 -06:00
Arfon Smith
e5210b5137 Update languages.yml 2015-01-02 06:53:58 -06:00
Arfon Smith
41f0950c04 Merge pull request #1933 from floscher/patch-1
Added CartoCSS to languages.yml
2015-01-01 13:46:22 -06:00
Florian Schäfer
9f439cd7fb Added support for CartoCSS
Code sample was taken from https://github.com/gravitystorm
/openstreetmap-carto/blob/ae990905790a26ae8af107441ce9e85b60ea1266
/amenity-points.mss
2015-01-01 17:15:22 +01:00
Arfon Smith
c911c5c045 Merge pull request #1932 from deadfoxygrandpa/elm
Update Elm support by adding its own syntax highlighting
2015-01-01 09:16:29 -06:00
Alex Neslusan
27a7873e08 Add color to Elm language definition 2015-01-01 20:41:05 +08:00
Alex Neslusan
5fe233384e Update Elm support 2015-01-01 20:24:13 +08:00
Adam Roben
d42ad45423 Turn on the bundler cache
This should allow us to skip installing gems in most builds, shaving off
~40 seconds.
2014-12-31 15:42:34 -05:00
Adam Roben
84235478ef Download and install libicu-dev without using sudo
We tell apt-get to download it to vendor/apt and then install it into a
vendor/icu directory.

We should be able to just specify --with-icu-dir, but apparently Ruby
2.0 (but not 1.9 or 2.1 or 2.2) has a bug that requires us to use
--with-icu-include/--with-icu-lib instead. Otherwise it can't find the
ICU libraries.
2014-12-31 15:42:34 -05:00
Adam Roben
509b35a19f Opt in to container-based Travis CI builds
This should speed up our builds by providing lower latency, better
caching, and more resources on the build machine. See
http://docs.travis-ci.com/user/workers/container-based-infrastructure/.
2014-12-31 15:42:34 -05:00
Adam Roben
65296e86a3 Switch to Minitest::Test instead of Test::Unit::TestCase
This gives us a consistent test framework across all Ruby versions which
should help avoid errors that are only found when CI runs the tests on
different Rubies. (And this fixes an immediate bug where there's no
`skip` method in the version of test-unit we're currently using only on
Ruby 2.2.)
2014-12-31 15:26:26 -05:00
Adam Roben
c9b7bb73b9 Use test/helper.rb in test_file_blob.rb 2014-12-31 15:19:56 -05:00
Adam Roben
795f42cbaa Merge pull request #1832 from pchaigno/optimize-generated
Optimization of generated?
2014-12-31 15:19:43 -05:00
Arfon Smith
d540ec0cb8 Merge pull request #1928 from github/contributing-update
Update including explicit steps to resolve conflicts.
2014-12-31 11:38:48 -06:00
Arfon Smith
202cba1a14 Update CONTRIBUTING.md 2014-12-31 11:38:03 -06:00
Arfon Smith
20d5b81085 Merge pull request #1929 from github/1304-local
Take 2: Add support for .sls YAML files (SaltStack states)
2014-12-31 09:45:14 -06:00
Arfon Smith
d8b806592d Removing trailing slash 2014-12-31 08:27:40 -06:00
Arfon Smith
84f9b83fc2 Fixing up grammars 2014-12-31 08:25:56 -06:00
Arfon Smith
7cb5106656 Adding atom-salt gitsubmodule 2014-12-31 07:48:48 -06:00
Arfon Smith
6f21df7624 Merge branch 'master' into 1304-local
Conflicts:
	grammars.yml
2014-12-30 22:15:55 -06:00
Arfon Smith
4c7dc565e7 Update including explicit steps to resolve conflicts. 2014-12-30 20:52:48 -06:00
Adam Roben
3c60fba430 Merge pull request #1926 from github/sas-grammar
Added support for SAS syntax.
2014-12-30 07:26:32 -05:00
Roy Pardee
224eef9ffa Added support for SAS syntax. 2014-12-30 06:34:37 -05:00
Paul Chaignon
42beadcf34 Use an exception for tests on Generated.generated? 2014-12-28 17:00:13 +01:00
Brandon Keepers
80ed2d6d30 Merge pull request #1920 from pchaigno/webidl-grammar
Grammar for WebIDL
2014-12-27 14:55:47 -05:00
Paul Chaignon
c2bf6fe7f5 Grammar for WebIDL 2014-12-27 16:54:41 +01:00
archy
084a9ab976 vendor.yml: added stylesheets imported from packages 2014-12-26 04:45:37 +08:00
archy
356b942114 vendor.yml: added less, scss, styl suffixes for popular stylesheets 2014-12-26 04:45:30 +08:00
archy
2c5d720146 vendor.yml: added imported bootstrap files 2014-12-26 04:45:18 +08:00
archy
64f83eee07 vendor.yml: added styl 2014-12-26 04:45:09 +08:00
archy
542cf9c52b vendor.yml: added custom bootstrap 2014-12-26 04:44:47 +08:00
Joaquin Casares
0bbccc1bc1 Properly order extensions 2014-12-22 16:48:22 -06:00
Adam Roben
6f014f8638 Merge pull request #1896 from github/grammar-submodules
Move all grammars that use Git repos to submodules
2014-12-22 17:17:40 -05:00
Adam Roben
66ca5aca89 Init submodules in CI 2014-12-22 17:07:37 -05:00
Adam Roben
33afa30c30 Don't use question marks in struct fields
Apparently it doesn't work in Ruby 1.9.
2014-12-22 17:06:49 -05:00
Adam Roben
1634d787ec Use fast-submodule-update in CI
Hopefully this will speed up CI builds.
2014-12-22 16:58:59 -05:00
Adam Roben
df7b529e23 Set tracking branches for submodules that aren't tracking master
This will let us use `git submodule update --remote` to update the
submodules to the latest commit from the relevant branch.
2014-12-22 16:41:22 -05:00
Adam Roben
56d90bedd0 Sort grammars.yml 2014-12-22 16:36:35 -05:00
Brandon Keepers
8369d253f8 Move grammar sources to vendor/grammars 2014-12-22 16:28:58 -05:00
Adam Roben
516d3e226c Suggest adding/removing submodules from the repo 2014-12-22 15:50:33 -05:00
Joaquin Casares
f4208cb27d Add support for cql and ddl files 2014-12-19 17:51:59 -06:00
Adam Roben
47b785a8fd Initialize submodules before updating them
Initialization cannot happen in parallel because every submodule has to
get written to .git/config.
2014-12-19 16:05:17 -05:00
Adam Roben
6a2bf3fd2f Update submodules in parallel to speed up bootstrap
This runs 8 `git submodule update` processes in parallel, speeding up
bootstrap from 2 minutes to 30 seconds for me. (Obviously this is
dependent on bandwidth.)
2014-12-19 16:05:17 -05:00
Adam Roben
ff678642e6 Suggest running script/bootstrap before building gems
This ensures all our submodules are up to date as well.
2014-12-19 16:05:17 -05:00
Adam Roben
e3eb1b90c5 Test that grammars.yml agrees with the list of submodules
If any submodules are missing from grammars.yml, or are listed in
grammars.yml but missing from the repo, the test will fail.

Eventually it would be good to test that the scopes for each submodule
are accurate, but that will take some more work.
2014-12-19 16:05:17 -05:00
Adam Roben
49125f077c Update grammars.yml
This is just the result of running script/download-grammars.
2014-12-19 15:39:02 -05:00
Adam Roben
324031cb68 Sort grammars.yml 2014-12-19 15:39:02 -05:00
Adam Roben
f2ab426d38 Move all grammars that use Git repos to submodules
This makes it so we don't have to redownload all the grammars every time
we build the grammars gem. It will also let us verify that grammars.yml
is accurate in the future by checking it against the submodules on disk.

script/bootstrap now updates the submodules.
2014-12-19 15:39:02 -05:00
Brandon Keepers
587ab35d65 Merge pull request #1904 from github/remove-cached-gems
Remove cached gems
2014-12-19 11:27:10 -05:00
Brandon Keepers
16a6dda3dd Remove cached gems 2014-12-19 10:52:29 -05:00
Dale Henrichs
034137f533 Use source.smalltalk to hightlight STON files.
While not perfect, source.smalltalk is a better fit for highlighting STON files than source.json. When STON departs from pure JSON (often) the hightlighting is pretty bad.
2014-12-18 21:19:38 -08:00
Dale Henrichs
6f75e18bfa Merge pull request #1 from github/master
update with latest master
2014-12-18 20:29:28 -08:00
Arfon Smith
15191b068d Merge pull request #1890 from github/cut-release-v4.2.4
Updating Linguist version for v4.2.4
2014-12-18 14:31:21 -08:00
Arfon Smith
ee9cc24e52 Longer timeout 2014-12-18 14:28:33 -08:00
Arfon Smith
0584fbf42b 4.2.5 2014-12-18 14:17:36 -08:00
Adam Roben
f5f9ccee7f Merge pull request #1895 from github/bootstrap-script
Add script/bootstrap
2014-12-18 12:20:26 -05:00
Adam Roben
0d183e2e89 Ignore vendor/gems
This is where script/bootstrap places the bundle.
2014-12-18 12:14:45 -05:00
Adam Roben
b9eacfefc8 Add script/bootstrap
This just runs Bundler with the right options. Maybe it will do more in
the future, like update submodules.
2014-12-18 12:13:32 -05:00
Arfon Smith
0239127db4 4.2.5b1 2014-12-18 08:02:24 -08:00
Arfon Smith
281d1ea91c Merge branch 'master' into cut-release-v4.2.4 2014-12-17 15:37:46 -08:00
Arfon Smith
df92ecaa55 Merge pull request #1891 from github/fix-grammars
Fix some bugs in grammars.yml
2014-12-17 15:35:30 -08:00
Adam Roben
60d40c8ad8 Update grammars.yml
I just ran script/download-grammars and these are the changes it made.
The most notable one is that we had the wrong scope listed for Markdown.
2014-12-17 16:39:03 -05:00
Adam Roben
f428c561c9 Remove the WebIDL grammar
This grammar uses the same scope name (source.idl) as our existing IDL
grammar. The wrong scope name was listed in grammars.yml which masked
this problem. https://github.com/andik/IDL-Syntax/pull/2 tracks getting
the grammar to use a different scope name; in the meantime we just won't
highlight these files.
2014-12-17 16:39:03 -05:00
Adam Roben
8fbb7a1d93 Sort grammars.yml 2014-12-17 16:39:03 -05:00
Adam Roben
e98223b2b3 Use raw links as little as possible
It's much cleaner and more robust to specify the repo URL instead of a
URL to an individual file. If the file gets moved we'll still be able to
find it if we're using the repo URL.

Where we do need raw links, we now use github.com/owner/repo/raw/*
because it looks a bit nicer and sorts better with non-raw links.
2014-12-17 16:39:03 -05:00
Adam Roben
410fe2843d Add some tests for grammars.yml
It must be sorted, because it will get re-sorted when
script/download-grammars is next run and that would clutter up diffs.
And it must not contain any duplicate scopes.
2014-12-17 16:39:02 -05:00
Arfon Smith
dc8d69e0f4 Updating Linguist version for v4.2.4 2014-12-17 10:31:51 -08:00
Arfon Smith
a056765e38 Merge pull request #1886 from Dadido3/patch-1
Add PureBasic
2014-12-17 10:28:46 -08:00
MattDMo
97cd1e3886 Reorganized Sublime files, added more extensions. Moved those in JSON to JavaScript, as comments are allowed, and added several. Added 2 to XML. 2014-12-17 11:49:54 -05:00
Adam Roben
4e7da98bfa Merge pull request #1875 from arctic5/patch-1
change ace mode of game maker language to c++
2014-12-17 08:59:21 -05:00
David Vogel
0a56f5282d Create Example_Sine.pb 2014-12-17 12:00:16 +01:00
Arfon Smith
04b9ca2fd4 Merge pull request #1797 from github/cs-smalltalk
Cs smalltalk
2014-12-17 04:47:37 -06:00
Arfon Smith
ddbe3df6de Merge pull request #1876 from Mailaender/patch-2
Added support for StyleCop XML configuration files
2014-12-16 21:29:55 -06:00
Arfon Smith
ab5c88a7f3 Merge pull request #1881 from hawkw/master
Add support for Jasmin JVM assembly
2014-12-16 21:29:19 -06:00
Arfon Smith
4046a0efe9 Merge pull request #1877 from sebgod/change-mercury-grammar
Added a more suitable grammar for Mercury
2014-12-16 21:27:10 -06:00
Arfon Smith
5aefc7cdff Merge pull request #1885 from github/gjtorikian-patch-1
Use atom/language-atom for the YAML grammar
2014-12-16 21:25:02 -06:00
David Vogel
70eb779ce5 Reduced PureBasic to .pb and .pbi 2014-12-16 22:19:56 +01:00
David Vogel
39f5d28348 Added PureBasic example 2014-12-16 21:12:13 +01:00
David Vogel
e70407f16b Added PureBasic 2014-12-16 20:34:32 +01:00
Garen Torikian
c25475296d Use atom/language-atom for the YAML grammar 2014-12-16 08:17:07 -08:00
Paul Chaignon
1363af0317 Remove defactor keyword for .lsp heuristic 2014-12-16 11:02:23 -05:00
Vicent Marti
e97b7454e9 grammars: Temporarily use vmg's fork for C.tmbundle 2014-12-16 17:02:09 +01:00
Paul Chaignon
2418356eff Merge branch 'master' into newlisp 2014-12-16 10:52:17 -05:00
Hawk Weisman
735caa03b1 Fix empty sample file. 2014-12-15 22:47:11 -05:00
Hawk Weisman
f577aece08 Add Objective-J samples 2014-12-15 22:40:02 -05:00
Hawk Weisman
b7f1bfdb92 Put Jasmin entry in the right place. 2014-12-15 22:37:17 -05:00
Hawk Weisman
b5301e280b Add some samples of Jasmin assembly 2014-12-15 21:35:14 -05:00
Hawk Weisman
741816db52 Add Jasmin to languages.yml 2014-12-15 21:29:26 -05:00
Hawk Weisman
546a6e2a68 Add Jasmin textmate language 2014-12-15 21:27:06 -05:00
Sebastian Godelet
1be5e8c63e Added a more suitable grammar for Mercury 2014-12-15 10:31:50 +08:00
Matthias Mailänder
917a25317a sort alphabetically 2014-12-14 15:27:39 +01:00
Matthias Mailänder
949167e6ad add support for StyleCop XML configuration files 2014-12-14 13:04:31 +01:00
arctic
a359905a06 change ace mode of game maker language to c++ 2014-12-13 23:41:31 -08:00
Arfon Smith
4ce606306d Merge pull request #1871 from github/fish
Fish
2014-12-12 11:24:40 -06:00
Arfon Smith
707fcd29ea Merge branch 'master' into fish
Conflicts:
	grammars.yml
	lib/linguist/languages.yml
2014-12-12 11:22:24 -06:00
Arfon Smith
970cbe35b8 :blank: -> \t 2014-12-12 08:23:17 -06:00
Arfon Smith
fa9e8aa5c0 Merge branch 'master' into cpp-c-improvements 2014-12-12 08:21:32 -06:00
Brandon Keepers
a5e6d37049 Merge pull request #1859 from pchaigno/rc-interpreter
rc as a Shell interpreter for Plan 9
2014-12-11 22:49:27 -05:00
Arfon Smith
dacac135fb Merge pull request #1868 from github/no-language
No language
2014-12-11 21:23:02 -06:00
Arfon Smith
0ddf0d5d0d Merge branch 'master' into no-language
Conflicts:
	lib/linguist/heuristics.rb
2014-12-11 21:17:38 -06:00
Arfon Smith
90a5251fa7 Merge branch 'master' into cpp-c-improvements 2014-12-11 21:11:32 -06:00
Arfon Smith
a97c69e06f BitBake ace_mode 2014-12-11 21:10:57 -06:00
Arfon Smith
a323eb43ed Better C++ regex 2014-12-11 21:06:35 -06:00
Arfon Smith
79243b77fd Merge pull request #1129 from pchaigno/bitbake
Support of the BitBake language
2014-12-11 20:58:06 -06:00
Arfon Smith
5ab2720ddc Merge pull request #1865 from github/webidl
Webidl
2014-12-11 20:56:05 -06:00
Arfon Smith
c72a49b77f Whitespace 2014-12-11 20:52:44 -06:00
Arfon Smith
a0d92b80df Merge branch 'master' into webidl
Conflicts:
	grammars.yml
2014-12-11 20:52:17 -06:00
Arfon Smith
1a32a6252b Merge pull request #1861 from github/aroben-patch-1
Suggest reproducing highlighting errors in text editors
2014-12-11 20:45:33 -06:00
Arfon Smith
6df7cbaf6e Merge pull request #1864 from github/robrix-patch-1
Use atom/language-gfm’s Markdown grammar.
2014-12-11 20:44:37 -06:00
Rob Rix
0a90cd3a0a Remove the accidental “m”. 2014-12-11 16:38:10 -05:00
Rob Rix
c529939481 Use atom/language-gfm’s Markdown grammar.
We render [GitHub Flavoured Markdown](https://help.github.com/articles/github-flavored-markdown/) on the site. We can use Atom’s grammar to ensure that syntax highlighting uses the same dialect.
2014-12-11 16:29:36 -05:00
Paul Chaignon
db70630eaa Renamed text in Text 2014-12-11 12:51:09 -05:00
Adam Roben
24862d9759 Merge pull request #1863 from github/popular-integrity
Test that all popular languages exist
2014-12-11 12:31:08 -05:00
Adam Roben
cb5f2685cd Test that all popular languages exist
popular.yml listed "Bash" but should have been listing "Shell" instead.
There is no "Bash" language. Now CI will fail if this happens again.
2014-12-11 11:47:52 -05:00
Brandon Keepers
baa298873a Merge pull request #1854 from github/more-shebang-fixes
More shebang fixes
2014-12-11 10:40:11 -05:00
Adam Roben
a8f57d37bf Merge pull request #1860 from github/atom-sass-grammar
Use atom/language-sass's Sass grammar
2014-12-11 09:52:14 -05:00
Adam Roben
d97ee52f4e Suggest reproducing highlighting errors in text editors
This will make for more useful upstream bug reports.
2014-12-11 09:39:24 -05:00
Adam Roben
1cfdb6decd Use atom/language-sass's Sass grammar
This works better than the old Ruby Sass.tmbundle we were pulling from
svn.textmate.org.

atom/language-sass also contains an SCSS grammar, but I didn't switch to
using that grammar because it isn't obviously better than our current
one and I'm not an SCSS expert.
2014-12-11 09:35:33 -05:00
Paul Chaignon
f93272f0bd Move text files from fixtures to samples when possible 2014-12-10 20:09:14 -05:00
Paul Chaignon
e783e953d9 Merge branch 'master' into data-fixture-folder 2014-12-10 19:15:41 -05:00
Paul Chaignon
39cac919c7 rc as a Shell interpreter for Plan 9 2014-12-10 19:12:28 -05:00
Arfon Smith
fec82173d9 Merge pull request #1856 from lutoma/xelix-c-samples
Add a bunch of C header samples for the Bayesian classifier
2014-12-10 15:29:18 -06:00
Lukas Martini
35efed73d4 Add a bunch of C header samples for the Bayesian classifier 2014-12-10 20:28:20 +01:00
Brandon Keepers
21b8e16afc Use #start_with? for clarity 2014-12-10 12:05:37 -05:00
Brandon Keepers
6efee51101 Add missing test cases 2014-12-10 11:00:46 -05:00
Brandon Keepers
1490425ecb document shebang code 2014-12-10 11:00:41 -05:00
Brandon Keepers
afac6a918d Handle empty shebang with whitespace 2014-12-10 11:00:32 -05:00
Brandon Keepers
bf0e488c06 Test case for case causing error 2014-12-10 10:58:14 -05:00
othree
37c2bee3ae Follow #1831, change WebIDL ace_mode to 'text' 2014-12-10 14:18:25 +08:00
othree
4debcabb88 Add syntax define for WebIDL 2014-12-10 12:03:59 +08:00
Garen Torikian
5a0c637ad0 Merge pull request #1831 from github/return-nil-on-no-ace-mode
Set "missing" ace modes to `text`
2014-12-09 10:53:47 -08:00
othree
d91215680a Add WebIDL support and two sample file 2014-12-10 01:28:23 +08:00
Garen Torikian
0cbcbd4614 Set Public Key ace_mode to text 2014-12-09 09:16:51 -08:00
Garen Torikian
19135f08c3 Merge branch 'master' into return-nil-on-no-ace-mode 2014-12-09 09:13:02 -08:00
Brandon Keepers
855cc52f0f Merge pull request #1844 from pchaigno/pgp
Public Key as a language with .asc and .pub extensions
2014-12-09 11:24:18 -05:00
Garen Torikian
4e5da23474 Add warn message indicating deprecation 2014-12-09 08:20:15 -08:00
Arfon Smith
3cca4ec0ac Merge pull request #1848 from larsbrinkhoff/again_with_the_fortran
Improve FORTRAN heuristic.
2014-12-08 16:02:58 -06:00
Lars Brinkhoff
e393f7feb4 Improve FORTRAN heuristic. 2014-12-08 13:53:19 +01:00
Arfon Smith
b76ac7bab0 Merge pull request #1845 from lostcolony/patch-1
Adding 'erlang.mk' to vendor.yml exclusion list.
2014-12-07 17:45:48 -06:00
lostcolony
a3c842ba18 Adding erlang.mk to exclusion list.
Adding 'erlang.mk' to list of erlang bundles; it's seeing some adoption in the Erlang community for building Erlang apps, and at 1k lines of code at present can dominate an initial check-in, project skeleton, or small library.

See https://github.com/ninenines/erlang.mk for further details.
2014-12-07 16:41:56 -05:00
Paul Chaignon
1640370c9d Add Public Key as a language with .asc and .pub extensions 2014-12-07 10:37:25 -05:00
Garen Torikian
b6427fa05a Set text's ace_mode to text 2014-12-07 14:48:36 +02:00
Garen Torikian
2a04d854cc Merge branch 'master' into return-nil-on-no-ace-mode 2014-12-07 14:45:27 +02:00
Jorge Bucaran
6d190d7d7c Add Fish. (Fix* ace_mode: none) 2014-12-07 16:24:16 +09:00
Jorge Bucaran
b8a2bd595a Add Fish. (Update) 2014-12-07 15:57:46 +09:00
Paul Chaignon
8b7d5546f7 Merge branch 'master' into newlisp 2014-12-06 20:04:18 -05:00
Paul Chaignon
b63423ce37 Merge branch 'master' into newlisp 2014-12-06 19:56:29 -05:00
Paul Chaignon
0b02b68538 Heuristic for .lsp and .lisp (Common Lisp, NewLisp) 2014-12-06 19:51:45 -05:00
Paul Chaignon
bbd1646ae5 Add .lisp as a NewLisp file extension 2014-12-06 19:51:20 -05:00
Arfon Smith
299a9c7bc9 Merge pull request #1835 from tenbits/master
MaskLang: Use proper tm scope
2014-12-06 17:14:06 -06:00
Arfon Smith
37f8d5b5e1 Merge pull request #1834 from karel-brinda/master
Python syntax highlighting for Snakemake files
2014-12-06 17:11:51 -06:00
Arfon Smith
2a6a59c047 Merge pull request #1842 from pchaigno/ts
Add .ts as a XML extension for Qt translation files
2014-12-06 17:06:09 -06:00
Paul Chaignon
c4da2dd557 Merge branch 'master' into newlisp 2014-12-06 17:50:37 -05:00
Paul Chaignon
583392d179 Heuristic for .ts (TypeScript, XML) 2014-12-06 16:31:14 -05:00
Paul Chaignon
1488796779 .ts as a XML extension for Qt translation files 2014-12-06 15:41:13 -05:00
Paul Chaignon
7458a2f9ff Heuristic for .bb (BitBake, BlitzBasic) 2014-12-06 15:26:30 -05:00
Garen Torikian
348dab4b9f Update test to account for using text 2014-12-06 11:59:31 +02:00
Paul Chaignon
5c824e0771 Ace mode and grammar to none for BitBake after merge with master 2014-12-05 21:20:55 -05:00
Paul Chaignon
b9c88a758c Merge branch 'master' into bitbake 2014-12-05 19:35:48 -05:00
Paul Chaignon
a51d637e58 Error messages for tests on Generated 2014-12-05 17:53:19 -05:00
Karel Brinda
d002dfa70c Snakemake => Snakefile (Snakemake ... program, Snakefile ... file) 2014-12-05 23:46:37 +01:00
Karel Brinda
d118017d27 Correction of alphabet sorting of filenames 2014-12-05 23:36:25 +01:00
Alex Kit
d10d328eb1 MaskLang: Use proper tm scope 2014-12-05 23:13:01 +01:00
Karel Brinda
e472d7b8b1 Python syntax highlighting for Snakemake files 2014-12-05 20:00:52 +01:00
Brandon Keepers
a54d6f3a8a Merge pull request #1779 from larsbrinkhoff/fr
Disambiguate .fr between Frege, Forth, and plain text files
2014-12-05 08:18:24 -08:00
Paul Chaignon
67ccb24b41 Require test helper in generated test 2014-12-05 10:29:19 -05:00
Paul Chaignon
42ff3f58d9 Tests for Generated.generated? optimization 2014-12-05 11:38:03 -05:00
Garen Torikian
ad778571a2 This reject is no longer necessary 2014-12-05 16:57:55 +02:00
Garen Torikian
bb12b86445 Set missing ace_mode values to text
This makes it much easier to deal with when iterating over all the
languages, since `text` is a valid, non-highlighting lexer.
2014-12-05 16:56:55 +02:00
Garen Torikian
ab61b06c34 Reject Ace modes that are lacking a mode 2014-12-05 16:25:14 +02:00
Lars Brinkhoff
de6b2f3307 Add 'text' language with samples, and heuristics for .fr. 2014-12-05 12:19:36 +01:00
Lars Brinkhoff
5fd56c75d5 Add Forth extension .fr; and a sample. 2014-12-05 11:52:00 +01:00
Paul Chaignon
6aa70a3e93 Reorganize the methods called in generated? to only load the data in last resort 2014-12-05 01:22:38 -05:00
Paul Chaignon
93186947c2 Move binaries and text files from samples folder to fixtures 2014-12-04 23:48:05 -05:00
Paul Chaignon
77444284e3 Data folder in fixtures for files with no language 2014-12-04 19:14:44 -05:00
Paul Chaignon
6950b028df Ace mode for SaltStack 2014-12-04 15:06:35 -05:00
Paul Chaignon
565767ef42 Merge branch 'master' into saltstack-states 2014-12-04 15:05:52 -05:00
Garen Torikian
a1f26d64d5 Merge pull request #1762 from github/add-missing-ace-modes-for-popular-languages
Add missing `ace_mode` values wherever necessary
2014-12-04 21:46:58 +02:00
Paul Chaignon
be30e1c658 Grammar for .sls SaltStack files 2014-12-04 14:42:24 -05:00
Garen Torikian
3aec4dd2ea Adjust to ignore generated 2014-12-04 21:27:07 +02:00
Paul Chaignon
ed34caa565 Merge branch 'master' into saltstack-states 2014-12-04 14:14:05 -05:00
Garen Torikian
81b8c57bae Add Loomscript exclusion 2014-12-04 21:10:28 +02:00
Garen Torikian
0780b7239a Merge branch 'master' into add-missing-ace-modes-for-popular-languages 2014-12-04 21:09:46 +02:00
Arfon Smith
1d626f7378 Merge pull request #1821 from github/cut-release-v4.2.3
v4.2.3
2014-12-03 15:09:42 -06:00
Arfon Smith
ff3438b810 v4.2.3 2014-12-03 13:52:45 -06:00
Arfon Smith
1762c2cefd Merge pull request #1816 from github/FS-samples
Adding more F# .fs samples. Fixes #1814
2014-12-03 13:47:18 -06:00
Arfon Smith
7aaf99c9b1 Merge branch 'FS-samples' of github.com:github/linguist into FS-samples 2014-12-03 13:09:00 -06:00
Arfon Smith
07cd9aa994 Merge branch 'master' into FS-samples 2014-12-03 13:08:41 -06:00
Arfon Smith
6ae4aa50e2 Merge pull request #1817 from pchaigno/fix-fs-heuristic
Fix .fs heuristic
2014-12-03 13:08:08 -06:00
Brandon Keepers
22fbcc244b Merge pull request #1820 from github/cut-release-v4.2.2
v4.2.2
2014-12-03 10:55:09 -08:00
Garen Torikian
1a3177409c Merge master 2014-12-03 20:15:55 +02:00
Garen Torikian
de4b538d82 Update comment at the top of the file 2014-12-03 20:14:20 +02:00
Brandon Keepers
70b1ec97db Clean before running janky build 2014-12-03 10:07:59 -08:00
Brandon Keepers
a97e328484 v4.2.2 2014-12-03 09:58:08 -08:00
Brandon Keepers
e446b86b90 Merge pull request #1813 from github/invalid-shebang
Fix detection for invalid shebang
2014-12-03 09:48:48 -08:00
Arfon Smith
901e8da911 Merge pull request #1818 from github/remove-scss-from-sass
SCSS isnt SASS
2014-12-03 10:13:32 -06:00
Arfon Smith
e9036d675e SCSS isnt SASS 2014-12-03 10:12:58 -06:00
Paul Chaignon
351e348ac0 New F# sample to test fix for .fs heuristics 2014-12-03 10:07:54 -05:00
Paul Chaignon
feea9bfd30 Fix heuristic for .fs 2014-12-03 09:48:54 -05:00
Arfon Smith
f1282b857d Better output for failing test 2014-12-03 08:46:45 -06:00
Arfon Smith
70e0ce1d73 Adding more F# .fs samples. Fixes #1814 2014-12-03 08:36:58 -06:00
Brandon Keepers
a5673e7fb6 Fix detection for invalid shebang 2014-12-02 21:03:39 -06:00
Arfon Smith
d06529fd14 Merge pull request #1812 from github/cut-release-v4.2.1
Bumping linguist version
2014-12-02 20:30:30 -06:00
Arfon Smith
a02f19f5a3 Bumping linguist version 2014-12-02 20:06:36 -06:00
Arfon Smith
a9a62fff15 Merge pull request #1809 from pchaigno/fix-matches-heuristics
Fix error when matching languages against heuristics
2014-12-02 20:05:22 -06:00
Paul Chaignon
7625c92307 Remove .module extension for PHP 2014-12-02 20:37:09 -05:00
Paul Chaignon
7dd318ca76 Use namespace.js for the heuristic test with no match 2014-12-02 20:36:18 -05:00
Paul Chaignon
e5bc2845cd Fix for fixture tests: fixture files were not tested at all 2014-12-02 20:26:15 -05:00
Paul Chaignon
4ddd8d9d2b Unit test for fix #1809 on heuristics 2014-12-02 20:06:12 -05:00
Paul Chaignon
37ffdb9020 Fix error when matching languages against heuristics: if no language, no heuristic rule should be used 2014-12-02 16:41:39 -05:00
Arfon Smith
39037d5bfb Merge pull request #1803 from github/cut-release-v4.2.0
Bumping to v4.2.0
2014-12-02 12:36:05 -06:00
Arfon Smith
31d882b07e Merge branch 'master' into cut-release-v4.2.0
Conflicts:
	grammars.yml
2014-12-02 10:57:53 -06:00
Arfon Smith
fd9275b213 Merge pull request #1702 from ellemenno/loomscript-support
add language declaration and samples for LoomScript
2014-12-02 10:54:36 -06:00
Arfon Smith
cfa63cff35 Merge pull request #900 from hoelzro/master
Update Perl 6 samples
2014-12-02 10:52:45 -06:00
Arfon Smith
5e6fd11cc2 Updating Oz tmbundle 2014-12-01 15:08:22 -06:00
Arfon Smith
62a8b52df4 Bumping to v4.2.0 2014-12-01 14:19:08 -06:00
Adam Roben
783670095c Merge pull request #1802 from wmertens/master
Add grammar for Nix
2014-12-01 13:05:24 -05:00
Wout Mertens
23cfa86f93 Add grammar for Nix 2014-12-01 18:50:56 +01:00
Garen Torikian
dce00d01d9 Add missing ace_mode values 2014-12-01 15:54:33 +02:00
Garen Torikian
768ec76ff0 Merge master 2014-12-01 15:52:37 +02:00
ellemenno
211cb9567a refactor heuristic tests to use new helper 2014-12-01 01:37:55 -05:00
ellemenno
1e68a45515 add test of ls disambiguation 2014-12-01 01:30:14 -05:00
ellemenno
72c00f869c add textmate scope for loomscript 2014-12-01 01:30:14 -05:00
ellemenno
c76137efc0 improve regex for loomscript 2014-12-01 01:30:13 -05:00
ellemenno
88f196e4d4 add a heuristic to disambiguate LiveScript from LoomScript
Keying off of `package {`, since LoomScript code must be enclosed in a
package definition, whereas that would be invalid LiveScript
2014-12-01 01:28:33 -05:00
ellemenno
4fe5980065 add language declaration and samples for LoomScript
LoomScript is the scripting language for the Loom SDK.
It has an ActionScript3-like syntax with added C#-esque capabilities.

Loom SDK: https://github.com/LoomSDK/LoomSDK
2014-12-01 01:03:03 -05:00
Rob Hoelz
7c7b1fb9c4 Reorder extensions for Perl 6 2014-11-30 22:35:52 -06:00
Rob Hoelz
ed3d38cf05 Create Perl6 heuristic 2014-11-30 22:35:52 -06:00
Rob Hoelz
837e9a6325 Add a bunch of Perl 6 sample files 2014-11-30 22:28:06 -06:00
Rob Hoelz
1364e9be51 Add .t as a valid Perl/Perl6 file extension 2014-11-30 22:28:06 -06:00
Arfon Smith
2fbfaf448d Merge pull request #1800 from github/isabelle-grammar
Isabelle grammar
2014-11-30 21:58:08 -06:00
Arfon Smith
bf82caccfc Merge branch 'master' into isabelle-grammar
Conflicts:
	grammars.yml
2014-11-30 21:53:02 -06:00
Arfon Smith
325dbc8e16 Merge pull request #1698 from sebgod/add-mercury-interpreter
languages.yml: added an interpreter entry to Mercury section
2014-11-30 21:28:04 -06:00
Arfon Smith
bd2fb0af51 Merge pull request #1790 from pchaigno/gradle
Support for gradle files
2014-11-30 21:24:30 -06:00
Arfon Smith
3c904dff61 Merge pull request #1798 from github/google-apps
Google apps
2014-11-30 21:16:50 -06:00
Arfon Smith
9b22b2973f Merge branch 'master' into google-apps
Conflicts:
	lib/linguist/heuristics.rb
	lib/linguist/samples.json
2014-11-30 21:11:59 -06:00
Arfon Smith
025bb35ac7 Merge pull request #1673 from blakeembrey/support-raml
Add spport for RAML language
2014-11-30 21:05:10 -06:00
Arfon Smith
7fb5d0cadd Merge pull request #1782 from anpar/master
Add Oz to recognized languages
2014-11-30 20:57:55 -06:00
Arfon Smith
8157c6f56b Merge pull request #1796 from github/cool
Cool
2014-11-30 20:49:26 -06:00
Arfon Smith
0154c21c3d Adding Cool grammar 2014-11-30 20:45:24 -06:00
Arfon Smith
8c841903a5 Merge branch 'master' into cs-smalltalk
Conflicts:
	lib/linguist/languages.yml
	lib/linguist/samples.json
2014-11-30 15:35:16 -06:00
Arfon Smith
648596dbb2 Be explicit about tm_scope 2014-11-30 15:24:33 -06:00
Arfon Smith
212c74d8a3 Merge branch 'master' into cool
Conflicts:
	lib/linguist/heuristics.rb
	lib/linguist/languages.yml
	lib/linguist/samples.json
2014-11-30 15:23:09 -06:00
Antoine Paris
4495e15fa7 Misspelling correction 2014-11-30 22:07:55 +01:00
Antoine Paris
da96e11b37 Add grammar for Oz 2014-11-30 22:01:39 +01:00
Antoine Paris
b7a9843770 Corrections by @pchaigno 2014-11-30 21:18:23 +01:00
Arfon Smith
55432774c7 Merge pull request #1795 from github/mercury-vendor
Removing Mercury directory from vendor.yml
2014-11-30 08:00:36 -06:00
Arfon Smith
ca76802ee4 Removing Mercury directory from vendor.yml 2014-11-30 07:55:55 -06:00
Gerwin Klein
cec54837bc add language grammar for Isabelle theorem prover 2014-11-30 17:17:13 +11:00
Arfon Smith
e0c35b0665 Merge pull request #1706 from pchaigno/mm-xml
Add .mm as an XML extension with heuristic rule
2014-11-29 23:07:58 -06:00
Brandon Keepers
865980b8f7 Merge pull request #1791 from pchaigno/remove-old-heuristic
Remove old test forgotten in #1788
2014-11-29 12:32:28 -06:00
Paul Chaignon
9367a4797f Remove old test forgotten in #1788 2014-11-28 23:14:17 -05:00
Paul Chaignon
4ed58c743d Support for gradle files 2014-11-28 23:00:35 -05:00
Arfon Smith
cfd95360cb Merge pull request #1627 from github/1036-local
Disambiguate C, C++, Objective-C
2014-11-28 18:05:16 -06:00
Brandon Keepers
22144e79d3 Merge pull request #1787 from github/move-shebang
Move shebang (updated)
2014-11-28 18:02:04 -06:00
Brandon Keepers
3acbf06beb Merge pull request #1788 from github/refactor-heuristics
Refactor heuristics (updated)
2014-11-28 17:59:43 -06:00
Brandon Keepers
7b41346db8 Merge branch 'refactor-heuristics' into 1036-local
* refactor-heuristics: (43 commits)
  update docs
  Clean up heuristic logic
  Allow disambiguate to return an Array
  Rename .create to .disambiguate
  docs
  Remove inactive heuristics
  Refactor heuristics
  Not going back
  docs
  Move call method into existing Classifier class
  Try strategies until one language is returned
  Remove unneded empty blob check
  Add F# and GLSL samples.  Add Forth and GLSL extension .fs. Add heuristic to disambiguate between F#, Forth, and GLSL.
  byebug requires ruby 2.0
  Remove test for removed extension
  Fix typo in test
  add rake interpreter
  add python3 interpreter
  Remove old wrong_shebang.rb sample
  Add byebug
  ...

Conflicts:
	lib/linguist/heuristics.rb
	test/test_heuristics.rb
2014-11-28 17:58:00 -06:00
Brandon Keepers
878b321b89 Merge remote-tracking branch 'origin/master' into move-shebang
* origin/master:
  Tweak docs
2014-11-28 17:41:10 -06:00
Brandon Keepers
a903123cb8 Merge pull request #1663 from github/strategies
Refactor detection into strategies
2014-11-28 17:40:12 -06:00
Brandon Keepers
577fb95384 Tweak docs 2014-11-28 17:36:14 -06:00
Brandon Keepers
770a1d4553 update docs 2014-11-28 17:07:15 -06:00
Brandon Keepers
c038b51941 Clean up heuristic logic 2014-11-28 17:03:01 -06:00
Brandon Keepers
4bebcef6ef Allow disambiguate to return an Array 2014-11-28 16:55:00 -06:00
Jorge Bucaran
d4888098e5 Add source.fish scope reference. 2014-11-29 07:39:19 +09:00
Jorge Bucaran
a349daeaeb Add fish tmBundle source. 2014-11-29 07:38:00 +09:00
Brandon Keepers
b8685103d0 Rename .create to .disambiguate 2014-11-28 14:41:52 -06:00
Brandon Keepers
26d789612b docs 2014-11-28 14:40:02 -06:00
Garen Torikian
7a57a0b594 What is this, Lisp? 2014-11-28 12:35:42 -08:00
Garen Torikian
66eabd8bdc Prefer Yajl.load 2014-11-28 12:34:02 -08:00
Garen Torikian
be82b55408 Simplify rescue catching 2014-11-28 12:33:43 -08:00
Garen Torikian
526ca1761a This require is no longer used 2014-11-28 12:33:37 -08:00
Brandon Keepers
10de952ed6 Remove Linguist.interpreter_from_shebang 2014-11-28 14:14:40 -06:00
Brandon Keepers
2517650ecb Fix shebang without path 2014-11-28 14:14:10 -06:00
Brandon Keepers
47b739527a Treat lines as enumerator and not array 2014-11-28 13:55:55 -06:00
Garen Torikian
8655d966ad Make corrections from a bade merge resolution 2014-11-28 11:50:46 -08:00
Garen Torikian
3fb4973aab Add missing ace_modes (introduced from master) 2014-11-28 11:48:39 -08:00
Garen Torikian
1d4149168d Add Rake task to fetch ace_modes, and skip test if there's no internet 2014-11-28 11:48:26 -08:00
Garen Torikian
26ab33754f Merge master 2014-11-28 11:04:53 -08:00
Brandon Keepers
88f08803ee require shebang when building samples 2014-11-28 12:34:41 -06:00
Brandon Keepers
c05717d15c docs 2014-11-28 12:27:48 -06:00
Brandon Keepers
bc66f558b9 Remove inactive heuristics
We can add these back when we’re ready to enable them.
2014-11-28 12:17:52 -06:00
Antoine Paris
71e1bd9af2 Misspelling correction 2014-11-28 17:42:54 +01:00
Antoine Paris
57b0739219 Add some examples for Oz 2014-11-28 17:40:49 +01:00
Antoine Paris
d60241cc86 Add grammar for Oz 2014-11-28 17:28:22 +01:00
Antoine Paris
d725e8e385 Add Oz to languages.yml 2014-11-28 17:16:32 +01:00
Brandon Keepers
034cb25099 Refactor heuristics 2014-11-28 09:43:59 -06:00
Brandon Keepers
fbc0947420 Not going back 2014-11-28 08:14:30 -06:00
Brandon Keepers
9020d7c044 Deprecate find_by_shebang
This class doesn’t need to know about shebangs.
2014-11-27 13:18:51 -05:00
Brandon Keepers
ffe2ccf1f6 Don't bother creating an instance 2014-11-27 13:17:28 -05:00
Brandon Keepers
434ab9f2c0 Add tests for shebangs 2014-11-27 13:09:05 -05:00
Brandon Keepers
cd3defda42 Simplify shebang detection 2014-11-27 12:44:55 -05:00
Brandon Keepers
fd85f7f112 consolidate shebang logic 2014-11-27 12:18:23 -05:00
Brandon Keepers
e42ccf0d82 docs 2014-11-27 11:40:48 -05:00
Brandon Keepers
bf4baff363 Move call method into existing Classifier class 2014-11-27 11:29:38 -05:00
Brandon Keepers
c1a9737313 Try strategies until one language is returned 2014-11-27 11:12:47 -05:00
Brandon Keepers
a4081498f8 Remove unneded empty blob check 2014-11-27 10:55:03 -05:00
Brandon Keepers
9efd923382 Merge remote-tracking branch 'origin/master' into strategies
* origin/master: (165 commits)
  Add F# and GLSL samples.  Add Forth and GLSL extension .fs. Add heuristic to disambiguate between F#, Forth, and GLSL.
  byebug requires ruby 2.0
  Remove test for removed extension
  Fix typo in test
  add rake interpreter
  add python3 interpreter
  Remove old wrong_shebang.rb sample
  Add byebug
  Link to Lightshow in CONTRIBUTING.md
  Switch to a better F# grammar
  Bump Rugged again
  Checkout the master for testing
  Rugged 0.22.0b3
  Reordering
  Bump version to 4.0.3
  Add some docs for tm_scope
  Change NONE to none
  Checking other case for Chart.jS
  Test that all languages have grammars
  Fix RHTML's tm_scope
  ...

Conflicts:
	lib/linguist/language.rb
2014-11-27 10:52:44 -05:00
Arfon Smith
b16149d641 Merge pull request #1758 from larsbrinkhoff/fsharp-glsl
Disambiguate .fs between F#, Forth, and GLSL
2014-11-27 07:41:14 -06:00
Lars Brinkhoff
2d940e72c2 Add F# and GLSL samples. Add Forth and GLSL extension .fs.
Add heuristic to disambiguate between F#, Forth, and GLSL.
2014-11-27 06:56:26 +01:00
Brandon Keepers
9f103abfb5 Merge pull request #1750 from github/interpreters-in-samples
Fix for interpreters from samples
2014-11-26 16:51:08 -05:00
Brandon Keepers
689a209ed9 Merge remote-tracking branch 'origin/master' into interpreters-in-samples
* origin/master:
  byebug requires ruby 2.0
  Remove test for removed extension
  Merge branch 'master' into 1233-local
  Removing pry runtime dependency
  Moving to fixtures
  Language detection test for non-sample files
  Refactoring of Language.detect
  Try shebang detection if the extension is unknown
  Change unknown extension of PHP sample file
2014-11-26 16:25:15 -05:00
Brandon Keepers
d91a451fc7 Merge pull request #1776 from github/fix-failures
Fix failure from #1731
2014-11-26 16:24:25 -05:00
Brandon Keepers
1ae4672230 byebug requires ruby 2.0 2014-11-26 16:12:43 -05:00
Brandon Keepers
3edf5fd770 Remove test for removed extension
This existed when the test was written, but was removed in https://github.com/github/linguist/pull/1734 and the test got lost in a merge somewhere.
2014-11-26 15:59:16 -05:00
Arfon Smith
412af86cb8 Merge pull request #1538 from github/1233-local
Detection based on the shebang (updated)
2014-11-26 14:47:12 -06:00
Brandon Keepers
5b41ab4774 Fix typo in test 2014-11-26 15:40:51 -05:00
Brandon Keepers
06c0cb916b add rake interpreter 2014-11-26 15:40:40 -05:00
Brandon Keepers
b3a49ce627 add python3 interpreter 2014-11-26 15:40:33 -05:00
Brandon Keepers
0651568bfb Remove old wrong_shebang.rb sample
This was added in a69118bd17, but that test has since been removed.
2014-11-26 15:34:03 -05:00
Brandon Keepers
ce31e23006 Merge remote-tracking branch 'origin/master' into interpreters-in-samples
* origin/master: (30 commits)
  Add byebug
  Link to Lightshow in CONTRIBUTING.md
  Switch to a better F# grammar
  Bump Rugged again
  Checkout the master for testing
  Rugged 0.22.0b3
  Reordering
  Bump version to 4.0.3
  Add some docs for tm_scope
  Change NONE to none
  Checking other case for Chart.jS
  Test that all languages have grammars
  Fix RHTML's tm_scope
  Chart JS is vendored
  Switch to a better grammar for Bro
  reorder again…
  put cjsx at the top
  Use a SQF grammar for SQF files
  move cjsx before iced
  move cjsx before iced
  ...

Conflicts:
	lib/linguist/languages.yml
2014-11-26 15:17:08 -05:00
Brandon Keepers
7ccd8caf71 Merge pull request #1774 from github/byebug
Add byebug
2014-11-26 15:16:06 -05:00
Brandon Keepers
598a7028ea Add byebug 2014-11-26 15:12:55 -05:00
Brandon Keepers
4ed1efe9ce Merge pull request #1741 from github/test-helper
Add test helper to make test env consistent
2014-11-26 15:10:24 -05:00
Brandon Keepers
6a4bf3fa65 Merge pull request #1731 from github/multiple-ext-segments
Support for multiple file extension segments
2014-11-26 15:09:15 -05:00
Brandon Keepers
5b2b3a2b53 Merge remote-tracking branch 'origin/master' into test-helper
* origin/master: (31 commits)
  Link to Lightshow in CONTRIBUTING.md
  Switch to a better F# grammar
  Bump Rugged again
  Checkout the master for testing
  Rugged 0.22.0b3
  Reordering
  Bump version to 4.0.3
  Add some docs for tm_scope
  Change NONE to none
  Checking other case for Chart.jS
  Test that all languages have grammars
  Fix RHTML's tm_scope
  Chart JS is vendored
  Switch to a better grammar for Bro
  reorder again…
  put cjsx at the top
  Use a SQF grammar for SQF files
  move cjsx before iced
  move cjsx before iced
  change component name
  ...

Conflicts:
	test/test_language.rb
2014-11-26 15:07:27 -05:00
Adam Roben
596cd9368f Merge pull request #1773 from github/introduce-lightshow
Link to Lightshow in CONTRIBUTING.md
2014-11-26 11:44:05 -05:00
Adam Roben
f8d50faedb Link to Lightshow in CONTRIBUTING.md
This is a tool for testing grammars with GitHub's syntax highlighter.
2014-11-26 11:21:05 -05:00
Adam Roben
ccc9c197ae Merge pull request #1771 from github/better-fsharp-grammar
Switch to a better F# grammar
2014-11-26 09:35:55 -05:00
Adam Roben
ed2dcc35e8 Switch to a better F# grammar
This fixes many bugs with F# highlighting, and the grammar is being
actively developed and maintained by the fsharp organization on GitHub.
2014-11-26 08:56:02 -05:00
Paul Chaignon
c5a654e692 Tests for Python multiline comments during tokenization 2014-11-25 20:01:24 -05:00
Paul Chaignon
3ac69ed4e0 Merge branch 'master' into pythonmultiline 2014-11-25 19:53:40 -05:00
Arfon Smith
208a3ff480 Merge branch 'master' into 1233-local
Conflicts:
	lib/linguist/language.rb
2014-11-25 17:04:43 -06:00
Paul Chaignon
6739a1471b Remove samples.json following merge with master 2014-11-25 15:46:51 -05:00
Paul Chaignon
230d91ecd8 Merge branch 'master' into saltstack-states 2014-11-25 15:41:25 -05:00
Arfon Smith
8de2cd15ed Merge branch 'master' into 1036-local
Conflicts:
	lib/linguist/heuristics.rb
	lib/linguist/languages.yml
	test/test_heuristics.rb
2014-11-25 13:06:11 -06:00
Garen Torikian
4603f3b2e7 Update languages.yml to always include ace_mode 2014-11-24 11:38:51 -08:00
Garen Torikian
9d6b8b4715 Add test for catching missing ace_mode values 2014-11-24 10:58:13 -08:00
Brandon Keepers
7cbc4bc144 Merge pull request #1751 from roodboi/master
add .cjsx extension for Facebook’s JSX in coffescript
2014-11-24 11:30:04 -05:00
Vicent Marti
d239e71826 Merge pull request #1765 from github/vmg/rugged-22b3
Rugged 0.22.0b3
2014-11-24 13:37:09 +01:00
Vicent Marti
ecaa2a41c9 Bump Rugged again 2014-11-24 13:32:37 +01:00
Vicent Marti
fc71805489 Checkout the master for testing 2014-11-24 13:25:49 +01:00
Vicent Marti
74d94781cb Rugged 0.22.0b3 2014-11-24 13:05:42 +01:00
Garen Torikian
897c2c5ab6 Add missing ace_mode values wherever necessary 2014-11-23 21:16:21 -08:00
Arfon Smith
b556425037 Reordering 2014-11-21 13:10:45 -06:00
Arfon Smith
6131d17c02 Merge pull request #1748 from mrego/xht-extension
Add support for .xht extension which is used in some XHTML files
2014-11-21 12:48:58 -06:00
Adam Roben
875b3157bf Merge pull request #1757 from github/cut-release-v4.0.3
Bump version to 4.0.3
2014-11-21 12:06:38 -05:00
Adam Roben
4ce9048f8d Bump version to 4.0.3 2014-11-21 11:56:17 -05:00
Adam Roben
04f1b1df48 Merge pull request #1756 from github/test-for-grammars
Test that all languages have grammars
2014-11-21 11:54:46 -05:00
Adam Roben
f9c36345c3 Add some docs for tm_scope 2014-11-21 11:53:52 -05:00
Adam Roben
ec3967d080 Change NONE to none
NONE is a little shouty.
2014-11-21 11:52:29 -05:00
Arfon Smith
05a88b5b7e Merge pull request #1754 from github/chart-js
Chart js
2014-11-21 09:30:20 -06:00
Arfon Smith
b6b2cf04a7 Checking other case for Chart.jS 2014-11-21 09:29:28 -06:00
Adam Roben
49247e9ec2 Test that all languages have grammars
This will make CI fail if someone adds a new language but neglects to
add a new grammar for it. This should make it easier for people to
review PRs, as CI will help them to make sure a new grammar gets added.

However, we currently support some languages that have no grammars, and
we may support more in the future. So you can explicitly mark the
language as having no grammar by setting `tm_scope: NONE` in
languages.yml.
2014-11-21 09:48:52 -05:00
Adam Roben
6629b75aa6 Merge pull request #1755 from github/fix-rhtml-scope
Fix RHTML's tm_scope
2014-11-21 09:31:07 -05:00
Adam Roben
e702b453ec Fix RHTML's tm_scope
I missed this back in 9595e2ba7e.
2014-11-21 09:29:06 -05:00
Arfon Smith
38190d92fc Chart JS is vendored 2014-11-21 08:24:33 -06:00
Adam Roben
109ca5735b Merge pull request #1753 from github/better-bro-grammar
Switch to a better grammar for Bro
2014-11-21 09:23:28 -05:00
Adam Roben
4dde499f51 Switch to a better grammar for Bro
This grammar seems to be replacing the other ones out there and is
maintained by the Bro organization.
2014-11-21 09:17:19 -05:00
Vicent Marti
5fd18a215e Merge pull request #1752 from github/sqf-grammar
Use a SQF grammar for SQF files
2014-11-21 11:31:50 +01:00
Dimitri Kennedy
b283548c0f reorder again… 2014-11-20 18:36:08 -05:00
Dimitri Kennedy
2352ce77c9 put cjsx at the top 2014-11-20 17:38:38 -05:00
Adam Roben
2054afc741 Use a SQF grammar for SQF files
This produces better highlighting than using the C++ grammar.

The grammar is licensed under the Apache 2.0 license.
2014-11-20 17:22:55 -05:00
Dimitri Kennedy
9d3b9964b5 move cjsx before iced 2014-11-20 17:08:21 -05:00
Dimitri Kennedy
79c1d21a0f move cjsx before iced 2014-11-20 17:08:10 -05:00
Dimitri Kennedy
1d69228872 change component name 2014-11-20 16:49:48 -05:00
Dimitri Kennedy
f5953a09da add example cjsx file 2014-11-20 16:48:22 -05:00
Dimitri Kennedy
a17f6c8ae1 add .cjsx extension for Facebook’s JSX in coffescript 2014-11-20 14:56:09 -05:00
Max Horn
f9ad5dda56 Add heuristic distinguishing GAP and Scilab .tst files 2014-11-20 12:52:13 -07:00
Max Horn
ff6a10698e Pass name of file being analyzed to find_by_heuristics
Some languages are sensitive to file names in the sense that
different kinds of files contain somewhat different data.
Example: GAP .tst files contain test cases, which add some
extra data compared to regular code, and as a consequence are
not directly interchangeable with regular source code.

Heuristics may need to take this into account, thus may need
to know the name of the file being analyzed.
2014-11-20 12:48:28 -07:00
Max Horn
6072a63f99 Add GAP .tst extension plus two sample files 2014-11-20 12:47:15 -07:00
Max Horn
1bd935b2b4 Set 'lexer: GAP' for GAP
My Pygments patch adding support for GAP was merged in April, and I
verified that it is live on GitHub.
2014-11-20 12:47:15 -07:00
Brandon Keepers
9823af0cb4 Fix for shebang with relative bin
`#!/usr/bin/env bin/linguist` is a valid shebang
2014-11-20 12:50:35 -05:00
Brandon Keepers
45384bd498 More missing interpreters 2014-11-20 12:29:16 -05:00
Brandon Keepers
56bfde998b Only strip minor version off of interpreters
This used to turn `python2.4` into `python`, which causes trouble with
`perl6`, which is a different language definition.
2014-11-20 12:28:30 -05:00
Brandon Keepers
870feb8592 Add missing interpreters 2014-11-20 11:27:54 -05:00
Brandon Keepers
2670e2b035 Test that interpreters are defined in languages.yml 2014-11-20 11:21:52 -05:00
Brandon Keepers
eccea65641 Fix for interpreters not getting add to samples.json 2014-11-20 11:14:05 -05:00
Brandon Keepers
231ad86176 sync cached gems 2014-11-20 08:51:56 -05:00
Florian Kaiser
9658b02502 add Chart.js as vendor
http://www.chartjs.org
2014-11-20 10:02:45 +01:00
Manuel Rego Casasnovas
30c6b6e5a1 Add XHTML example file 2014-11-20 00:30:21 +01:00
Manuel Rego Casasnovas
b44e58dd7f Add support for .xht extension which is used in some XHTML files 2014-11-19 23:08:51 +01:00
Vicent Marti
bce31e8b51 Merge pull request #1747 from github/cut-release-v4.0.2
Cut release v4.0.2
2014-11-19 18:12:07 +01:00
Adam Roben
011c654c2a Bump version to v4.0.2 2014-11-19 12:08:49 -05:00
Adam Roben
2457b52658 Update grammars.yml 2014-11-19 12:08:43 -05:00
Arfon Smith
a3adaa6a7b Merge pull request #1745 from github/f-case
Fix failures on case-insensitive filesystem
2014-11-19 07:04:58 -06:00
Brandon Keepers
a6f168d1ac Rename file to avoid case-insensitive collision 2014-11-18 23:22:10 -05:00
Arfon Smith
f792029a20 Merge pull request #1743 from github/codemirror
Codemirror should be considered vendored
2014-11-18 20:02:12 -06:00
Arfon Smith
2a5dd5b224 Adding test for codemirror 2014-11-18 19:34:41 -06:00
Martín Gaitán
fb7dcfd62d Exclude codemirror
An example of a wrong detection due to codemirror is my project.  https://github.com/mgaitan/waliki
2014-11-18 20:17:15 -03:00
Brandon Keepers
245a1a92cf Merge remote-tracking branch 'origin/master' into test-helper
* origin/master:
  Add Gemfile.lock sample
  Remove deprecated method
  #all_extensions already includes primary extension
  typo
  remove unused assertion
  Symlink ant.xml to build.xml
  Avoid shadowing variable name
  Update comment
  Make missing sample failure message similar
  Remove blank extensions property
  Fix sample tests
  Add Forth extensions .f and .for; add heuristics for Forth and FORTRAN.
  Add FORTRAN and Forth samples.
  Extensions aren't actually required
  Fix errors from pedantic test
  Make pedantic test actually pedantic
  Removing extensions when they should be filenames
  Adding sample pom.xml files
  Link to contributing docs
  require samples if filename matches multiple languages

Conflicts:
	test/test_pedantic.rb
2014-11-18 16:48:26 -05:00
Brandon Keepers
aa7ab2065b Add test helper to make test env consistent 2014-11-18 16:46:09 -05:00
Brandon Keepers
719f6e876b Merge pull request #1732 from github/filename-matches-multiple-langages
Require samples if filename matches multiple languages
2014-11-18 16:31:19 -05:00
Brandon Keepers
8724dc8ccc Merge pull request #889 from larsbrinkhoff/fortran
FIX: .f misidentified as Fortran
2014-11-18 16:05:23 -05:00
Brandon Keepers
63f9d0bdeb Add Gemfile.lock sample
Gemfile.lock should not actually get classified as Ruby, but we can fix that in another PR.
2014-11-18 15:36:42 -05:00
Brandon Keepers
d7fd12cb32 Remove deprecated method 2014-11-18 15:19:23 -05:00
Brandon Keepers
850ab6dedb #all_extensions already includes primary extension 2014-11-18 15:10:07 -05:00
Brandon Keepers
b20fa497b9 typo 2014-11-18 15:07:36 -05:00
Brandon Keepers
1abc7ee2ef remove unused assertion 2014-11-18 15:04:12 -05:00
Brandon Keepers
d7a032afcd Symlink ant.xml to build.xml
We require samples for explicitly defined filenames that matches multiple languages. This is generally a good thing, but in this case they will be identical.
2014-11-18 15:02:59 -05:00
Brandon Keepers
587c764950 Avoid shadowing variable name 2014-11-18 14:57:39 -05:00
Brandon Keepers
1abbcb6435 Update comment 2014-11-18 14:57:32 -05:00
Brandon Keepers
17f3d7005a Make missing sample failure message similar 2014-11-18 14:55:15 -05:00
Brandon Keepers
ac59620728 Remove blank extensions property 2014-11-18 14:48:43 -05:00
Brandon Keepers
ba8b55391d Fix sample tests 2014-11-18 14:48:21 -05:00
Lars Brinkhoff
03c1e725ce Add Forth extensions .f and .for; add heuristics for Forth and FORTRAN. 2014-11-18 20:21:19 +01:00
Lars Brinkhoff
4cefaf2808 Add FORTRAN and Forth samples. 2014-11-18 20:12:39 +01:00
Brandon Keepers
757801e32f Merge remote-tracking branch 'origin/master' into filename-matches-multiple-langages
* origin/master:
  Allow mime-types 2.x to be used with Linguist
  Upgrade to rugged 0.22.0b1
  Mention that languages need to be quite popular
  fix vendor/cache
  Gemfile.lock is nolonger considered generated
  Tests for BlobHelper#empty?
  remove reference to empty.js
  Remove more empty samples
  Bail earlier if the file is empty.
  Moving comments
  Use heuristics earlier to inform the rest of the classification process
  Removing inconsistency of `find_by_heuristics` (was sometimes returning nil and sometimes returning and empty array)
  Removing unused array of candidate languages.
  Reworking most heuristics to only return one match
2014-11-18 14:09:15 -05:00
Brandon Keepers
749ea2a580 Merge pull request #1734 from github/just-filenames
Removing extensions when they should be filenames
2014-11-18 14:01:57 -05:00
Adam Roben
dc373fb51f Merge pull request #1737 from github/relax-mime-types
Allow mime-types 2.x to be used with Linguist
2014-11-18 11:47:35 -05:00
Arfon Smith
0443c4db2d Merge pull request #1674 from github/rework-heuristics
Rework heuristics
2014-11-18 10:43:01 -06:00
Adam Roben
d699ba3a98 Allow mime-types 2.x to be used with Linguist
The API is compatible for our purposes, and this allows Linguist to be
used in apps that pull in newer versions of mime-types through other
gems.
2014-11-18 10:46:04 -05:00
Adam Roben
92d2782ceb Merge pull request #1738 from github/update-rugged
Upgrade to rugged 0.22.0b1
2014-11-18 10:45:38 -05:00
Adam Roben
e76ebb1a74 Upgrade to rugged 0.22.0b1
0.21.2 was just released but doesn't contain the Repository::Attributes
code we depend on. 0.22.0b1 has this code.
2014-11-18 10:40:37 -05:00
Arfon Smith
cacde403c0 Merge pull request #1736 from github/aroben-patch-1
Mention that languages need to be quite popular
2014-11-18 08:07:51 -06:00
Adam Roben
906b0ee30e Mention that languages need to be quite popular
The precedent seems to be "hundreds of repos".
2014-11-18 08:48:00 -05:00
Brandon Keepers
cd7549390e Extensions aren't actually required 2014-11-17 20:00:09 -05:00
Brandon Keepers
f30cab30f4 fix vendor/cache 2014-11-17 19:42:22 -05:00
Paul Chaignon
1356d4e579 Remove heuristic rules for .mm files 2014-11-17 19:20:45 -05:00
Brandon Keepers
63c83d014b Fix errors from pedantic test 2014-11-17 18:53:14 -05:00
Brandon Keepers
b8e426d3a3 Make pedantic test actually pedantic
What do you call someone that thinks they are pedantic but actually
aren’t? All the crazy custom parsing in this test was making so it
wasn’t actually doing anything.
2014-11-17 18:52:53 -05:00
Arfon Smith
c5344da2ba Removing extensions when they should be filenames 2014-11-17 16:44:39 -06:00
Arfon Smith
7606a70bb8 Merge pull request #1733 from github/gemfile-lock-not-generated
Gemfile.lock is nolonger considered generated
2014-11-17 16:35:07 -06:00
Arfon Smith
7d850d7c09 Gemfile.lock is nolonger considered generated 2014-11-17 16:31:47 -06:00
Arfon Smith
c1b704075e Adding sample pom.xml files 2014-11-17 16:25:03 -06:00
Brandon Keepers
07a6411a75 Link to contributing docs 2014-11-17 16:30:39 -05:00
Brandon Keepers
b32bc5ef47 require samples if filename matches multiple languages 2014-11-17 16:18:56 -05:00
Brandon Keepers
6c106b88c0 Avoid using singular #extension 2014-11-17 15:47:21 -05:00
Adam Roben
f2c9581bac Merge pull request #1730 from github/more-docs
Add CONTRIBUTING.md
2014-11-17 15:28:32 -05:00
Brandon Keepers
c46667581d Use the first extension with languages defined 2014-11-17 15:15:39 -05:00
Adam Roben
59e5ba351c Mention that grammars should be licensed 2014-11-17 15:14:36 -05:00
Adam Roben
a8a710f863 Add a link to CONTRIBUTING.md from the README 2014-11-17 15:10:09 -05:00
Adam Roben
f603b731a9 Add CONTRIBUTING.md
This document tries to explain how to file various common kinds of bug
reports or enhancements.
2014-11-17 15:05:33 -05:00
Brandon Keepers
3ca872cea8 Support for multiple file extension segments 2014-11-17 14:54:22 -05:00
Adam Roben
970953ca12 Merge pull request #1727 from pchaigno/lexer-inform7
Lexer for Inform 7
2014-11-17 14:45:46 -05:00
Vicent Marti
7cf6372519 Version 4.0.1 2014-11-17 18:09:26 +01:00
Paul Chaignon
1d381233e0 Update tm_scope to match case used in Sublime-Inform 2014-11-17 11:19:23 -05:00
Paul Chaignon
6f0c24b90b Remove grammar for Inform 6 2014-11-17 10:56:38 -05:00
Brandon Keepers
f29c172267 Merge pull request #1726 from github/makefile-tests
Fix tests for Makefile change
2014-11-17 10:52:39 -05:00
Paul Chaignon
e9c5598254 Add lexer for Inform 7 using download-grammars script 2014-11-17 10:50:03 -05:00
Adam Roben
dd5728a441 Merge pull request #1728 from github/new-pike-url
Update the URL for the source.pike grammar
2014-11-17 10:45:48 -05:00
Adam Roben
ec1d77c32e Update the URL for the source.pike grammar
It's now hosted on GitHub and has a clearer license.
2014-11-17 10:43:36 -05:00
Paul Chaignon
40887930f9 Lexer for Inform 7 2014-11-17 09:41:35 -05:00
Brandon Keepers
6bf8243014 Fix tests for Makefile change 2014-11-17 08:15:17 -05:00
Brandon Keepers
419805ce9f Merge pull request #1724 from pchaigno/make-type
Programming type for Makefile
2014-11-16 23:17:30 -05:00
Paul Chaignon
81089416a2 Makefile set to programming type 2014-11-16 23:13:31 -05:00
Vicent Marti
efc7799960 Clojure grammar from Atom 2014-11-16 18:29:58 +01:00
Joseph Hall
7702583314 Python also supports triple single-quotes for comments 2014-11-16 07:19:55 -07:00
Vicent Marti
fcbef97e39 Typo in README 2014-11-16 14:42:56 +01:00
Vicent Marti
8beef260da Merge pull request #1722 from github/vmg/grammar-fixes
Misc. grammar fixes
2014-11-16 14:41:40 +01:00
Vicent Marti
618a5b62ee Revert the changes in download-grammars 2014-11-16 14:40:48 +01:00
Vicent Marti
c579924485 DOCS 2014-11-16 14:25:11 +01:00
Vicent Marti
9b9fadfa19 Use a Racket grammar for Racket 2014-11-16 13:47:19 +01:00
Vicent Marti
daf64010f9 Merge pull request #1714 from github/vmg/new-languages
Some new TM powered languages
2014-11-14 20:24:21 +01:00
Vicent Marti
f0bd24f810 DOT was already a thing 2014-11-14 19:20:47 +01:00
Vicent Marti
5969a8b679 More samples 2014-11-14 19:18:43 +01:00
Vicent Marti
6b3ba29558 Reindent 2014-11-14 19:11:11 +01:00
Vicent Marti
f217047ac0 Rename 2014-11-14 19:06:41 +01:00
Vicent Marti
935c852364 Add Dockerfile sample 2014-11-14 19:05:42 +01:00
Vicent Marti
9e28965259 Rename Dockerfile 2014-11-14 19:04:11 +01:00
Vicent Marti
a829f3143a Add DOT sample 2014-11-14 19:04:06 +01:00
Vicent Marti
3fc01d09ce Hah Parrot was already a thing 2014-11-14 19:00:21 +01:00
Vicent Marti
a4ae90e2e9 Add Thrift 2014-11-14 18:58:30 +01:00
Vicent Marti
4928828874 Add Ninja 2014-11-14 18:56:34 +01:00
Vicent Marti
af90ac3758 add Maven buildfiles 2014-11-14 18:54:27 +01:00
Vicent Marti
d4e6798ba8 add Graphviz 2014-11-14 18:48:19 +01:00
Vicent Marti
03b250990d Add Cap'n Proto 2014-11-14 18:46:16 +01:00
Vicent Marti
5bc0ce0888 Add Bison 2014-11-14 18:44:12 +01:00
Vicent Marti
a0bbf7df6f Add Ant 2014-11-14 18:41:36 +01:00
Vicent Marti
6b90f22cef Add Parrot IR 2014-11-14 18:37:54 +01:00
Vicent Marti
d290576543 Add Docker Files as a language 2014-11-14 18:16:51 +01:00
Vicent Marti
75871e52ea Merge pull request #1707 from github/vmg/lol-pygments
Remove the Pygments dependency
2014-11-14 17:39:51 +01:00
Vicent Marti
b40459335b ...actually... This is 4.0.0 because of breaking changes 2014-11-14 17:38:39 +01:00
Vicent Marti
51b16ca965 oops 2014-11-14 17:37:12 +01:00
Vicent Marti
5dafa937de Remove lexers from languages.yml 2014-11-14 17:37:12 +01:00
Vicent Marti
2307c2e9fc Bump version to 3.6.0 2014-11-14 17:37:12 +01:00
Vicent Marti
d12aff9776 Unused test 2014-11-14 17:37:12 +01:00
Vicent Marti
fcd26da282 Remove outdated gems 2014-11-14 17:37:12 +01:00
Vicent Marti
4a10b27611 Remove Pygments 2014-11-14 17:37:12 +01:00
Vicent Marti
201fe54b0c Merge pull request #1710 from github/grammars
Add github-linguist-grammars gem
2014-11-14 16:12:22 +01:00
Adam Roben
1618a3b02a Use the original Kotlin package instead of a fork
The fork is identical to the original.
2014-11-13 14:26:06 -05:00
Adam Roben
3be97ccaa3 Update SCSS bundle location
The old URL redirects to this one.
2014-11-13 14:24:47 -05:00
Adam Roben
879e4977e4 Handle includes like source.c#block 2014-11-13 13:45:02 -05:00
Adam Roben
613b71719f Add back some accidentally pruned grammars
A bug in the prune-grammars script caused these to be removed.
2014-11-13 13:42:36 -05:00
Adam Roben
2870f6d038 Prune unused grammars
script/prune-grammars will remove any grammars that aren't needed from
grammars.yml.
2014-11-13 13:16:24 -05:00
Adam Roben
046fb18980 Add github-linguist-grammars gem
The purpose of this gem is to package up the language grammars that are
used for syntax highlighting on github.com. The grammars are TextMate,
Sublime Text, or Atom language grammars, converted to JSON and given the
filename SCOPE.json, where SCOPE is the language scope that the grammar
defines.

The github-linguist-grammars gem packages up all the grammars, and also
exports a Linguist::Grammars.path method to locate the directory
containing the grammars.

To build the gem, simply run `rake build_grammars_gem`. The grammars.yml
file lists all the repositories we download grammars from, as well as
which scopes are defined by each repository. The
script/download-grammars script takes that list and downloads and
processes the grammars into the format expected by the gem.
2014-11-13 11:03:53 -05:00
Brandon Keepers
d133d9eccb Merge pull request #1709 from github/emacs-lisp-assertion
Add assertion for Emacs Lisp
2014-11-13 10:47:52 -05:00
Brandon Keepers
296473507f Add assert for Emacs lisp
/cc https://github.com/github/linguist/pull/1499
2014-11-13 10:40:58 -05:00
Adam Roben
ff8821080a Merge pull request #1708 from github/fortran-modern
Use source.fortran.modern TM scope for FORTRAN
2014-11-13 09:53:33 -05:00
Adam Roben
9acf41b0fe Use source.fortran.modern TM scope for FORTRAN
This is technically only for FORTRAN 90 and newer, but seems to do just fine with older variants.
2014-11-13 09:52:08 -05:00
Paul Chaignon
9c64f72f35 Add .mm as an XML extension with heuristic rule 2014-11-12 19:38:54 -05:00
Adam Roben
9385e70d2d Merge pull request #1705 from github/cut-release-v3.5.2
Bump to version v3.5.2
2014-11-12 13:51:59 -05:00
Adam Roben
9469e188c8 Bump to version v3.5.2 2014-11-12 13:39:05 -05:00
Vicent Marti
6e57ca6fbc Update the TM scope for the Zephir language 2014-11-12 18:19:10 +01:00
Adam Roben
d5e3ebaef3 Merge pull request #1704 from github/gas-tmscope
Add a tm_scope for GAS
2014-11-12 12:08:14 -05:00
Adam Roben
a9eac8a832 Add a tm_scope for GAS
The source.asm.x86 grammar does a decent job of parsing this.
2014-11-12 12:07:23 -05:00
Adam Roben
1c7f5368cf Merge pull request #1703 from github/less-tmscope
Fix the tm_scope for Less
2014-11-12 11:45:01 -05:00
Adam Roben
960ff73c7f Fix the tm_scope for Less
The source.css.less grammar actually understands Less syntax.
2014-11-12 11:43:52 -05:00
Sebastian Godelet
95777055d1 languages.yml: added an interpreter entry to Mercury section 2014-11-11 23:28:07 +08:00
Brandon Keepers
e1ce30c3ce Merge pull request #1653 from baroquebobcat/patch-1
add pants BUILD file highlighting to languages.yml
2014-11-11 01:39:55 -05:00
Brandon Keepers
89b442c751 Merge pull request #1657 from techniq/patch-1
Add .NET config files as XML
2014-11-11 01:39:19 -05:00
Adam Roben
6b41059cdf Merge pull request #1696 from github/cut-release-v3.5.1
Bump to 3.5.1
2014-11-10 15:19:28 -05:00
Adam Roben
62cb42eee5 Bump to 3.5.1 2014-11-10 15:15:15 -05:00
Adam Roben
6bbb56db00 Merge pull request #1695 from github/nil-safety
Make it safe to pass nil to Language.find_by_name/alias again
2014-11-10 15:13:28 -05:00
Adam Roben
160598b9ef Make it safe to pass nil to Language.find_by_name/alias again
This restores compatibility with v3.4.x.
2014-11-10 15:12:29 -05:00
Adam Roben
32b07a4e10 Merge pull request #1694 from github/cut-release-v3.5.0
Bumping to 3.5.0
2014-11-10 14:52:55 -05:00
Adam Roben
8890c57681 Bumping to 3.5.0 2014-11-10 14:38:55 -05:00
Adam Roben
de188126fb Merge pull request #1683 from github/find-by-ext
Extract Language.find_by_extension
2014-11-10 14:37:45 -05:00
Adam Roben
97a1adcef1 Allow extensions without a leading dot
This makes the API a little easier to use.
2014-11-10 14:30:37 -05:00
Adam Roben
ffbe95d6e5 Fix docs 2014-11-10 14:15:21 -05:00
Adam Roben
d54f86ae58 Add some tests for Language.find_by_extension 2014-11-10 14:12:29 -05:00
Brandon Keepers
92ace440b9 Merge pull request #1540 from rlespinasse/golo-support
Add support for Golo language
2014-11-08 14:00:36 -05:00
Adam Roben
d5ee477d3b Merge pull request #1687 from github/shell-session-scope
Add a TextMate scope for .sh-session files
2014-11-07 15:47:35 -05:00
Adam Roben
6e8152c423 Add a TextMate scope for .sh-session files
Coming soon to Atom. See https://github.com/atom/language-shellscript/pull/3
2014-11-07 15:02:37 -05:00
Adam Roben
8149356668 Merge pull request #1678 from tenbits/master
Use MaskLexer for *.mask
2014-11-07 13:39:24 -05:00
Alex Kit
806e30d70f Use MaskLexer for *.mask 2014-11-07 19:26:37 +01:00
Adam Roben
299ec8f8ea Merge pull request #1686 from github/pytb-tm_scope
Add a TextMate scope for .pytb files
2014-11-07 12:57:36 -05:00
Adam Roben
f6fbd18bd5 Add a TextMate scope for .pytb files
This is the scope that Atom uses for these files.
See https://github.com/atom/language-python/blob/master/grammars/python-traceback.cson
2014-11-07 12:55:59 -05:00
Adam Roben
ecd30d3ccf Merge pull request #1675 from github/more-aliases
Pull in aliases and file extensions from Pygments
2014-11-07 10:31:00 -05:00
Brandon Keepers
228d89649a Add Language.find_by_extension 2014-11-07 10:27:07 -05:00
Adam Roben
751360ecf1 Make Language.[] and Language.find_by(alias|name) ignore case
This makes it easier to find a Linguist::Language for a fenced code
block in Markdown, where language names are often specified in
lowercase.
2014-11-07 10:09:55 -05:00
Adam Roben
d9ed216092 Add language aliases from Pygments
I went through all the aliases Pygments supports and removed the ones
that could already be used to find a Linguist::Language. Then I found
the Pygments::Lexer associated with each alias and found an associated
Linguist::Language for it (looking for a language with the same name as
the lexer, or by looking for the first langauge that uses that lexer).
Then I added the alias to the language's alias list.
2014-11-06 16:48:52 -05:00
Adam Roben
18a3ef9e5e Pull in file extensions from Pygments
I read all the file extensions that Pygments knows about, mapped them
back to the appropriate Linguist::Language, and added them to the
languages.yaml file.
2014-11-06 16:43:08 -05:00
Brandon Keepers
33d75d9623 Tests for BlobHelper#empty? 2014-11-06 15:14:03 -06:00
Brandon Keepers
a0cc2c4c86 remove reference to empty.js 2014-11-06 14:59:34 -06:00
Brandon Keepers
754bc4ef6d Remove more empty samples 2014-11-06 14:56:19 -06:00
Brandon Keepers
df55043500 Bail earlier if the file is empty.
This will change behavior for empty files with unique extensions, returning nil instead of the language.
2014-11-06 14:49:24 -06:00
Arfon Smith
f22524a615 Moving comments 2014-11-06 14:27:49 -06:00
Arfon Smith
1831390429 Use heuristics earlier to inform the rest of the classification process 2014-11-06 14:09:19 -06:00
Arfon Smith
f4c7661cc6 Removing inconsistency of find_by_heuristics (was sometimes returning nil and sometimes returning and empty array) 2014-11-06 14:08:42 -06:00
Arfon Smith
0ab88919c9 Removing unused array of candidate languages. 2014-11-06 13:31:34 -06:00
Arfon Smith
9107d3c243 Reworking most heuristics to only return one match 2014-11-06 13:26:40 -06:00
Blake Embrey
42e9131b4f Add RAML support 2014-11-06 11:47:00 -06:00
Arfon Smith
e7b670c5de Merge pull request #1669 from github/support-hack
Support hack
2014-11-05 13:56:37 -06:00
Arfon Smith
114fabd29a Test for Hack heuristic 2014-11-04 16:12:46 -06:00
Arfon Smith
0946791434 Merge branch 'master' into support-hack
Conflicts:
	lib/linguist/heuristics.rb
2014-11-04 16:09:00 -06:00
Brandon Keepers
06bcdba9c4 Merge pull request #1654 from danijar/master
Exclude minified JavaScript and CSS
2014-11-03 14:20:59 -05:00
Nick Howard
729a174eb6 add pants BUILD file highlighting to languages.yml
the pants build tool uses python files named BUILD. This adds highlighting for them.
2014-11-03 12:11:14 -07:00
Danijar Hafner
1dbbcb73e7 Add tests for minified JavaScript and CSS
Also, exclude -min.css pattern, like already done for JavaScript files
2014-11-03 19:41:31 +01:00
Brandon Keepers
74fa4b9b75 docs 2014-11-03 08:54:11 -05:00
Sean Lynch
87df17309c Fix package.config to packages.config 2014-11-03 08:35:14 -05:00
Brandon Keepers
815337299a Extract empty blob strategy 2014-11-03 08:21:46 -05:00
Brandon Keepers
fd32938cd8 Extract strategies for detecting the language 2014-11-03 08:17:02 -05:00
Brandon Keepers
8d7b4f81b4 Extract filename strategy 2014-11-02 22:15:52 -05:00
Arfon Smith
f2cd75332c Merge pull request #1660 from github/1623-local
1623 local
2014-11-02 20:17:38 -06:00
Arfon Smith
2cd7579e21 Merge branch '1623-local' of github.com:github/linguist into 1623-local
Conflicts:
	lib/linguist/heuristics.rb
2014-11-02 20:14:46 -06:00
Arfon Smith
d9daae176e Merge branch 'master' into 1623-local
Conflicts:
	lib/linguist/heuristics.rb
2014-11-02 20:13:58 -06:00
Arfon Smith
20814ec533 Merge branch 'master' into 1623-local
Conflicts:
	lib/linguist/heuristics.rb
2014-11-02 20:12:59 -06:00
Arfon Smith
9d8ab16a38 Merge branch 'master' into 1623-local
Conflicts:
	lib/linguist/heuristics.rb
2014-11-02 20:11:49 -06:00
Arfon Smith
49c2793bf5 Syntax preference 2014-11-02 19:56:20 -06:00
Sean Lynch
b5cacbba9f Add .NET config files as XML 2014-11-02 10:13:52 -05:00
Danijar Hafner
20aee11cea Exclude minified JavaScript and CSS
Those files are either external libraries or builds of the repository itself. In any case they are generated automatically and shouldn't count in the language statistics. This also simplifies some of the rules that had to exclude both minified and normal dependencies.
2014-11-01 19:13:19 +01:00
Arfon Smith
2bc546eadf Merge branch 'master' into 1233-local
Conflicts:
	lib/linguist/language.rb
2014-11-01 10:05:45 -05:00
Arfon Smith
9e50e188a8 Merge branch 'master' into 1233-local
Conflicts:
	lib/linguist/language.rb
	lib/linguist/languages.yml
	lib/linguist/samples.json
2014-11-01 10:04:22 -05:00
Arfon Smith
e8cf750e18 Merge pull request #1639 from pchaigno/asc
Heuristic rule to detect AsciiDoc files
2014-11-01 09:26:49 -05:00
Arfon Smith
5ffc4c0158 Starting work on Disambiguate Matlab, Objective-C, Mathematica, M, and Mercury method 2014-10-31 17:22:32 -05:00
Brandon Keepers
21f56744d4 Merge pull request #1608 from github/just-yajl
Use yajl since it is already a dependency
2014-10-31 18:03:28 -04:00
Brandon Keepers
02aeb4f895 Merge remote-tracking branch 'origin/master' into just-yajl
* origin/master: (42 commits)
  its always greener
  that new green shell
  Removing stale extension
  Update README.md
  Add moon interpreter for MoonScript
  Bumping version for 3.4.1 release
  Use text.html.erb scope for HTML+ERB files
  Add sample .dyalog file for file type APL
  Added extra Papyrus sample files.
  Add sample Papyrus script
  Add Papyrus support
  Add LOLCODE support
  Add ProGuard config files to vendored files
  Recognise *.dyalog as APL sources
  Assign a bunch more TextMate scopes
  CI step for samples
  Add .command as a Shell file extension
  CI config
  Vendored gems
  Update cibuild
  ...

Conflicts:
	Rakefile
2014-10-31 18:03:03 -04:00
Arfon Smith
f9de16fbd2 Merge pull request #1620 from unfunco/ant-build-dist-support
Add build.xml.dist to XML filenames
2014-10-31 16:46:49 -05:00
Brandon Keepers
abe002f30c Merge remote-tracking branch 'origin/master' into tricknotes-ruby-22
* origin/master: (51 commits)
  its always greener
  that new green shell
  Removing stale extension
  Update README.md
  Add moon interpreter for MoonScript
  Bumping version for 3.4.1 release
  Use text.html.erb scope for HTML+ERB files
  Add sample .dyalog file for file type APL
  Added extra Papyrus sample files.
  Add sample Papyrus script
  Add Papyrus support
  Add LOLCODE support
  Add ProGuard config files to vendored files
  Recognise *.dyalog as APL sources
  Assign a bunch more TextMate scopes
  CI step for samples
  Add .command as a Shell file extension
  CI config
  Vendored gems
  Update cibuild
  ...

Conflicts:
	Gemfile
2014-10-31 17:36:06 -04:00
Jessica Lord
e5ae6fb00d Merge pull request #1650 from github/greenshell
That new green shell, fixes #1640
2014-10-31 21:16:34 +00:00
Jessica Lord
a0a8dd8897 its always greener 2014-10-31 21:15:59 +00:00
Jessica Lord
e00f073726 that new green shell 2014-10-31 20:08:25 +00:00
Arfon Smith
1a9ee8e187 Merge pull request #1636 from Verteiron/master
Add support for Papyrus scripts
2014-10-30 06:24:56 -05:00
Arfon Smith
0c05a6c3ac Merge branch 'master' into 1036-local 2014-10-29 20:06:40 -05:00
Arfon Smith
213fce00e0 Merge pull request #1646 from github/gradle-extension
Removing stale extension
2014-10-29 19:57:32 -05:00
Arfon Smith
380739b209 Removing stale extension 2014-10-29 19:56:59 -05:00
Arfon Smith
36322f8ac0 Update README.md 2014-10-29 19:38:19 -05:00
Arfon Smith
57d1ec7733 Merge pull request #1645 from pchaigno/moon-shebang
Add moon interpreter for MoonScript
2014-10-29 17:10:14 -05:00
Paul Chaignon
648c6d4547 Add moon interpreter for MoonScript 2014-10-29 15:00:21 -04:00
Arfon Smith
6ab5870b59 Merge pull request #1643 from github/linguist-3.4.1
Bumping version for 3.4.1 release
2014-10-29 13:34:41 -05:00
Arfon Smith
7dbe2bb774 Bumping version for 3.4.1 release 2014-10-29 13:13:26 -05:00
Adam Roben
163a039e0d Merge pull request #1641 from github/aroben-patch-1
Use text.html.erb scope for HTML+ERB files
2014-10-29 10:02:49 -04:00
Adam Roben
9595e2ba7e Use text.html.erb scope for HTML+ERB files
This grammar does a better job highlighting than the text.html.ruby grammar does. It requires injection grammar support, but there's no getting around that.
2014-10-29 10:00:09 -04:00
Arfon Smith
d4d6ef314d Merge branch 'master' into 1036-local 2014-10-28 19:14:43 -05:00
Arfon Smith
322b21e0d0 Updating regexes 2014-10-28 19:14:32 -05:00
Arfon Smith
a696e3a7a2 Merge pull request #1632 from ngn/master
Recognise *.dyalog as APL sources
2014-10-27 17:38:34 +00:00
Paul Chaignon
ebabcfc84f Heuristic rule to detect AsciiDoc files 2014-10-27 10:50:18 -04:00
ngn
8336dc33e4 Add sample .dyalog file for file type APL
Taken from
https://github.com/Gianfrancoalongi/APLUnit/blob/master/UT.dyalog
2014-10-27 10:35:23 +00:00
Verteiron
5f22bf225c Added extra Papyrus sample files. 2014-10-26 15:30:40 -05:00
Verteiron
8eee8ad9cf Add sample Papyrus script
This is the metaquest script from one of my own mods.
2014-10-26 14:58:17 -05:00
Verteiron
24743985e4 Add Papyrus support
Papyrus is a scripting language used by mods/plugins for The Elder Scrolls V: Skyrim.
2014-10-26 14:53:20 -05:00
Arfon Smith
94fba197d1 Merge pull request #1634 from wil93/master
Add LOLCODE support
2014-10-26 09:06:38 +00:00
William Di Luigi
3504a36c3e Add LOLCODE support 2014-10-26 00:23:08 +02:00
Arfon Smith
c8038d1c80 Merge pull request #1633 from pchaigno/proguard
ProGuard config files as vendored
2014-10-24 22:48:11 +01:00
Paul Chaignon
8ba8b48caf Add ProGuard config files to vendored files 2014-10-24 17:18:22 -04:00
ngn
92d0c1f3b7 Recognise *.dyalog as APL sources 2014-10-24 15:55:27 +01:00
Adam Roben
d4186bd34a Merge pull request #1630 from github/even-more-tmscopes
Assign a bunch more TextMate scopes
2014-10-23 11:42:57 -07:00
Adam Roben
008ba9e23f Assign a bunch more TextMate scopes 2014-10-23 11:22:19 -07:00
Paul Chaignon
fd707ddf7e Heuristic rules to distinguish .sc files between SuperCollider and Scala 2014-10-23 14:22:12 -04:00
Arfon Smith
32de8a4d19 Only exact matches 2014-10-23 13:59:36 +01:00
Arfon Smith
cf9998f3e4 Merge branch 'master' into 1036-local 2014-10-23 12:16:51 +01:00
Arfon Smith
f258e4940d Merge branch 'master' of github.com:github/linguist 2014-10-23 12:16:26 +01:00
Arfon Smith
a7b8e38bf3 CI step for samples 2014-10-23 12:16:02 +01:00
Arfon Smith
89320b1ca4 Merge branch 'master' into 1036-local
Conflicts:
	lib/linguist/heuristics.rb
	lib/linguist/samples.json
2014-10-23 12:05:18 +01:00
Arfon Smith
b65129a8e1 Merge pull request #1622 from pchaigno/shell-extensions
Add .command as a Shell file extension
2014-10-23 10:54:05 +01:00
Paul Chaignon
b6a9993c97 Add .sc as a SuperCollider file extension 2014-10-22 10:16:30 -04:00
Josh Watzman
9c044c5bd0 Add detection for Hack files with ".php" file extension
Based on top of PR#1447. Adds a simple heuristic check for Hack files vs PHP files (`<?hh` vs other `<?`).

Tested by verifying that the Hack example site was detected as 100% Hack and that Laravel was detected as 100% PHP. (Without the heuristic, Laravel gets detected as about 50% Hack, just by randomness in the classifier since PHP and Hack are very hard to distinguish unless you actually parse the file and look for specific language features.)
2014-10-21 16:17:58 -07:00
Paul Chaignon
6b0783936f Add .command as a Shell file extension 2014-10-21 19:07:03 -04:00
Arfon Smith
2a66b754c2 CI config 2014-10-21 18:41:25 -04:00
Arfon Smith
460443b3c8 Merge branch 'master' of github.com:github/linguist 2014-10-21 18:40:53 -04:00
Arfon Smith
cd99ab2d6e Vendored gems 2014-10-21 18:40:43 -04:00
Josh Watzman
b2cb74cabf Add detection for Hack files with ".hh" file extension
Hack is Facebook's dialect of PHP: http://hacklang.org/. This adds support for detecting it via the ".hh" file extension; although that extension techincally conflicts with C++ headers, the files look different enough that the existing classifier based on sample code has no trouble distinguising them.

This diff deliberately does not deal with detecting ".php" as another valid extension for Hack code. That's much trickier since the code looks basically identical to PHP to the classifier, and needs a different approach.
2014-10-21 15:35:57 -07:00
Arfon Smith
6d07302963 Update cibuild 2014-10-21 16:49:13 -05:00
Arfon Smith
d831205f6a Update cibuild 2014-10-21 16:41:55 -05:00
Arfon Smith
a9b9e6216b Update cibuild 2014-10-21 16:10:05 -05:00
Arfon Smith
3ba090de7e Update cibuild 2014-10-21 16:07:49 -05:00
Arfon Smith
c105208481 Update cibuild 2014-10-21 14:06:43 -05:00
Arfon Smith
0c9e14eeff Update cibuild 2014-10-21 14:06:13 -05:00
Arfon Smith
2a8a5cdca9 +x 2014-10-21 14:04:52 -05:00
Arfon Smith
1f91acbd9d Janky CI 2014-10-21 14:03:30 -05:00
Daniel Morris
6f8278aa79 Add build.xml.dist to XML filenames 2014-10-21 10:21:39 +01:00
Arfon Smith
3e48a84cf1 Merge pull request #1612 from briandela/patch-1
Add hbs alias for Handlebars
2014-10-20 10:29:04 -05:00
Arfon Smith
31728a3a78 Merge pull request #1613 from hearsilent/patch-1
Add .a51 to Assembly
2014-10-20 10:21:24 -05:00
Arfon Smith
e56a2ed6ad Merge pull request #1614 from creasty/viml_underscore_vimrc
Add a filename rule for _vimrc
2014-10-19 16:45:42 -05:00
HearSilent
35aa57657b Add .a51 sample 2014-10-20 05:16:51 +08:00
Yuki Iwanaga
423c8865bd Add a filename rule for _vimrc 2014-10-20 00:39:26 +09:00
HearSilent
55ecc5f7eb Add .a51 to Assembly
.a51 doc is 8051-asm (coding in MIDE-51)
2014-10-19 17:32:41 +08:00
Brian Delahunty
6aae7882df Update indenentation 2014-10-18 18:03:27 -07:00
Brian Delahunty
240fcec3ce Add hbs alias for Handlebars
Adds a `hbs` alias for `Handlebars`. It's very commonly used and would make adding hbs code blocks easier in github comments.
2014-10-18 11:13:12 -07:00
Arfon Smith
170c1d4ee8 Merge pull request #1584 from laomaiweng/linguist-detect-tcl-shebang
Shebang detection for Tcl/Tk scripts
2014-10-17 14:32:13 -05:00
Arfon Smith
38f0a71ea3 Merge pull request #1596 from pchaigno/fcgi
Add .fcgi as an extension for script languages
2014-10-17 14:30:40 -05:00
Arfon Smith
62936dc6b5 Merge pull request #1609 from github/bundler-rakefile
Require "bundler/setup" in rakefile
2014-10-17 14:27:39 -05:00
Arfon Smith
fb9c784f4f Merge pull request #1611 from github/rugged-gemspec
twiddle-wakka
2014-10-17 14:27:24 -05:00
Arfon Smith
89477ed2fa twiddle-wakka 2014-10-17 14:20:32 -05:00
Arfon Smith
844679dcbe Merge pull request #1610 from github/rugged-gemspec
Moving Rugged dependency back to gemspec
2014-10-17 14:07:47 -05:00
Brandon Keepers
cd743332f4 Use yajl since it is already a dependency
Both JSON and Yajl were listed as dependencies. Pygments.rb already requires yajl, so let's just use that instead of using both.
2014-10-17 14:45:28 -04:00
Arfon Smith
47843e7e78 Moving Rugged dependency back to gemspec 2014-10-17 13:36:13 -05:00
Brandon Keepers
85957ecf56 Require "bundler/setup" in rakefile
This ensures that the Rake task will use bundler to manage dependencies and print a warning to run `bundle install` if dependencies are missing.
2014-10-17 14:14:27 -04:00
Arfon Smith
4232b04571 Merge pull request #1602 from github/gitattribute-docs
Docs update
2014-10-17 08:20:03 -05:00
Arfon Smith
34f717526a Merge pull request #1605 from github/bkeepers/gitattribute-docs
Suggested cuts for .gitattribute docs
2014-10-17 08:19:04 -05:00
Brandon Keepers
b0b94182a2 ✂️ 2014-10-17 09:15:00 -04:00
Arfon Smith
843e196f00 Formatting 2014-10-16 20:56:21 -05:00
Arfon Smith
63661dfc6e Docs update 2014-10-16 16:33:49 -05:00
Arfon Smith
f100dc91c2 Merge pull request #1588 from github/cache-bustin
Bust that cache
2014-10-16 14:21:33 -05:00
Arfon Smith
fd9d63d605 Removing beta label 2014-10-16 14:05:36 -05:00
Arfon Smith
5c21c35875 Merge branch 'master' into cache-bustin 2014-10-16 12:59:41 -05:00
Arfon Smith
370d55fd74 Merge pull request #1595 from github/text-html-ruby
Use TextMate 1 scope for HTML+ERB files
2014-10-15 17:05:08 -05:00
Paul Chaignon
0fcc26f778 Add .fcgi as an extension for script languages 2014-10-15 10:37:58 -04:00
Arfon Smith
8dd2ddcbf7 CI 2014-10-14 20:18:32 -05:00
Arfon Smith
037857623d Merge branch 'master' into cache-bustin
Conflicts:
	lib/linguist/version.rb
2014-10-14 19:45:09 -05:00
Arfon Smith
d7b19d577b Bumping version 2014-10-14 19:44:35 -05:00
Adam Roben
c70048a3e2 Use TextMate 1 scope for HTML+ERB files
The TextMate 2 scope requires support for injection grammars, which some parsers don't support.
2014-10-14 14:19:05 -04:00
Ryunosuke SATO
a1884ca261 Run test against Ruby 2.2 on Travis CI 2014-10-15 00:54:00 +09:00
Ryunosuke SATO
e452291314 Run test against latest Ruby 2.1 on Travis CI
see: https://twitter.com/travisci/status/513233940442644480
2014-10-15 00:53:57 +09:00
Arfon Smith
6d51117a91 Merge pull request #1593 from github/more-tmscopes
Add more TextMate scopes
2014-10-14 10:06:47 -05:00
Arfon Smith
848a1cc1e5 Minor bump 2014-10-14 10:06:38 -05:00
Adam Roben
9092dfdc7f Add a TextMate scope for Literate CoffeeScript 2014-10-14 10:50:39 -04:00
Adam Roben
d7fe0cc5c7 Add TextMate scopes for HTML variants 2014-10-14 10:41:19 -04:00
Adam Roben
15ec37d4bc Add a TextMate scope for Objective-C++ 2014-10-14 10:41:19 -04:00
Adam Roben
43cc701ac3 Add a TextMate scope for JSON 2014-10-14 10:41:19 -04:00
Adam Roben
7cb8357f73 Add a TextMate scope for YAML 2014-10-14 10:41:19 -04:00
Adam Roben
4b46bcf649 Add TextMate scopes for Sass/SCSS files 2014-10-14 10:41:19 -04:00
Arfon Smith
a954a6465e Update README.md 2014-10-14 09:29:45 -05:00
Arfon Smith
b8a5e8505a Merge branch 'vmg/tmscopes' into cache-bustin
Conflicts:
	lib/linguist/version.rb
2014-10-13 20:21:31 -05:00
Arfon Smith
3087d640a3 3.2.2b1 2014-10-13 19:33:03 -05:00
Arfon Smith
e87b89ab5b Removing todo 2014-10-13 18:52:27 -05:00
Arfon Smith
7aabc6a5ad A different approach 2014-10-13 17:01:53 -05:00
Arfon Smith
5cc053694a Remove pry 2014-10-13 16:38:51 -05:00
Arfon Smith
653314448c Bust that cache 2014-10-13 16:37:46 -05:00
quentin
48f2949d69 Move the extension-less sample scripts in a filenames/ subdir 2014-10-13 10:09:07 +02:00
quentin
baa3cba0fc Add sample Tcl/Tk scripts to test Tcl/Tk shebang detection
Scripts taken from:
* starfield: http://wiki.tcl.tk/14140
* owh: http://wiki.tcl.tk/906
2014-10-13 03:05:56 +02:00
quentin
eb54a92328 Add Tcl/Tk interpreters to languages.yml for shebang detection 2014-10-13 02:38:07 +02:00
Romain Lespinasse
ce1e2441f4 Choose a color from the Golo logo 2014-10-11 10:27:06 +02:00
Paul Chaignon
7b44baa417 Merge branch 'master' into newlisp 2014-09-25 10:47:16 -04:00
Paul Chaignon
f3d654a965 Merge branch 'master' into bitbake 2014-09-25 10:38:47 -04:00
Paul Chaignon
2e6aae0256 Merge branch 'master' into saltstack-states 2014-09-25 10:26:57 -04:00
Arfon Smith
12b78c5357 Removing pry runtime dependency 2014-09-18 13:22:02 -05:00
Arfon Smith
e70cd33323 Moving to fixtures 2014-09-17 08:37:00 -05:00
Romain Lespinasse
5a59ecbc2a Add support for Golo language 2014-09-17 13:59:02 +02:00
Arfon Smith
302af86363 Merge branch 'master' into 1233-local
Conflicts:
	lib/linguist/language.rb
	lib/linguist/samples.json
2014-09-16 16:36:10 -05:00
Rachel Mant
44eebde394 Added @property and @end as an Obj-C heuristic for issue #1344 2014-09-03 18:33:24 +01:00
DX-MON
498c102414 Fixed the tests that broke, but this may have re-broken a couple of repositories - I can't yet tell 2014-09-03 18:14:15 +01:00
DX-MON
79cd77454b Merge remote-tracking branch 'source/master' 2014-09-03 18:09:52 +01:00
Michael Johnson
410aace222 Adding Google Apps Script (.gs) as a JavaScript extension. 2014-08-24 17:00:37 -04:00
Damien Pollet
bde19a76cc Re-generate samples.json 2014-08-07 15:24:57 +02:00
Damien Pollet
49ebf4b303 C# samples to disambiguate from Smalltalk 2014-08-07 14:43:35 +02:00
Damien Pollet
0017310dd1 Declare .cs as Smalltalk changeset 2014-08-06 22:27:30 +02:00
dx-mon
dad4b974b7 Merge branch 'master' of https://github.com/github/linguist 2014-07-14 22:08:16 +01:00
DX-MON
f1cb16648f Added samples for .C and .H files to fix the pedantic tests for sample presense 2014-06-27 12:49:11 +01:00
DX-MON
1276f10b67 Fixed languages.yml so the pedantic test on extension ordering passes 2014-06-26 23:04:10 +01:00
DX-MON
c3da262bd0 Merge branch 'master' of https://github.com/github/linguist 2014-06-26 22:57:07 +01:00
Paul Chaignon
35355b157c Add support for .sls YAML files (SaltStack states) 2014-06-22 15:28:49 +02:00
Paul Chaignon
2143699aab Language detection test for non-sample files 2014-06-14 11:53:45 +02:00
Paul Chaignon
b1c2820299 Merge conflicts from master fixed 2014-06-13 18:50:32 +02:00
DX-MON
624fd74f83 Added C header samples from https://github.com/MiJyn/nightmare/ to fix the misclassifications as C++ that were occuring 2014-06-10 18:54:10 +01:00
DX-MON
cd878522d9 Added the GLKit GLKMatrix4 header as a C sample as this fixes 5 misclassifications - 4 as Obj-C and one as C++ 2014-06-10 18:51:29 +01:00
DX-MON
10fed43c27 Added .H and .C as C file extensions as well as them already being C++ ones. This fixes #1054 2014-06-10 11:59:11 +01:00
DX-MON
1d50adf87a Added a sample that fixes comment two on issue #1264. 2014-06-10 10:41:00 +01:00
Rachel Mant
614a61b0b0 Update heuristics.rb
Added the iostream headers and std:: to the C++ heuristics. This covers issues 1250.
2014-06-05 10:37:23 +01:00
Paul Chaignon
bd380f44cc Refactoring of Language.detect 2014-06-03 09:52:24 +02:00
Paul Chaignon
8a546d2a7a Try shebang detection if the extension is unknown 2014-06-01 20:00:49 +02:00
Paul Chaignon
1148a9746a Change unknown extension of PHP sample file 2014-06-01 19:59:57 +02:00
Trey Deitch
913cd6c309 Add support for Cool
This change includes a brief (non-sensical) sample program I wrote to
illustrate many of Cool's language constructs, as well as a simple rule
to distinguish Cool files from Common Lisp or OpenCL (it has a line that
starts with the word 'class'). Further, it includes a second example
program adapted from an example contained in the Cool distribution
(list.cl), which contains a few further language constructs and captures
the style of a Cool program.
2014-05-08 13:27:22 -07:00
Paul Chaignon
81d9c682da Support of the BitBake language 2014-05-05 11:29:00 +02:00
Paul Chaignon
e4975fc476 Heuristics for Common Lisp and NewLisp 2014-04-28 11:45:24 +02:00
Paul Chaignon
e1064b13c0 NewLisp language added 2014-04-28 11:30:12 +02:00
DX-MON
492aa12cad Updated the samples database file as recommended 2014-04-03 11:18:36 +01:00
DX-MON
e79e45a74e Removed the matches variable from find_by_heuristics without re-breaking anything 2014-04-02 22:22:22 +01:00
dx-mon
e661470bbb Merge branch 'master' of github.com:DX-MON/linguist 2014-04-02 21:41:13 +01:00
DX-MON
af30a80702 Added two new heuristics tests for the new C/C++/Obj-C heuristics 2014-04-02 21:41:02 +01:00
Rachel Mant
bab7ee4fcb Found my new heuristic was still not being used because heuristics had been switched off 2014-04-02 20:17:33 +01:00
DX-MON
6524ac3588 Fixed the C++ class matching regex that was breaking the test for C/jni_layer.h 2014-04-02 20:08:47 +01:00
DX-MON
c432cd67fc Found out that nothing was ever getting returned from the heuristic function "find_by_heuristics", and that headers matching C, Obj-C and C++ were never getting checked heuristically 2014-04-02 19:55:24 +01:00
DX-MON
5c071a2e07 More regex goodness to improve the detection of C++ vs C 2014-04-02 19:48:44 +01:00
DX-MON
cb10c53dee Fixed the failing patten for detecting C++-only headers 2014-04-02 17:57:58 +01:00
Rachel Mant
dfba2a31a5 Added the end statements for the two new if statmeents
Did not know ends were required on one-liner ifs. Fixed.
2014-04-02 13:44:17 +01:00
Rachel Mant
667f3de26b Improved the Obj-C heuristic with a Regex matching multiple unique keywords
Also improved the C++ heuristic by checking for class without an @ on the front.
2014-04-02 13:09:17 +01:00
Rachel Mant
fd585beb07 Improved the C++ heuristic for detecting based on included headers 2014-04-02 12:55:29 +01:00
533 changed files with 43174 additions and 2127 deletions

7
.gitignore vendored
View File

@@ -1,5 +1,8 @@
Gemfile.lock
/Gemfile.lock
.bundle/
vendor/
benchmark/
lib/linguist/samples.json
/grammars
/node_modules
test/fixtures/ace_modes.json
/vendor/gems/

581
.gitmodules vendored Normal file
View File

@@ -0,0 +1,581 @@
[submodule "vendor/grammars/go-tmbundle"]
path = vendor/grammars/go-tmbundle
url = https://github.com/AlanQuatermain/go-tmbundle
[submodule "vendor/grammars/PHP-Twig.tmbundle"]
path = vendor/grammars/PHP-Twig.tmbundle
url = https://github.com/Anomareh/PHP-Twig.tmbundle
[submodule "vendor/grammars/sublime-cirru"]
path = vendor/grammars/sublime-cirru
url = https://github.com/Cirru/sublime-cirru
[submodule "vendor/grammars/Sublime-Logos"]
path = vendor/grammars/Sublime-Logos
url = https://github.com/Cykey/Sublime-Logos
[submodule "vendor/grammars/SublimeBrainfuck"]
path = vendor/grammars/SublimeBrainfuck
url = https://github.com/Drako/SublimeBrainfuck
[submodule "vendor/grammars/awk-sublime"]
path = vendor/grammars/awk-sublime
url = https://github.com/JohnNilsson/awk-sublime
[submodule "vendor/grammars/Sublime-SQF-Language"]
path = vendor/grammars/Sublime-SQF-Language
url = https://github.com/JonBons/Sublime-SQF-Language
[submodule "vendor/grammars/SCSS.tmbundle"]
path = vendor/grammars/SCSS.tmbundle
url = https://github.com/MarioRicalde/SCSS.tmbundle
[submodule "vendor/grammars/Sublime-REBOL"]
path = vendor/grammars/Sublime-REBOL
url = https://github.com/Oldes/Sublime-REBOL
[submodule "vendor/grammars/Sublime-Inform"]
path = vendor/grammars/Sublime-Inform
url = https://github.com/PogiNate/Sublime-Inform
[submodule "vendor/grammars/autoitv3-tmbundle"]
path = vendor/grammars/autoitv3-tmbundle
url = https://github.com/Red-Nova-Technologies/autoitv3-tmbundle
[submodule "vendor/grammars/Sublime-VimL"]
path = vendor/grammars/Sublime-VimL
url = https://github.com/SalGnt/Sublime-VimL
[submodule "vendor/grammars/boo-sublime"]
path = vendor/grammars/boo-sublime
url = https://github.com/Shammah/boo-sublime
[submodule "vendor/grammars/ColdFusion"]
path = vendor/grammars/ColdFusion
url = https://github.com/SublimeText/ColdFusion
[submodule "vendor/grammars/NSIS"]
path = vendor/grammars/NSIS
url = https://github.com/SublimeText/NSIS
[submodule "vendor/grammars/NimLime"]
path = vendor/grammars/NimLime
url = https://github.com/Varriount/NimLime
[submodule "vendor/grammars/gradle.tmbundle"]
path = vendor/grammars/gradle.tmbundle
url = https://github.com/alkemist/gradle.tmbundle
[submodule "vendor/grammars/Sublime-Loom"]
path = vendor/grammars/Sublime-Loom
url = https://github.com/ambethia/Sublime-Loom
[submodule "vendor/grammars/VBDotNetSyntax"]
path = vendor/grammars/VBDotNetSyntax
url = https://github.com/angryant0007/VBDotNetSyntax
[submodule "vendor/grammars/cool-tmbundle"]
path = vendor/grammars/cool-tmbundle
url = https://github.com/anunayk/cool-tmbundle
[submodule "vendor/grammars/Docker.tmbundle"]
path = vendor/grammars/Docker.tmbundle
url = https://github.com/asbjornenge/Docker.tmbundle
[submodule "vendor/grammars/jasmin-sublime"]
path = vendor/grammars/jasmin-sublime
url = https://github.com/atmarksharp/jasmin-sublime
[submodule "vendor/grammars/language-clojure"]
path = vendor/grammars/language-clojure
url = https://github.com/atom/language-clojure
[submodule "vendor/grammars/language-coffee-script"]
path = vendor/grammars/language-coffee-script
url = https://github.com/atom/language-coffee-script
[submodule "vendor/grammars/language-csharp"]
path = vendor/grammars/language-csharp
url = https://github.com/atom/language-csharp
[submodule "vendor/grammars/language-gfm"]
path = vendor/grammars/language-gfm
url = https://github.com/atom/language-gfm
[submodule "vendor/grammars/language-javascript"]
path = vendor/grammars/language-javascript
url = https://github.com/atom/language-javascript
[submodule "vendor/grammars/language-python"]
path = vendor/grammars/language-python
url = https://github.com/atom/language-python
[submodule "vendor/grammars/language-shellscript"]
path = vendor/grammars/language-shellscript
url = https://github.com/atom/language-shellscript
[submodule "vendor/grammars/language-yaml"]
path = vendor/grammars/language-yaml
url = https://github.com/atom/language-yaml
[submodule "vendor/grammars/sublime-sourcepawn"]
path = vendor/grammars/sublime-sourcepawn
url = https://github.com/austinwagner/sublime-sourcepawn
[submodule "vendor/grammars/Sublime-Lasso"]
path = vendor/grammars/Sublime-Lasso
url = https://github.com/bfad/Sublime-Lasso
[submodule "vendor/grammars/chapel-tmbundle"]
path = vendor/grammars/chapel-tmbundle
url = https://github.com/bholt/chapel-tmbundle
[submodule "vendor/grammars/sublime-nginx"]
path = vendor/grammars/sublime-nginx
url = https://github.com/brandonwamboldt/sublime-nginx
[submodule "vendor/grammars/bro-sublime"]
path = vendor/grammars/bro-sublime
url = https://github.com/bro/bro-sublime
[submodule "vendor/grammars/sublime_man_page_support"]
path = vendor/grammars/sublime_man_page_support
url = https://github.com/carsonoid/sublime_man_page_support
[submodule "vendor/grammars/sublime-MuPAD"]
path = vendor/grammars/sublime-MuPAD
url = https://github.com/ccreutzig/sublime-MuPAD
[submodule "vendor/grammars/nesC.tmbundle"]
path = vendor/grammars/nesC.tmbundle
url = https://github.com/cdwilson/nesC.tmbundle
[submodule "vendor/grammars/haxe-sublime-bundle"]
path = vendor/grammars/haxe-sublime-bundle
url = https://github.com/clemos/haxe-sublime-bundle
[submodule "vendor/grammars/cucumber-tmbundle"]
path = vendor/grammars/cucumber-tmbundle
url = https://github.com/cucumber/cucumber-tmbundle
[submodule "vendor/grammars/Handlebars"]
path = vendor/grammars/Handlebars
url = https://github.com/daaain/Handlebars
[submodule "vendor/grammars/powershell"]
path = vendor/grammars/powershell
url = https://github.com/SublimeText/PowerShell
[submodule "vendor/grammars/jade-tmbundle"]
path = vendor/grammars/jade-tmbundle
url = https://github.com/davidrios/jade-tmbundle
[submodule "vendor/grammars/elixir-tmbundle"]
path = vendor/grammars/elixir-tmbundle
url = https://github.com/elixir-lang/elixir-tmbundle
[submodule "vendor/grammars/sublime-glsl"]
path = vendor/grammars/sublime-glsl
url = https://github.com/euler0/sublime-glsl
[submodule "vendor/grammars/fancy-tmbundle"]
path = vendor/grammars/fancy-tmbundle
url = https://github.com/fancy-lang/fancy-tmbundle
[submodule "vendor/grammars/fsharpbinding"]
path = vendor/grammars/fsharpbinding
url = https://github.com/fsharp/fsharpbinding
[submodule "vendor/grammars/monkey.tmbundle"]
path = vendor/grammars/monkey.tmbundle
url = https://github.com/gingerbeardman/monkey.tmbundle
[submodule "vendor/grammars/dart-sublime-bundle"]
path = vendor/grammars/dart-sublime-bundle
url = https://github.com/guillermooo/dart-sublime-bundle
[submodule "vendor/grammars/sublimetext-cuda-cpp"]
path = vendor/grammars/sublimetext-cuda-cpp
url = https://github.com/harrism/sublimetext-cuda-cpp
[submodule "vendor/grammars/pike-textmate"]
path = vendor/grammars/pike-textmate
url = https://github.com/hww3/pike-textmate
[submodule "vendor/grammars/ceylon-sublimetext"]
path = vendor/grammars/ceylon-sublimetext
url = https://github.com/jeancharles-roger/ceylon-sublimetext
[submodule "vendor/grammars/Sublime-Text-2-OpenEdge-ABL"]
path = vendor/grammars/Sublime-Text-2-OpenEdge-ABL
url = https://github.com/jfairbank/Sublime-Text-2-OpenEdge-ABL
[submodule "vendor/grammars/sublime-rust"]
path = vendor/grammars/sublime-rust
url = https://github.com/jhasse/sublime-rust
[submodule "vendor/grammars/sublime-befunge"]
path = vendor/grammars/sublime-befunge
url = https://github.com/johanasplund/sublime-befunge
[submodule "vendor/grammars/RDoc.tmbundle"]
path = vendor/grammars/RDoc.tmbundle
url = https://github.com/joshaven/RDoc.tmbundle
[submodule "vendor/grammars/Textmate-Gosu-Bundle"]
path = vendor/grammars/Textmate-Gosu-Bundle
url = https://github.com/jpcamara/Textmate-Gosu-Bundle
[submodule "vendor/grammars/jquery-tmbundle"]
path = vendor/grammars/jquery-tmbundle
url = https://github.com/kswedberg/jquery-tmbundle
[submodule "vendor/grammars/fish-tmbundle"]
path = vendor/grammars/fish-tmbundle
url = https://github.com/l15n/fish-tmbundle
[submodule "vendor/grammars/sublime-idris"]
path = vendor/grammars/sublime-idris
url = https://github.com/laughedelic/sublime-idris
[submodule "vendor/grammars/sublime-better-typescript"]
path = vendor/grammars/sublime-better-typescript
url = https://github.com/lavrton/sublime-better-typescript
[submodule "vendor/grammars/moonscript-tmbundle"]
path = vendor/grammars/moonscript-tmbundle
url = https://github.com/leafo/moonscript-tmbundle
[submodule "vendor/grammars/Isabelle.tmbundle"]
path = vendor/grammars/Isabelle.tmbundle
url = https://github.com/lsf37/Isabelle.tmbundle
[submodule "vendor/grammars/x86-assembly-textmate-bundle"]
path = vendor/grammars/x86-assembly-textmate-bundle
url = https://github.com/lunixbochs/x86-assembly-textmate-bundle
[submodule "vendor/grammars/Alloy.tmbundle"]
path = vendor/grammars/Alloy.tmbundle
url = https://github.com/macekond/Alloy.tmbundle
[submodule "vendor/grammars/opa.tmbundle"]
path = vendor/grammars/opa.tmbundle
url = https://github.com/mads379/opa.tmbundle
[submodule "vendor/grammars/scala.tmbundle"]
path = vendor/grammars/scala.tmbundle
url = https://github.com/mads379/scala.tmbundle
[submodule "vendor/grammars/mako-tmbundle"]
path = vendor/grammars/mako-tmbundle
url = https://github.com/marconi/mako-tmbundle
[submodule "vendor/grammars/gnuplot-tmbundle"]
path = vendor/grammars/gnuplot-tmbundle
url = https://github.com/mattfoster/gnuplot-tmbundle
[submodule "vendor/grammars/idl.tmbundle"]
path = vendor/grammars/idl.tmbundle
url = https://github.com/mgalloy/idl.tmbundle
[submodule "vendor/grammars/protobuf-tmbundle"]
path = vendor/grammars/protobuf-tmbundle
url = https://github.com/michaeledgar/protobuf-tmbundle
[submodule "vendor/grammars/Sublime-Coq"]
path = vendor/grammars/Sublime-Coq
url = https://github.com/mkolosick/Sublime-Coq
[submodule "vendor/grammars/Agda.tmbundle"]
path = vendor/grammars/Agda.tmbundle
url = https://github.com/mokus0/Agda.tmbundle
[submodule "vendor/grammars/Julia.tmbundle"]
path = vendor/grammars/Julia.tmbundle
url = https://github.com/nanoant/Julia.tmbundle
[submodule "vendor/grammars/assembly.tmbundle"]
path = vendor/grammars/assembly.tmbundle
url = https://github.com/nanoant/assembly.tmbundle
[submodule "vendor/grammars/ooc.tmbundle"]
path = vendor/grammars/ooc.tmbundle
url = https://github.com/nilium/ooc.tmbundle
[submodule "vendor/grammars/LiveScript.tmbundle"]
path = vendor/grammars/LiveScript.tmbundle
url = https://github.com/paulmillr/LiveScript.tmbundle
[submodule "vendor/grammars/sublime-tea"]
path = vendor/grammars/sublime-tea
url = https://github.com/pferruggiaro/sublime-tea
[submodule "vendor/grammars/puppet-textmate-bundle"]
path = vendor/grammars/puppet-textmate-bundle
url = https://github.com/puppet-textmate-bundle/puppet-textmate-bundle
[submodule "vendor/grammars/abap.tmbundle"]
path = vendor/grammars/abap.tmbundle
url = https://github.com/pvl/abap.tmbundle
[submodule "vendor/grammars/mercury-tmlanguage"]
path = vendor/grammars/mercury-tmlanguage
url = https://github.com/sebgod/mercury-tmlanguage
[submodule "vendor/grammars/mathematica-tmbundle"]
path = vendor/grammars/mathematica-tmbundle
url = https://github.com/shadanan/mathematica-tmbundle
[submodule "vendor/grammars/sublime-robot-plugin"]
path = vendor/grammars/sublime-robot-plugin
url = https://github.com/shellderp/sublime-robot-plugin
[submodule "vendor/grammars/actionscript3-tmbundle"]
path = vendor/grammars/actionscript3-tmbundle
url = https://github.com/simongregory/actionscript3-tmbundle
[submodule "vendor/grammars/Sublime-QML"]
path = vendor/grammars/Sublime-QML
url = https://github.com/skozlovf/Sublime-QML
[submodule "vendor/grammars/Slash.tmbundle"]
path = vendor/grammars/Slash.tmbundle
url = https://github.com/slash-lang/Slash.tmbundle
[submodule "vendor/grammars/factor"]
path = vendor/grammars/factor
url = https://github.com/slavapestov/factor
[submodule "vendor/grammars/ruby-slim.tmbundle"]
path = vendor/grammars/ruby-slim.tmbundle
url = https://github.com/slim-template/ruby-slim.tmbundle
[submodule "vendor/grammars/SublimeXtend"]
path = vendor/grammars/SublimeXtend
url = https://github.com/staltz/SublimeXtend
[submodule "vendor/grammars/Stata.tmbundle"]
path = vendor/grammars/Stata.tmbundle
url = https://github.com/statatmbundle/Stata.tmbundle
[submodule "vendor/grammars/Vala-TMBundle"]
path = vendor/grammars/Vala-TMBundle
url = https://github.com/technosophos/Vala-TMBundle
[submodule "vendor/grammars/ant.tmbundle"]
path = vendor/grammars/ant.tmbundle
url = https://github.com/textmate/ant.tmbundle
[submodule "vendor/grammars/antlr.tmbundle"]
path = vendor/grammars/antlr.tmbundle
url = https://github.com/textmate/antlr.tmbundle
[submodule "vendor/grammars/apache.tmbundle"]
path = vendor/grammars/apache.tmbundle
url = https://github.com/textmate/apache.tmbundle
[submodule "vendor/grammars/applescript.tmbundle"]
path = vendor/grammars/applescript.tmbundle
url = https://github.com/textmate/applescript.tmbundle
[submodule "vendor/grammars/asp.tmbundle"]
path = vendor/grammars/asp.tmbundle
url = https://github.com/textmate/asp.tmbundle
[submodule "vendor/grammars/bison.tmbundle"]
path = vendor/grammars/bison.tmbundle
url = https://github.com/textmate/bison.tmbundle
[submodule "vendor/grammars/capnproto.tmbundle"]
path = vendor/grammars/capnproto.tmbundle
url = https://github.com/textmate/capnproto.tmbundle
[submodule "vendor/grammars/cmake.tmbundle"]
path = vendor/grammars/cmake.tmbundle
url = https://github.com/textmate/cmake.tmbundle
[submodule "vendor/grammars/cpp-qt.tmbundle"]
path = vendor/grammars/cpp-qt.tmbundle
url = https://github.com/textmate/cpp-qt.tmbundle
[submodule "vendor/grammars/css.tmbundle"]
path = vendor/grammars/css.tmbundle
url = https://github.com/textmate/css.tmbundle
[submodule "vendor/grammars/d.tmbundle"]
path = vendor/grammars/d.tmbundle
url = https://github.com/textmate/d.tmbundle
[submodule "vendor/grammars/diff.tmbundle"]
path = vendor/grammars/diff.tmbundle
url = https://github.com/textmate/diff.tmbundle
[submodule "vendor/grammars/dylan.tmbundle"]
path = vendor/grammars/dylan.tmbundle
url = https://github.com/textmate/dylan.tmbundle
[submodule "vendor/grammars/eiffel.tmbundle"]
path = vendor/grammars/eiffel.tmbundle
url = https://github.com/textmate/eiffel.tmbundle
[submodule "vendor/grammars/erlang.tmbundle"]
path = vendor/grammars/erlang.tmbundle
url = https://github.com/textmate/erlang.tmbundle
[submodule "vendor/grammars/fortran.tmbundle"]
path = vendor/grammars/fortran.tmbundle
url = https://github.com/textmate/fortran.tmbundle
[submodule "vendor/grammars/gettext.tmbundle"]
path = vendor/grammars/gettext.tmbundle
url = https://github.com/textmate/gettext.tmbundle
[submodule "vendor/grammars/graphviz.tmbundle"]
path = vendor/grammars/graphviz.tmbundle
url = https://github.com/textmate/graphviz.tmbundle
[submodule "vendor/grammars/groovy.tmbundle"]
path = vendor/grammars/groovy.tmbundle
url = https://github.com/textmate/groovy.tmbundle
[submodule "vendor/grammars/haskell.tmbundle"]
path = vendor/grammars/haskell.tmbundle
url = https://github.com/textmate/haskell.tmbundle
[submodule "vendor/grammars/html.tmbundle"]
path = vendor/grammars/html.tmbundle
url = https://github.com/textmate/html.tmbundle
[submodule "vendor/grammars/ini.tmbundle"]
path = vendor/grammars/ini.tmbundle
url = https://github.com/textmate/ini.tmbundle
[submodule "vendor/grammars/desktop.tmbundle"]
path = vendor/grammars/desktop.tmbundle
url = https://github.com/Mailaender/desktop.tmbundle.git
[submodule "vendor/grammars/io.tmbundle"]
path = vendor/grammars/io.tmbundle
url = https://github.com/textmate/io.tmbundle
[submodule "vendor/grammars/java.tmbundle"]
path = vendor/grammars/java.tmbundle
url = https://github.com/textmate/java.tmbundle
[submodule "vendor/grammars/javadoc.tmbundle"]
path = vendor/grammars/javadoc.tmbundle
url = https://github.com/textmate/javadoc.tmbundle
[submodule "vendor/grammars/javascript-objective-j.tmbundle"]
path = vendor/grammars/javascript-objective-j.tmbundle
url = https://github.com/textmate/javascript-objective-j.tmbundle
[submodule "vendor/grammars/json.tmbundle"]
path = vendor/grammars/json.tmbundle
url = https://github.com/textmate/json.tmbundle
[submodule "vendor/grammars/latex.tmbundle"]
path = vendor/grammars/latex.tmbundle
url = https://github.com/textmate/latex.tmbundle
[submodule "vendor/grammars/less.tmbundle"]
path = vendor/grammars/less.tmbundle
url = https://github.com/textmate/less.tmbundle
[submodule "vendor/grammars/lilypond.tmbundle"]
path = vendor/grammars/lilypond.tmbundle
url = https://github.com/textmate/lilypond.tmbundle
[submodule "vendor/grammars/lisp.tmbundle"]
path = vendor/grammars/lisp.tmbundle
url = https://github.com/textmate/lisp.tmbundle
[submodule "vendor/grammars/logtalk.tmbundle"]
path = vendor/grammars/logtalk.tmbundle
url = https://github.com/textmate/logtalk.tmbundle
[submodule "vendor/grammars/lua.tmbundle"]
path = vendor/grammars/lua.tmbundle
url = https://github.com/textmate/lua.tmbundle
[submodule "vendor/grammars/make.tmbundle"]
path = vendor/grammars/make.tmbundle
url = https://github.com/textmate/make.tmbundle
[submodule "vendor/grammars/matlab.tmbundle"]
path = vendor/grammars/matlab.tmbundle
url = https://github.com/textmate/matlab.tmbundle
[submodule "vendor/grammars/maven.tmbundle"]
path = vendor/grammars/maven.tmbundle
url = https://github.com/textmate/maven.tmbundle
[submodule "vendor/grammars/nemerle.tmbundle"]
path = vendor/grammars/nemerle.tmbundle
url = https://github.com/textmate/nemerle.tmbundle
[submodule "vendor/grammars/ninja.tmbundle"]
path = vendor/grammars/ninja.tmbundle
url = https://github.com/textmate/ninja.tmbundle
[submodule "vendor/grammars/objective-c.tmbundle"]
path = vendor/grammars/objective-c.tmbundle
url = https://github.com/textmate/objective-c.tmbundle
[submodule "vendor/grammars/ocaml.tmbundle"]
path = vendor/grammars/ocaml.tmbundle
url = https://github.com/textmate/ocaml.tmbundle
[submodule "vendor/grammars/pascal.tmbundle"]
path = vendor/grammars/pascal.tmbundle
url = https://github.com/textmate/pascal.tmbundle
[submodule "vendor/grammars/perl.tmbundle"]
path = vendor/grammars/perl.tmbundle
url = https://github.com/textmate/perl.tmbundle
[submodule "vendor/grammars/php-smarty.tmbundle"]
path = vendor/grammars/php-smarty.tmbundle
url = https://github.com/textmate/php-smarty.tmbundle
[submodule "vendor/grammars/php.tmbundle"]
path = vendor/grammars/php.tmbundle
url = https://github.com/textmate/php.tmbundle
[submodule "vendor/grammars/postscript.tmbundle"]
path = vendor/grammars/postscript.tmbundle
url = https://github.com/textmate/postscript.tmbundle
[submodule "vendor/grammars/processing.tmbundle"]
path = vendor/grammars/processing.tmbundle
url = https://github.com/textmate/processing.tmbundle
[submodule "vendor/grammars/prolog.tmbundle"]
path = vendor/grammars/prolog.tmbundle
url = https://github.com/textmate/prolog.tmbundle
[submodule "vendor/grammars/python-django.tmbundle"]
path = vendor/grammars/python-django.tmbundle
url = https://github.com/textmate/python-django.tmbundle
[submodule "vendor/grammars/r.tmbundle"]
path = vendor/grammars/r.tmbundle
url = https://github.com/textmate/r.tmbundle
[submodule "vendor/grammars/restructuredtext.tmbundle"]
path = vendor/grammars/restructuredtext.tmbundle
url = https://github.com/textmate/restructuredtext.tmbundle
[submodule "vendor/grammars/ruby-haml.tmbundle"]
path = vendor/grammars/ruby-haml.tmbundle
url = https://github.com/textmate/ruby-haml.tmbundle
[submodule "vendor/grammars/ruby-on-rails-tmbundle"]
path = vendor/grammars/ruby-on-rails-tmbundle
url = https://github.com/textmate/ruby-on-rails-tmbundle
[submodule "vendor/grammars/scheme.tmbundle"]
path = vendor/grammars/scheme.tmbundle
url = https://github.com/textmate/scheme.tmbundle
[submodule "vendor/grammars/scilab.tmbundle"]
path = vendor/grammars/scilab.tmbundle
url = https://github.com/textmate/scilab.tmbundle
[submodule "vendor/grammars/sql.tmbundle"]
path = vendor/grammars/sql.tmbundle
url = https://github.com/textmate/sql.tmbundle
[submodule "vendor/grammars/standard-ml.tmbundle"]
path = vendor/grammars/standard-ml.tmbundle
url = https://github.com/textmate/standard-ml.tmbundle
[submodule "vendor/grammars/swift.tmbundle"]
path = vendor/grammars/swift.tmbundle
url = https://github.com/textmate/swift.tmbundle
[submodule "vendor/grammars/tcl.tmbundle"]
path = vendor/grammars/tcl.tmbundle
url = https://github.com/textmate/tcl.tmbundle
[submodule "vendor/grammars/text.tmbundle"]
path = vendor/grammars/text.tmbundle
url = https://github.com/textmate/text.tmbundle
[submodule "vendor/grammars/textile.tmbundle"]
path = vendor/grammars/textile.tmbundle
url = https://github.com/textmate/textile.tmbundle
[submodule "vendor/grammars/textmate.tmbundle"]
path = vendor/grammars/textmate.tmbundle
url = https://github.com/textmate/textmate.tmbundle
[submodule "vendor/grammars/thrift.tmbundle"]
path = vendor/grammars/thrift.tmbundle
url = https://github.com/textmate/thrift.tmbundle
[submodule "vendor/grammars/toml.tmbundle"]
path = vendor/grammars/toml.tmbundle
url = https://github.com/textmate/toml.tmbundle
[submodule "vendor/grammars/verilog.tmbundle"]
path = vendor/grammars/verilog.tmbundle
url = https://github.com/textmate/verilog.tmbundle
[submodule "vendor/grammars/xml.tmbundle"]
path = vendor/grammars/xml.tmbundle
url = https://github.com/textmate/xml.tmbundle
[submodule "vendor/grammars/smalltalk-tmbundle"]
path = vendor/grammars/smalltalk-tmbundle
url = https://github.com/tomas-stefano/smalltalk-tmbundle
[submodule "vendor/grammars/ioke-outdated"]
path = vendor/grammars/ioke-outdated
url = https://github.com/vic/ioke-outdated
[submodule "vendor/grammars/kotlin-sublime-package"]
path = vendor/grammars/kotlin-sublime-package
url = https://github.com/vkostyukov/kotlin-sublime-package
[submodule "vendor/grammars/c.tmbundle"]
path = vendor/grammars/c.tmbundle
url = https://github.com/textmate/c.tmbundle
[submodule "vendor/grammars/zephir-sublime"]
path = vendor/grammars/zephir-sublime
url = https://github.com/vmg/zephir-sublime
[submodule "vendor/grammars/llvm.tmbundle"]
path = vendor/grammars/llvm.tmbundle
url = https://github.com/whitequark/llvm.tmbundle
[submodule "vendor/grammars/sublime-nix"]
path = vendor/grammars/sublime-nix
url = https://github.com/wmertens/sublime-nix
[submodule "vendor/grammars/ada.tmbundle"]
path = vendor/grammars/ada.tmbundle
url = https://github.com/aroben/ada.tmbundle
branch = better-with-highlighting
[submodule "vendor/grammars/oz-tmbundle"]
path = vendor/grammars/oz-tmbundle
url = https://github.com/eregon/oz-tmbundle
[submodule "vendor/grammars/ebundles"]
path = vendor/grammars/ebundles
url = https://github.com/ericzou/ebundles
[submodule "vendor/grammars/sublime-mask"]
path = vendor/grammars/sublime-mask
url = https://github.com/tenbits/sublime-mask
[submodule "vendor/grammars/sublime_cobol"]
path = vendor/grammars/sublime_cobol
url = https://bitbucket.org/bitlang/sublime_cobol
[submodule "vendor/grammars/ruby.tmbundle"]
path = vendor/grammars/ruby.tmbundle
url = https://github.com/aroben/ruby.tmbundle
branch = pl
[submodule "vendor/grammars/IDL-Syntax"]
path = vendor/grammars/IDL-Syntax
url = https://github.com/andik/IDL-Syntax
[submodule "vendor/grammars/sas.tmbundle"]
path = vendor/grammars/sas.tmbundle
url = https://github.com/rpardee/sas.tmbundle
[submodule "vendor/grammars/atom-salt"]
path = vendor/grammars/atom-salt
url = https://github.com/saltstack/atom-salt
[submodule "vendor/grammars/Scalate.tmbundle"]
path = vendor/grammars/Scalate.tmbundle
url = https://github.com/scalate/Scalate.tmbundle
[submodule "vendor/grammars/Elm.tmLanguage"]
path = vendor/grammars/Elm.tmLanguage
url = https://github.com/deadfoxygrandpa/Elm.tmLanguage
[submodule "vendor/grammars/sublime-bsv"]
path = vendor/grammars/sublime-bsv
url = https://github.com/thotypous/sublime-bsv
[submodule "vendor/grammars/Sublime-HTTP"]
path = vendor/grammars/Sublime-HTTP
url = https://github.com/httpspec/sublime-highlighting
[submodule "vendor/grammars/sass-textmate-bundle"]
path = vendor/grammars/sass-textmate-bundle
url = https://github.com/nathos/sass-textmate-bundle
[submodule "vendor/grammars/carto-atom"]
path = vendor/grammars/carto-atom
url = https://github.com/yohanboniface/carto-atom
[submodule "vendor/grammars/Sublime-Nit"]
path = vendor/grammars/Sublime-Nit
url = https://github.com/R4PaSs/Sublime-Nit
[submodule "vendor/grammars/language-hy"]
path = vendor/grammars/language-hy
url = https://github.com/rwtolbert/language-hy
[submodule "vendor/grammars/Racket"]
path = vendor/grammars/Racket
url = https://github.com/soegaard/racket-highlight-for-github
[submodule "vendor/grammars/turtle.tmbundle"]
path = vendor/grammars/turtle.tmbundle
url = https://github.com/peta/turtle.tmbundle
[submodule "vendor/grammars/liquid.tmbundle"]
path = vendor/grammars/liquid.tmbundle
url = https://github.com/bastilian/validcode-textmate-bundles
[submodule "vendor/grammars/AutoHotkey"]
path = vendor/grammars/AutoHotkey
url = https://github.com/ahkscript/AutoHotkey
[submodule "vendor/grammars/ats.sublime"]
path = vendor/grammars/ats.sublime
url = https://github.com/steinwaywhw/ats-mode-sublimetext
[submodule "vendor/grammars/Modelica"]
path = vendor/grammars/Modelica
url = https://github.com/BorisChumichev/modelicaSublimeTextPackage
[submodule "vendor/grammars/sublime-apl"]
path = vendor/grammars/sublime-apl
url = https://github.com/StoneCypher/sublime-apl
[submodule "vendor/grammars/CLIPS-sublime"]
path = vendor/grammars/CLIPS-sublime
url = https://github.com/psicomante/CLIPS-sublime
[submodule "vendor/grammars/Creole"]
path = vendor/grammars/Creole
url = https://github.com/Siddley/Creole
[submodule "vendor/grammars/GDScript-sublime"]
path = vendor/grammars/GDScript-sublime
url = https://github.com/beefsack/GDScript-sublime
[submodule "vendor/grammars/sublime-golo"]
path = vendor/grammars/sublime-golo
url = https://github.com/TypeUnsafe/sublime-golo
[submodule "vendor/grammars/JSyntax"]
path = vendor/grammars/JSyntax
url = https://github.com/bcj/JSyntax

View File

@@ -1,11 +1,12 @@
before_install:
- git fetch origin master:master
- git fetch origin v2.0.0:v2.0.0
- git fetch origin test/attributes:test/attributes
- sudo apt-get install libicu-dev -y
sudo: false
before_install: script/travis/before_install
rvm:
- 1.9.3
- 2.0.0
- 2.1.1
- 2.1
- 2.2
notifications:
disabled: true
git:
submodules: false
cache: bundler

41
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,41 @@
## Contributing
The majority of contributions won't need to touch any Ruby code at all. The [master language list][languages] is just a YAML configuration file.
Almost all bug fixes or new language additions should come with some additional code samples. Just drop them under [`samples/`][samples] in the correct subdirectory and our test suite will automatically test them. In most cases you shouldn't need to add any new assertions.
### My code is detected as the wrong language
This can usually be solved either by adding a new filename or file name extension to the language's entry in [`languages.yml`][languages] or adding more [samples][samples] for your language to the repository to make Linguist's classifier smarter.
### Syntax highlighting looks wrong
Assuming your code is being detected as the right language (see above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report.
You can also try to fix the bug yourself and submit a Pull Request. [This piece from TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://lightshow.githubapp.com).
Once the bug has been fixed upstream, please let us know and we'll pick it up for GitHub.
### I want to add support for the `X` programming language
Great! You'll need to:
0. Add an entry for your language to [`languages.yml`][languages].
0. Add a grammar for your language. Please only add grammars that have a license that permits redistribution.
0. Add your grammar as a submodule: `git submodule add https://github.com/JaneSmith/MyGrammar vendor/grammars/MyGrammar`.
0. Add your grammar to [`grammars.yml`][grammars] by running `script/convert-grammars --add vendor/grammars/MyGrammar`.
0. Add samples for your language to the [samples directory][samples].
In addition, if your new language defines an extension that's already listed in [`languages.yml`][languages] (such as `.foo`) then sometimes a few more steps will need to be taken:
0. Make sure that example `.foo` files are present in the [samples directory][samples] for each language that uses `.foo`.
0. Test the performance of the Bayesian classifier with a relatively large number (1000s) of sample `.foo` files. (ping @arfon or @bkeepers to help with this) to ensure we're not misclassifying files.
0. If the Bayesian classifier does a bad job with the sample `.foo` files then a [heuristic](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb) may need to be written to help.
Remember, the goal here is to try and avoid false positives!
We try only to add languages once they have some usage on GitHub, so please note in-the-wild usage examples in your pull request. In most cases we prefer that languages already be in use in hundreds of repositories before supporting them in Linguist.
[grammars]: /grammars.yml
[languages]: /lib/linguist/languages.yml
[samples]: /samples

View File

@@ -1,3 +1,4 @@
source 'https://rubygems.org'
gemspec
gem 'rugged', '0.21.1b2'
gemspec :name => "github-linguist"
gemspec :name => "github-linguist-grammars"
gem 'byebug' if RUBY_VERSION >= '2.0'

View File

@@ -1,4 +1,4 @@
Copyright (c) 2011-2014 GitHub, Inc.
Copyright (c) 2011-2015 GitHub, Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -1,12 +1,14 @@
# Linguist
We use this library at GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs.
We use this library at GitHub to detect blob languages, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs.
Tips for filing issues and creating pull requests can be found in [`CONTRIBUTING.md`](/CONTRIBUTING.md).
## Features
### Language detection
Linguist defines a list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and a lexer must be defined there.
Linguist defines a list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml).
Most languages are detected by their file extension. For disambiguating between files with common extensions, we first apply some common-sense heuristics to pick out obvious languages. After that, we use a
[statistical
@@ -24,7 +26,9 @@ See [lib/linguist/language.rb](https://github.com/github/linguist/blob/master/li
### Syntax Highlighting
The actual syntax highlighting is handled by our Pygments wrapper, [pygments.rb](https://github.com/tmm1/pygments.rb). It also provides a [Lexer abstraction](https://github.com/tmm1/pygments.rb/blob/master/lib/pygments/lexer.rb) that determines which highlighter should be used on a file.
Syntax highlighting in GitHub is performed using TextMate-compatible grammars. These are the same grammars that TextMate, Sublime Text and Atom use.
Every language in `languages.yml` is mapped to its corresponding TM `scope`. This scope will be used when picking up a grammar for highlighting. **When adding a new language to Linguist, please add its corresponding scope too (assuming there's an existing TextMate bundle, Sublime Text package, or Atom package) so syntax highlighting works for it**.
### Stats
@@ -34,7 +38,7 @@ The repository stats API, accessed through `#languages`, can be used on a direct
***API UPDATE***
Since [Version 3.0.0](https://github.com/github/linguist/releases/tag/v3.0.0) Linguist requires a git repository (in the form of a [Rugged::Repository](https://github.com/libgit2/rugged#repositories)) to be passed when initializing `Linguist::Repository`.
Since [Version 3.0.0](https://github.com/github/linguist/releases/tag/v3.0.0) Linguist expects a git repository (in the form of a [Rugged::Repository](https://github.com/libgit2/rugged#repositories)) to be passed when initializing `Linguist::Repository`.
```ruby
@@ -104,28 +108,45 @@ Linguist::FileBlob.new("underscore.min.js").generated? # => true
See [Linguist::Generated#generated?](https://github.com/github/linguist/blob/master/lib/linguist/generated.rb).
## Overrides
Linguist supports custom overrides for language definitions and vendored paths. Add a `.gitattributes` file to your project using the keys `linguist-language` and `linguist-vendored` with the standard git-style path matchers for the files you want to override.
Please note that the overrides currently only affect the language statistics for a repository and not the syntax-highlighting of files.
```
$ cat .gitattributes
*.rb linguist-language=Java
$ linguist --breakdown
100.00% Java
Java:
ruby_file.rb
```
By default, Linguist treats all of the paths defined in [lib/linguist/vendor.yml](https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml) as vendored and therefore doesn't include them in the language statistics for a repository. Use the `linguist-vendored` attribute to vendor or un-vendor paths.
```
$ cat .gitattributes
special-vendored-path/* linguist-vendored
jquery.js linguist-vendored=false
```
## Installation
github.com is usually running the latest version of the `github-linguist` gem that is released on [RubyGems.org](http://rubygems.org/gems/github-linguist).
Github.com is usually running the latest version of the `github-linguist` gem that is released on [RubyGems.org](http://rubygems.org/gems/github-linguist).
But for development you are going to want to checkout out the source. To get it, clone the repo and run [Bundler](http://gembundler.com/) to install its dependencies.
git clone https://github.com/github/linguist.git
cd linguist/
bundle install
script/bootstrap
To run the tests:
bundle exec rake test
## Contributing
The majority of contributions won't need to touch any Ruby code at all. The [master language list](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) is just a YAML configuration file.
We try to only add languages once they have some usage on GitHub, so please note in-the-wild usage examples in your pull request.
Almost all bug fixes or new language additions should come with some additional code samples. Just drop them under [`samples/`](https://github.com/github/linguist/tree/master/samples) in the correct subdirectory and our test suite will automatically test them. In most cases you shouldn't need to add any new assertions.
### A note on language extensions
Linguist has a number of methods available to it for identifying the language of a particular file. The initial lookup is based upon the extension of the file, possible file extensions are defined in an array called `extensions`. Take a look at this example for example for `Perl`:
@@ -160,12 +181,13 @@ Here's our current build status, which is hopefully green: [![Build Status](http
If you are the current maintainer of this gem:
0. Create a branch for the release: `git checkout -b cut-release-vxx.xx.xx`
0. Make sure your local dependencies are up to date: `bundle install`
0. Make sure your local dependencies are up to date: `script/bootstrap`
0. If grammar submodules have not been updated recently, update them: `git submodule update --remote && git commit -a`
0. Ensure that samples are updated: `bundle exec rake samples`
0. Ensure that tests are green: `bundle exec rake test`
0. Bump gem version in `lib/linguist/version.rb`. For example, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985).
0. Make a PR to github/linguist. For example, [#1238](https://github.com/github/linguist/pull/1238).
0. Build a local gem: `gem build github-linguist.gemspec`
0. Build a local gem: `bundle exec rake build_gem`
0. Testing:
0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem
0. Install the new gem locally

View File

@@ -1,14 +1,16 @@
require 'json'
require 'bundler/setup'
require 'rake/clean'
require 'rake/testtask'
require 'yaml'
require 'yajl'
require 'open-uri'
task :default => :test
Rake::TestTask.new
# Extend test task to check for samples
task :test => :check_samples
# Extend test task to check for samples and fetch latest Ace modes
task :test => [:check_samples, :fetch_ace_modes]
desc "Check that we have samples.json generated"
task :check_samples do
@@ -17,21 +19,39 @@ task :check_samples do
end
end
desc "Fetch the latest Ace modes from its GitHub repository"
task :fetch_ace_modes do
ACE_FIXTURE_PATH = File.join('test', 'fixtures', 'ace_modes.json')
File.delete(ACE_FIXTURE_PATH) if File.exist?(ACE_FIXTURE_PATH)
begin
ace_github_modes = open("https://api.github.com/repos/ajaxorg/ace/contents/lib/ace/mode").read
File.write(ACE_FIXTURE_PATH, ace_github_modes)
rescue OpenURI::HTTPError, SocketError
# no internet? no problem.
end
end
task :samples do
require 'linguist/samples'
require 'yajl'
data = Linguist::Samples.data
json = Yajl::Encoder.encode(data, :pretty => true)
File.open('lib/linguist/samples.json', 'w') { |io| io.write json }
json = Yajl.dump(Linguist::Samples.data, :pretty => true)
File.write 'lib/linguist/samples.json', json
end
task :build_gem => :samples do
languages = YAML.load_file("lib/linguist/languages.yml")
File.write("lib/linguist/languages.json", JSON.dump(languages))
File.write("lib/linguist/languages.json", Yajl.dump(languages))
`gem build github-linguist.gemspec`
File.delete("lib/linguist/languages.json")
end
task :build_grammars_gem do
rm_rf "grammars"
sh "script/convert-grammars"
sh "gem", "build", "github-linguist-grammars.gemspec"
end
namespace :benchmark do
benchmark_path = "benchmark/results"
@@ -71,11 +91,11 @@ namespace :benchmark do
reference_file = ENV["REFERENCE"]
candidate_file = ENV["CANDIDATE"]
reference = JSON.parse(File.read(reference_file))
reference = Yajl.load(File.read(reference_file))
reference_counts = Hash.new(0)
reference.each { |filename, language| reference_counts[language] += 1 }
candidate = JSON.parse(File.read(candidate_file))
candidate = Yajl.load(File.read(candidate_file))
candidate_counts = Hash.new(0)
candidate.each { |filename, language| candidate_counts[language] += 1 }
@@ -125,14 +145,12 @@ namespace :classifier do
def each_public_gist
require 'open-uri'
require 'json'
url = "https://api.github.com/gists/public"
loop do
resp = open(url)
url = resp.meta['link'][/<([^>]+)>; rel="next"/, 1]
gists = JSON.parse(resp.read)
gists = Yajl.load(resp.read)
for gist in gists
for filename, attrs in gist['files']

View File

@@ -0,0 +1,14 @@
require File.expand_path('../lib/linguist/version', __FILE__)
Gem::Specification.new do |s|
s.name = 'github-linguist-grammars'
s.version = Linguist::VERSION
s.summary = "Language grammars for use with github-linguist"
s.authors = "GitHub"
s.homepage = "https://github.com/github/linguist"
s.files = ['lib/linguist/grammars.rb'] + Dir['grammars/*']
s.add_development_dependency 'plist', '~>3.1'
end

View File

@@ -10,15 +10,15 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/github/linguist"
s.license = "MIT"
s.files = Dir['lib/**/*']
s.files = Dir['lib/**/*'] - ['lib/linguist/grammars.rb']
s.executables << 'linguist'
s.add_dependency 'charlock_holmes', '~> 0.7.3'
s.add_dependency 'escape_utils', '~> 1.0.1'
s.add_dependency 'mime-types', '~> 1.19'
s.add_dependency 'pygments.rb', '~> 0.6.0'
s.add_dependency 'mime-types', '>= 1.19'
s.add_dependency 'rugged', '~> 0.22.0b4'
s.add_development_dependency 'json'
s.add_development_dependency 'minitest', '>= 5.0'
s.add_development_dependency 'mocha'
s.add_development_dependency 'pry'
s.add_development_dependency 'rake'

486
grammars.yml Normal file
View File

@@ -0,0 +1,486 @@
---
http://svn.edgewall.org/repos/genshi/contrib/textmate/Genshi.tmbundle/Syntaxes/Markup%20Template%20%28XML%29.tmLanguage:
- text.xml.genshi
http://svn.textmate.org/trunk/Review/Bundles/BlitzMax.tmbundle:
- source.blitzmax
http://svn.textmate.org/trunk/Review/Bundles/Cython.tmbundle:
- source.cython
http://svn.textmate.org/trunk/Review/Bundles/Forth.tmbundle:
- source.forth
http://svn.textmate.org/trunk/Review/Bundles/Parrot.tmbundle:
- source.parrot.pir
http://svn.textmate.org/trunk/Review/Bundles/SecondLife%20LSL.tmbundle:
- source.lsl
http://svn.textmate.org/trunk/Review/Bundles/VHDL.tmbundle:
- source.vhdl
http://svn.textmate.org/trunk/Review/Bundles/XQuery.tmbundle:
- source.xquery
https://bitbucket.org/Clams/sublimesystemverilog/get/default.tar.gz:
- source.systemverilog
- source.ucfconstraints
https://fan.googlecode.com/hg-history/Build%201.0.55/adm/tools/textmate/Fan.tmbundle/Syntaxes/Fan.tmLanguage:
- source.fan
vendor/grammars/Agda.tmbundle:
- source.agda
vendor/grammars/Alloy.tmbundle:
- source.alloy
vendor/grammars/AutoHotkey:
- source.ahk
vendor/grammars/CLIPS-sublime:
- source.clips
vendor/grammars/ColdFusion:
- source.cfscript
- source.cfscript.cfc
- text.cfml.basic
- text.html.cfm
vendor/grammars/Creole:
- text.html.creole
vendor/grammars/Docker.tmbundle:
- source.dockerfile
vendor/grammars/Elm.tmLanguage:
- source.elm
vendor/grammars/GDScript-sublime/:
- source.gdscript
vendor/grammars/Handlebars:
- text.html.handlebars
vendor/grammars/IDL-Syntax:
- source.webidl
vendor/grammars/Isabelle.tmbundle:
- source.isabelle.root
- source.isabelle.theory
vendor/grammars/JSyntax/:
- source.j
vendor/grammars/Julia.tmbundle:
- source.julia
vendor/grammars/LiveScript.tmbundle:
- source.livescript
vendor/grammars/Modelica/:
- source.modelica
vendor/grammars/NSIS:
- source.nsis
vendor/grammars/NimLime:
- source.nim
- source.nim_filter
- source.nimcfg
vendor/grammars/PHP-Twig.tmbundle:
- text.html.twig
vendor/grammars/RDoc.tmbundle:
- text.rdoc
vendor/grammars/Racket:
- source.racket
vendor/grammars/SCSS.tmbundle:
- source.scss
vendor/grammars/Scalate.tmbundle:
- source.scaml
- text.html.ssp
vendor/grammars/Slash.tmbundle:
- text.html.slash
vendor/grammars/Stata.tmbundle:
- source.mata
- source.stata
vendor/grammars/Sublime-Coq:
- source.coq
vendor/grammars/Sublime-HTTP:
- source.httpspec
vendor/grammars/Sublime-Inform:
- source.Inform7
vendor/grammars/Sublime-Lasso:
- file.lasso
vendor/grammars/Sublime-Logos:
- source.logos
vendor/grammars/Sublime-Loom:
- source.loomscript
vendor/grammars/Sublime-Nit:
- source.nit
vendor/grammars/Sublime-QML:
- source.qml
vendor/grammars/Sublime-REBOL:
- source.rebol
vendor/grammars/Sublime-SQF-Language:
- source.sqf
vendor/grammars/Sublime-Text-2-OpenEdge-ABL:
- source.abl
vendor/grammars/Sublime-VimL:
- source.viml
vendor/grammars/SublimeBrainfuck:
- source.bf
vendor/grammars/SublimeXtend:
- source.xtend
vendor/grammars/Textmate-Gosu-Bundle:
- source.gosu.2
vendor/grammars/VBDotNetSyntax:
- source.vbnet
vendor/grammars/Vala-TMBundle:
- source.vala
vendor/grammars/abap.tmbundle:
- source.abap
vendor/grammars/actionscript3-tmbundle:
- source.actionscript.3
- text.html.asdoc
- text.xml.flex-config
vendor/grammars/ada.tmbundle:
- source.ada
vendor/grammars/ant.tmbundle:
- text.xml.ant
vendor/grammars/antlr.tmbundle:
- source.antlr
vendor/grammars/apache.tmbundle:
- source.apache-config
- source.apache-config.mod_perl
vendor/grammars/applescript.tmbundle:
- source.applescript
vendor/grammars/asp.tmbundle:
- source.asp
- text.html.asp
vendor/grammars/assembly.tmbundle:
- objdump.x86asm
- source.x86asm
vendor/grammars/atom-salt:
- source.python.salt
- source.yaml.salt
vendor/grammars/ats.sublime:
- source.ats
vendor/grammars/autoitv3-tmbundle:
- source.autoit.3
vendor/grammars/awk-sublime:
- source.awk
vendor/grammars/bison.tmbundle:
- source.bison
vendor/grammars/boo-sublime:
- source.boo
vendor/grammars/bro-sublime:
- source.bro
vendor/grammars/c.tmbundle:
- source.c
- source.c++
- source.c.platform
vendor/grammars/capnproto.tmbundle:
- source.capnp
vendor/grammars/carto-atom:
- source.css.mss
vendor/grammars/ceylon-sublimetext:
- module.ceylon
- source.ceylon
vendor/grammars/chapel-tmbundle:
- source.chapel
vendor/grammars/cmake.tmbundle:
- source.cache.cmake
- source.cmake
vendor/grammars/cool-tmbundle:
- source.cool
vendor/grammars/cpp-qt.tmbundle:
- source.c++.qt
- source.qmake
vendor/grammars/css.tmbundle:
- source.css
vendor/grammars/cucumber-tmbundle:
- source.ruby.rspec.cucumber.steps
- text.gherkin.feature
vendor/grammars/d.tmbundle:
- source.d
vendor/grammars/dart-sublime-bundle:
- source.dart
- source.pubspec
- text.dart-doccomments
vendor/grammars/desktop.tmbundle:
- source.desktop
vendor/grammars/diff.tmbundle:
- source.diff
vendor/grammars/dylan.tmbundle:
- source.dylan
- source.lid
- source.makegen
vendor/grammars/ebundles/Bundles/MSDOS batch file.tmbundle:
- source.dosbatch
vendor/grammars/eiffel.tmbundle:
- source.eiffel
vendor/grammars/elixir-tmbundle:
- source.elixir
- text.elixir
- text.html.elixir
vendor/grammars/erlang.tmbundle:
- source.erlang
- text.html.erlang.yaws
vendor/grammars/factor:
- source.factor
- text.html.factor
vendor/grammars/fancy-tmbundle:
- source.fancy
vendor/grammars/fish-tmbundle:
- source.fish
vendor/grammars/fortran.tmbundle:
- source.fortran
- source.fortran.modern
vendor/grammars/fsharpbinding:
- source.fsharp
vendor/grammars/gettext.tmbundle:
- source.po
vendor/grammars/gnuplot-tmbundle:
- source.gnuplot
vendor/grammars/go-tmbundle:
- source.go
vendor/grammars/gradle.tmbundle:
- source.groovy.gradle
vendor/grammars/graphviz.tmbundle:
- source.dot
vendor/grammars/groovy.tmbundle:
- source.groovy
vendor/grammars/haskell.tmbundle:
- source.haskell
- text.tex.latex.haskell
vendor/grammars/haxe-sublime-bundle:
- source.erazor
- source.haxe.2
- source.hss.1
- source.hxml
- source.nmml
vendor/grammars/html.tmbundle:
- text.html.basic
vendor/grammars/idl.tmbundle:
- source.idl
- source.idl-dlm
- text.idl-idldoc
vendor/grammars/ini.tmbundle:
- source.ini
vendor/grammars/io.tmbundle:
- source.io
vendor/grammars/ioke-outdated:
- source.ioke
vendor/grammars/jade-tmbundle:
- source.jade
- source.pyjade
vendor/grammars/jasmin-sublime:
- source.jasmin
vendor/grammars/java.tmbundle:
- source.java
- source.java-properties
- text.html.jsp
- text.junit-test-report
vendor/grammars/javadoc.tmbundle:
- text.html.javadoc
vendor/grammars/javascript-objective-j.tmbundle:
- source.js.objj
vendor/grammars/jquery-tmbundle:
- source.js.jquery
vendor/grammars/json.tmbundle:
- source.json
vendor/grammars/kotlin-sublime-package:
- source.Kotlin
vendor/grammars/language-clojure:
- source.clojure
vendor/grammars/language-coffee-script:
- source.coffee
- source.litcoffee
vendor/grammars/language-csharp:
- source.cs
- source.csx
- source.nant-build
vendor/grammars/language-gfm:
- source.gfm
vendor/grammars/language-hy:
- source.hy
vendor/grammars/language-javascript:
- source.js
- source.js.regexp
vendor/grammars/language-python:
- source.python
- source.regexp.python
- text.python.console
- text.python.traceback
vendor/grammars/language-shellscript:
- source.shell
- text.shell-session
vendor/grammars/language-yaml:
- source.yaml
vendor/grammars/latex.tmbundle:
- text.bibtex
- text.log.latex
- text.tex
- text.tex.latex
- text.tex.latex.beamer
- text.tex.latex.memoir
vendor/grammars/less.tmbundle:
- source.css.less
vendor/grammars/lilypond.tmbundle:
- source.lilypond
vendor/grammars/liquid.tmbundle:
- text.html.liquid
vendor/grammars/lisp.tmbundle:
- source.lisp
vendor/grammars/llvm.tmbundle:
- source.llvm
vendor/grammars/logtalk.tmbundle:
- source.logtalk
vendor/grammars/lua.tmbundle:
- source.lua
vendor/grammars/make.tmbundle:
- source.makefile
vendor/grammars/mako-tmbundle:
- text.html.mako
vendor/grammars/mathematica-tmbundle:
- source.mathematica
vendor/grammars/matlab.tmbundle:
- source.matlab
- source.octave
vendor/grammars/maven.tmbundle:
- text.xml.pom
vendor/grammars/mercury-tmlanguage:
- source.mercury
vendor/grammars/monkey.tmbundle:
- source.monkey
vendor/grammars/moonscript-tmbundle:
- source.moonscript
vendor/grammars/nemerle.tmbundle:
- source.nemerle
vendor/grammars/nesC.tmbundle:
- source.nesc
vendor/grammars/ninja.tmbundle:
- source.ninja
vendor/grammars/objective-c.tmbundle:
- source.objc
- source.objc++
- source.objc.platform
- source.strings
vendor/grammars/ocaml.tmbundle:
- source.camlp4.ocaml
- source.ocaml
- source.ocamllex
- source.ocamlyacc
vendor/grammars/ooc.tmbundle:
- source.ooc
vendor/grammars/opa.tmbundle:
- source.opa
vendor/grammars/oz-tmbundle/Syntaxes/Oz.tmLanguage:
- source.oz
vendor/grammars/pascal.tmbundle:
- source.pascal
vendor/grammars/perl.tmbundle:
- source.perl
vendor/grammars/php-smarty.tmbundle:
- source.smarty
vendor/grammars/php.tmbundle:
- text.html.php
vendor/grammars/pike-textmate:
- source.pike
vendor/grammars/postscript.tmbundle:
- source.postscript
vendor/grammars/powershell:
- source.powershell
vendor/grammars/processing.tmbundle:
- source.processing
vendor/grammars/prolog.tmbundle:
- source.prolog
vendor/grammars/protobuf-tmbundle:
- source.protobuf
vendor/grammars/puppet-textmate-bundle:
- source.puppet
vendor/grammars/python-django.tmbundle:
- source.python.django
- text.html.django
vendor/grammars/r.tmbundle:
- source.r
- text.tex.latex.rd
vendor/grammars/restructuredtext.tmbundle:
- text.restructuredtext
vendor/grammars/ruby-haml.tmbundle:
- text.haml
vendor/grammars/ruby-on-rails-tmbundle:
- source.js.erb.rails
- source.ruby.rails
- source.ruby.rails.rjs
- source.sql.ruby
- text.html.erb.rails
vendor/grammars/ruby-slim.tmbundle:
- text.slim
vendor/grammars/ruby.tmbundle:
- source.ruby
- text.html.erb
vendor/grammars/sas.tmbundle:
- source.SASLog
- source.sas
vendor/grammars/sass-textmate-bundle:
- source.sass
vendor/grammars/scala.tmbundle:
- source.sbt
- source.scala
vendor/grammars/scheme.tmbundle:
- source.scheme
vendor/grammars/scilab.tmbundle:
- source.scilab
vendor/grammars/smalltalk-tmbundle:
- source.smalltalk
vendor/grammars/sql.tmbundle:
- source.sql
vendor/grammars/standard-ml.tmbundle:
- source.cm
- source.ml
vendor/grammars/sublime-MuPAD:
- source.mupad
vendor/grammars/sublime-apl/:
- source.apl
vendor/grammars/sublime-befunge:
- source.befunge
vendor/grammars/sublime-better-typescript:
- source.ts
vendor/grammars/sublime-bsv:
- source.bsv
vendor/grammars/sublime-cirru:
- source.cirru
vendor/grammars/sublime-glsl:
- source.essl
- source.glsl
vendor/grammars/sublime-golo/:
- source.golo
vendor/grammars/sublime-idris:
- source.idris
vendor/grammars/sublime-mask:
- source.mask
vendor/grammars/sublime-nginx:
- source.nginx
vendor/grammars/sublime-nix:
- source.nix
vendor/grammars/sublime-robot-plugin:
- text.robot
vendor/grammars/sublime-rust:
- source.rust
vendor/grammars/sublime-sourcepawn:
- source.sp
vendor/grammars/sublime-tea:
- source.tea
vendor/grammars/sublime_cobol:
- source.acucobol
- source.cobol
- source.opencobol
vendor/grammars/sublime_man_page_support:
- source.man
- text.groff
vendor/grammars/sublimetext-cuda-cpp:
- source.cuda-c++
vendor/grammars/swift.tmbundle:
- source.swift
vendor/grammars/tcl.tmbundle:
- source.tcl
- text.html.tcl
vendor/grammars/text.tmbundle:
- text.plain
vendor/grammars/textile.tmbundle:
- text.html.textile
vendor/grammars/textmate.tmbundle:
- source.regexp.oniguruma
- source.tm-properties
vendor/grammars/thrift.tmbundle:
- source.thrift
vendor/grammars/toml.tmbundle:
- source.toml
vendor/grammars/turtle.tmbundle:
- source.sparql
- source.turtle
vendor/grammars/verilog.tmbundle:
- source.verilog
vendor/grammars/x86-assembly-textmate-bundle:
- source.asm.x86
vendor/grammars/xml.tmbundle:
- text.xml
- text.xml.xsl
vendor/grammars/zephir-sublime:
- source.php.zephir

View File

@@ -4,4 +4,5 @@ require 'linguist/heuristics'
require 'linguist/language'
require 'linguist/repository'
require 'linguist/samples'
require 'linguist/shebang'
require 'linguist/version'

View File

@@ -2,7 +2,6 @@ require 'linguist/generated'
require 'charlock_holmes'
require 'escape_utils'
require 'mime/types'
require 'pygments'
require 'yaml'
module Linguist
@@ -147,6 +146,13 @@ module Linguist
end
end
# Public: Is the blob empty?
#
# Return true or false
def empty?
data.nil? || data == ""
end
# Public: Is the blob text?
#
# Return true or false
@@ -193,10 +199,6 @@ module Linguist
# Public: Is the blob safe to colorize?
#
# We use Pygments for syntax highlighting blobs. Pygments
# can be too slow for very large blobs or for certain
# corner-case blobs.
#
# Return true or false
def safe_to_colorize?
!large? && text? && !high_ratio_of_long_lines?
@@ -204,9 +206,6 @@ module Linguist
# Internal: Does the blob have a ratio of long lines?
#
# These types of files are usually going to make Pygments.rb
# angry if we try to colorize them.
#
# Return true or false
def high_ratio_of_long_lines?
return false if loc == 0
@@ -314,28 +313,9 @@ module Linguist
@language ||= Language.detect(self)
end
# Internal: Get the lexer of the blob.
#
# Returns a Lexer.
def lexer
language ? language.lexer : Pygments::Lexer.find_by_name('Text only')
end
# Internal: Get the TextMate compatible scope for the blob
def tm_scope
language && language.tm_scope
end
# Public: Highlight syntax of blob
#
# options - A Hash of options (defaults to {})
#
# Returns html String
def colorize(options = {})
return unless safe_to_colorize?
options[:options] ||= {}
options[:options][:encoding] ||= encoding
lexer.highlight(data, options)
end
end
end

View File

@@ -3,6 +3,25 @@ require 'linguist/tokenizer'
module Linguist
# Language bayesian classifier.
class Classifier
# Public: Use the classifier to detect language of the blob.
#
# blob - An object that quacks like a blob.
# possible_languages - Array of Language objects
#
# Examples
#
# Classifier.call(FileBlob.new("path/to/file"), [
# Language["Ruby"], Language["Python"]
# ])
#
# Returns an Array of Language objects, most probable first.
def self.call(blob, possible_languages)
language_names = possible_languages.map(&:name)
classify(Samples.cache, blob.data, language_names).map do |name, _|
Language[name] # Return the actual Language objects
end
end
# Public: Train classifier that data is a certain language.
#
# db - Hash classifier database object

View File

@@ -57,14 +57,20 @@ module Linguist
#
# Returns a String.
def extension
# File.extname returns nil if the filename is an extension.
extension = File.extname(name)
basename = File.basename(name)
# Checks if the filename is an extension.
if extension.empty? && basename[0] == "."
basename
else
extension
extensions.last || ""
end
# Public: Return an array of the file extensions
#
# >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions
# => [".html.erb", ".erb"]
#
# Returns an Array
def extensions
basename, *segments = File.basename(name).split(".")
segments.map.with_index do |segment, index|
"." + segments[index..-1].join(".")
end
end
end

View File

@@ -51,26 +51,25 @@ module Linguist
#
# Return true or false
def generated?
name == 'Gemfile.lock' ||
minified_files? ||
compiled_coffeescript? ||
xcode_file? ||
generated_parser? ||
generated_net_docfile? ||
generated_net_designer_file? ||
generated_postscript? ||
generated_protocol_buffer? ||
generated_jni_header? ||
composer_lock? ||
node_modules? ||
godeps? ||
vcr_cassette? ||
generated_by_zephir?
xcode_file? ||
generated_net_designer_file? ||
composer_lock? ||
node_modules? ||
godeps? ||
generated_by_zephir? ||
minified_files? ||
compiled_coffeescript? ||
generated_parser? ||
generated_net_docfile? ||
generated_postscript? ||
generated_protocol_buffer? ||
generated_jni_header? ||
vcr_cassette?
end
# Internal: Is the blob an Xcode file?
#
# Generated if the file extension is an Xcode
# Generated if the file extension is an Xcode
# file extension.
#
# Returns true of false.
@@ -265,4 +264,3 @@ module Linguist
end
end
end

13
lib/linguist/grammars.rb Normal file
View File

@@ -0,0 +1,13 @@
# Note: This file is included in the github-linguist-grammars gem, not the
# github-linguist gem.
module Linguist
module Grammars
# Get the path to the directory containing the language grammar JSON files.
#
# Returns a String.
def self.path
File.expand_path("../../../grammars", __FILE__)
end
end
end

View File

@@ -1,95 +1,227 @@
module Linguist
# A collection of simple heuristics that can be used to better analyze languages.
class Heuristics
ACTIVE = true
# Public: Use heuristics to detect language of the blob.
#
# blob - An object that quacks like a blob.
# possible_languages - Array of Language objects
#
# Examples
#
# Heuristics.call(FileBlob.new("path/to/file"), [
# Language["Ruby"], Language["Python"]
# ])
#
# Returns an Array of languages, or empty if none matched or were inconclusive.
def self.call(blob, languages)
data = blob.data
# Public: Given an array of String language names,
# apply heuristics against the given data and return an array
# of matching languages, or nil.
@heuristics.each do |heuristic|
return Array(heuristic.call(data)) if heuristic.matches?(languages)
end
[] # No heuristics matched
end
# Internal: Define a new heuristic.
#
# data - Array of tokens or String data to analyze.
# languages - Array of language name Strings to restrict to.
# languages - String names of languages to disambiguate.
# heuristic - Block which takes data as an argument and returns a Language or nil.
#
# Returns an array of Languages or []
def self.find_by_heuristics(data, languages)
if active?
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
result = disambiguate_pl(data, languages)
end
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
result = disambiguate_ecl(data, languages)
end
if languages.all? { |l| ["IDL", "Prolog"].include?(l) }
result = disambiguate_pro(data, languages)
end
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
result = disambiguate_cl(data, languages)
end
return result
# Examples
#
# disambiguate "Perl", "Prolog" do |data|
# if data.include?("use strict")
# Language["Perl"]
# elsif data.include?(":-")
# Language["Prolog"]
# end
# end
#
def self.disambiguate(*languages, &heuristic)
@heuristics << new(languages, &heuristic)
end
# Internal: Array of defined heuristics
@heuristics = []
# Internal
def initialize(languages, &heuristic)
@languages = languages
@heuristic = heuristic
end
# Internal: Check if this heuristic matches the candidate languages.
def matches?(candidates)
candidates.any? && candidates.all? { |l| @languages.include?(l.name) }
end
# Internal: Perform the heuristic
def call(data)
@heuristic.call(data)
end
# Common heuristics
ObjectiveCRegex = /^[ \t]*@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/
disambiguate "BitBake", "BlitzBasic" do |data|
if /^\s*; /.match(data) || data.include?("End Function")
Language["BlitzBasic"]
elsif /^\s*(# |include|require)\b/.match(data)
Language["BitBake"]
end
end
# .h extensions are ambiguous between C, C++, and Objective-C.
# We want to shortcut look for Objective-C _and_ now C++ too!
#
# Returns an array of Languages or []
def self.disambiguate_c(data, languages)
matches = []
matches << Language["Objective-C"] if data.include?("@interface")
matches << Language["C++"] if data.include?("#include <cstdint>")
matches
disambiguate "C#", "Smalltalk" do |data|
if /![\w\s]+methodsFor: /.match(data)
Language["Smalltalk"]
elsif /^\s*namespace\s*[\w\.]+\s*{/.match(data) || /^\s*\/\//.match(data)
Language["C#"]
end
end
def self.disambiguate_pl(data, languages)
matches = []
matches << Language["Prolog"] if data.include?(":-")
matches << Language["Perl"] if data.include?("use strict")
matches
disambiguate "Objective-C", "C++", "C" do |data|
if ObjectiveCRegex.match(data)
Language["Objective-C"]
elsif (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set|(i|o|io)stream)>/.match(data) ||
/^\s*template\s*</.match(data) || /^[ \t]*try/.match(data) || /^[ \t]*catch\s*\(/.match(data) || /^[ \t]*(class|(using[ \t]+)?namespace)\s+\w+/.match(data) || /^[ \t]*(private|public|protected):$/.match(data) || /std::\w+/.match(data))
Language["C++"]
end
end
def self.disambiguate_ecl(data, languages)
matches = []
matches << Language["Prolog"] if data.include?(":-")
matches << Language["ECL"] if data.include?(":=")
matches
disambiguate "Perl", "Perl6", "Prolog" do |data|
if data.include?("use v6")
Language["Perl6"]
elsif data.include?("use strict")
Language["Perl"]
elsif data.include?(":-")
Language["Prolog"]
end
end
def self.disambiguate_pro(data, languages)
matches = []
if (data.include?(":-"))
matches << Language["Prolog"]
disambiguate "ECL", "Prolog" do |data|
if data.include?(":-")
Language["Prolog"]
elsif data.include?(":=")
Language["ECL"]
end
end
disambiguate "IDL", "Prolog" do |data|
if data.include?(":-")
Language["Prolog"]
else
matches << Language["IDL"]
Language["IDL"]
end
matches
end
def self.disambiguate_ts(data, languages)
matches = []
if (data.include?("</translation>"))
matches << Language["XML"]
disambiguate "GAP", "Scilab" do |data|
if (data.include?("gap> "))
Language["GAP"]
# Heads up - we don't usually write heuristics like this (with no regex match)
else
matches << Language["TypeScript"]
Language["Scilab"]
end
matches
end
def self.disambiguate_cl(data, languages)
matches = []
matches << Language["Common Lisp"] if data.include?("(defun ")
matches << Language["OpenCL"] if /\/\* |\/\/ |^\}/.match(data)
matches
disambiguate "Common Lisp", "OpenCL", "Cool" do |data|
if data.include?("(defun ")
Language["Common Lisp"]
elsif /^class/x.match(data)
Language["Cool"]
elsif /\/\* |\/\/ |^\}/.match(data)
Language["OpenCL"]
end
end
def self.disambiguate_r(data, languages)
matches = []
matches << Language["Rebol"] if /\bRebol\b/i.match(data)
matches << Language["R"] if data.include?("<-")
matches
disambiguate "Hack", "PHP" do |data|
if data.include?("<?hh")
Language["Hack"]
elsif /<?[^h]/.match(data)
Language["PHP"]
end
end
def self.active?
!!ACTIVE
disambiguate "Scala", "SuperCollider" do |data|
if /\^(this|super)\./.match(data) || /^\s*(\+|\*)\s*\w+\s*{/.match(data) || /^\s*~\w+\s*=\./.match(data)
Language["SuperCollider"]
elsif /^\s*import (scala|java)\./.match(data) || /^\s*val\s+\w+\s*=/.match(data) || /^\s*class\b/.match(data)
Language["Scala"]
end
end
disambiguate "AsciiDoc", "AGS Script" do |data|
Language["AsciiDoc"] if /^=+(\s|\n)/.match(data)
end
disambiguate "FORTRAN", "Forth" do |data|
if /^: /.match(data)
Language["Forth"]
elsif /^([c*][^a-z]| (subroutine|program)\s|!)/i.match(data)
Language["FORTRAN"]
end
end
disambiguate "F#", "Forth", "GLSL" do |data|
if /^(: |new-device)/.match(data)
Language["Forth"]
elsif /^\s*(#light|import|let|module|namespace|open|type)/.match(data)
Language["F#"]
elsif /^\s*(#include|#pragma|precision|uniform|varying|void)/.match(data)
Language["GLSL"]
end
end
disambiguate "M", "Mathematica", "Matlab", "Mercury", "Objective-C" do |data|
if ObjectiveCRegex.match(data)
Language["Objective-C"]
elsif data.include?(":- module")
Language["Mercury"]
elsif /^\s*;/.match(data)
Language["M"]
elsif /^\s*\(\*/.match(data)
Language["Mathematica"]
elsif /^\s*%/.match(data)
Language["Matlab"]
end
end
disambiguate "Gosu", "JavaScript" do |data|
Language["Gosu"] if /^uses java\./.match(data)
end
disambiguate "LoomScript", "LiveScript" do |data|
if /^\s*package\s*[\w\.\/\*\s]*\s*{/.match(data)
Language["LoomScript"]
else
Language["LiveScript"]
end
end
disambiguate "Common Lisp", "NewLisp" do |data|
if /^\s*\((defun|in-package|defpackage) /.match(data)
Language["Common Lisp"]
elsif /^\s*\(define /.match(data)
Language["NewLisp"]
end
end
disambiguate "TypeScript", "XML" do |data|
if data.include?("<TS ")
Language["XML"]
else
Language["TypeScript"]
end
end
disambiguate "Frege", "Forth", "Text" do |data|
if /^(: |also |new-device|previous )/.match(data)
Language["Forth"]
elsif /^\s*(import|module|package|data|type) /.match(data)
Language["Frege"]
else
Language["Text"]
end
end
end
end

View File

@@ -1,8 +1,7 @@
require 'escape_utils'
require 'pygments'
require 'yaml'
begin
require 'json'
require 'yajl'
rescue LoadError
end
@@ -11,6 +10,9 @@ require 'linguist/heuristics'
require 'linguist/samples'
require 'linguist/file_blob'
require 'linguist/blob_helper'
require 'linguist/strategy/filename'
require 'linguist/strategy/modeline'
require 'linguist/shebang'
module Linguist
# Language names that are recognizable by GitHub. Defined languages
@@ -62,7 +64,7 @@ module Linguist
end
# Language name index
@index[language.name] = @name_index[language.name] = language
@index[language.name.downcase] = @name_index[language.name.downcase] = language
language.aliases.each do |name|
# All Language aliases should be unique. Raise if there is a duplicate.
@@ -70,7 +72,7 @@ module Linguist
raise ArgumentError, "Duplicate alias: #{name}"
end
@index[name] = @alias_index[name] = language
@index[name.downcase] = @alias_index[name.downcase] = language
end
language.extensions.each do |extension|
@@ -92,6 +94,14 @@ module Linguist
language
end
STRATEGIES = [
Linguist::Strategy::Modeline,
Linguist::Strategy::Filename,
Linguist::Shebang,
Linguist::Heuristics,
Linguist::Classifier
]
# Public: Detects the Language of the blob.
#
# blob - an object that includes the Linguist `BlobHelper` interface;
@@ -99,51 +109,22 @@ module Linguist
#
# Returns Language or nil.
def self.detect(blob)
name = blob.name.to_s
# Bail early if the blob is binary or empty.
return nil if blob.likely_binary? || blob.binary? || blob.empty?
# Check if the blob is possibly binary and bail early; this is a cheap
# test that uses the extension name to guess a binary binary mime type.
#
# We'll perform a more comprehensive test later which actually involves
# looking for binary characters in the blob
return nil if blob.likely_binary? || blob.binary?
# A bit of an elegant hack. If the file is executable but extensionless,
# append a "magic" extension so it can be classified with other
# languages that have shebang scripts.
extension = FileBlob.new(name).extension
if extension.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05
name += ".script!"
end
# First try to find languages that match based on filename.
possible_languages = find_by_filename(name)
# If there is more than one possible language with that extension (or no
# extension at all, in the case of extensionless scripts), we need to continue
# our detection work
if possible_languages.length > 1
data = blob.data
possible_language_names = possible_languages.map(&:name)
# Don't bother with binary contents or an empty file
if data.nil? || data == ""
nil
# Check if there's a shebang line and use that as authoritative
elsif (result = find_by_shebang(data)) && !result.empty?
result.first
# No shebang. Still more work to do. Try to find it with our heuristics.
elsif (determined = Heuristics.find_by_heuristics(data, possible_language_names)) && !determined.empty?
determined.first
# Lastly, fall back to the probabilistic classifier.
elsif classified = Classifier.classify(Samples.cache, data, possible_language_names).first
# Return the actual Language object based of the string language name (i.e., first element of `#classify`)
Language[classified[0]]
# Call each strategy until one candidate is returned.
STRATEGIES.reduce([]) do |languages, strategy|
candidates = strategy.call(blob, languages)
if candidates.size == 1
return candidates.first
elsif candidates.size > 1
# More than one candidate was found, pass them to the next strategy.
candidates
else
# No candiates were found, pass on languages from the previous strategy.
languages
end
else
# Simplest and most common case, we can just return the one match based on extension
possible_languages.first
end
end.first
end
# Public: Get all Languages
@@ -164,7 +145,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.find_by_name(name)
@name_index[name]
name && @name_index[name.downcase]
end
# Public: Look up Language by one of its aliases.
@@ -176,9 +157,9 @@ module Linguist
# Language.find_by_alias('cpp')
# # => #<Language name="C++">
#
# Returns the Lexer or nil if none was found.
# Returns the Language or nil if none was found.
def self.find_by_alias(name)
@alias_index[name]
name && @alias_index[name.downcase]
end
# Public: Look up Languages by filename.
@@ -193,27 +174,54 @@ module Linguist
# Returns all matching Languages or [] if none were found.
def self.find_by_filename(filename)
basename = File.basename(filename)
extname = FileBlob.new(filename).extension
langs = @filename_index[basename] +
@extension_index[extname]
langs.compact.uniq
# find the first extension with language definitions
extname = FileBlob.new(filename).extensions.detect do |e|
!@extension_index[e].empty?
end
(@filename_index[basename] + @extension_index[extname]).compact.uniq
end
# Public: Look up Languages by shebang line.
# Public: Look up Languages by file extension.
#
# data - Array of tokens or String data to analyze.
# extname - The extension String.
#
# Examples
#
# Language.find_by_shebang("#!/bin/bash\ndate;")
# Language.find_by_extension('.rb')
# # => [#<Language name="Ruby">]
#
# Language.find_by_extension('rb')
# # => [#<Language name="Ruby">]
#
# Returns all matching Languages or [] if none were found.
def self.find_by_extension(extname)
extname = ".#{extname}" unless extname.start_with?(".")
@extension_index[extname]
end
# DEPRECATED
def self.find_by_shebang(data)
@interpreter_index[Shebang.interpreter(data)]
end
# Public: Look up Languages by interpreter.
#
# interpreter - String of interpreter name
#
# Examples
#
# Language.find_by_interpreter("bash")
# # => [#<Language name="Bash">]
#
# Returns the matching Language
def self.find_by_shebang(data)
@interpreter_index[Linguist.interpreter_from_shebang(data)]
def self.find_by_interpreter(interpreter)
@interpreter_index[interpreter]
end
# Public: Look up Language by its name or lexer.
# Public: Look up Language by its name.
#
# name - The String name of the Language
#
@@ -227,7 +235,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.[](name)
@index[name]
name && @index[name.downcase]
end
# Public: A List of popular languages
@@ -237,7 +245,7 @@ module Linguist
#
# This list is configured in "popular.yml".
#
# Returns an Array of Lexers.
# Returns an Array of Languages.
def self.popular
@popular ||= all.select(&:popular?).sort_by { |lang| lang.name.downcase }
end
@@ -249,7 +257,7 @@ module Linguist
#
# This list is created from all the languages not listed in "popular.yml".
#
# Returns an Array of Lexers.
# Returns an Array of Languages.
def self.unpopular
@unpopular ||= all.select(&:unpopular?).sort_by { |lang| lang.name.downcase }
end
@@ -263,8 +271,12 @@ module Linguist
# Public: A List of languages compatible with Ace.
#
# TODO: Remove this method in a 5.x release. Every language now needs an ace_mode
# key, so this function isn't doing anything unique anymore.
#
# Returns an Array of Languages.
def self.ace_modes
warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set."
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
end
@@ -286,10 +298,7 @@ module Linguist
# Set aliases
@aliases = [default_alias_name] + (attributes[:aliases] || [])
# Lookup Lexer object
@lexer = Pygments::Lexer.find_by_name(attributes[:lexer] || name) ||
raise(ArgumentError, "#{@name} is missing lexer")
# Load the TextMate scope name or try to guess one
@tm_scope = attributes[:tm_scope] || begin
context = case @type
when :data, :markup, :prose
@@ -368,11 +377,6 @@ module Linguist
# Returns the name String
attr_reader :search_term
# Public: Get Lexer
#
# Returns the Lexer
attr_reader :lexer
# Public: Get the name of a TextMate-compatible scope
#
# Returns the scope
@@ -421,11 +425,6 @@ module Linguist
# Returns the extensions Array
attr_reader :filenames
# Public: Return all possible extensions for language
def all_extensions
(extensions + [primary_extension]).uniq
end
# Deprecated: Get primary extension
#
# Defaults to the first extension but can be overridden
@@ -493,16 +492,6 @@ module Linguist
@searchable
end
# Public: Highlight syntax of text
#
# text - String of code to be highlighted
# options - A Hash of options (defaults to {})
#
# Returns html String
def colorize(text, options = {})
lexer.highlight(text, options)
end
# Public: Return name as String representation
def to_s
name
@@ -533,8 +522,8 @@ module Linguist
languages_yml = File.expand_path("../languages.yml", __FILE__)
languages_json = File.expand_path("../languages.json", __FILE__)
if File.exist?(languages_json) && defined?(JSON)
languages = JSON.load(File.read(languages_json))
if File.exist?(languages_json) && defined?(Yajl)
languages = Yajl.load(File.read(languages_json))
else
languages = YAML.load_file(languages_yml)
end
@@ -546,7 +535,7 @@ module Linguist
if extnames = extensions[name]
extnames.each do |extname|
if !options['extensions'].include?(extname)
if !options['extensions'].index { |x| x.end_with? extname }
warn "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
options['extensions'] << extname
end
@@ -578,14 +567,13 @@ module Linguist
:color => options['color'],
:type => options['type'],
:aliases => options['aliases'],
:lexer => options['lexer'],
:tm_scope => options['tm_scope'],
:ace_mode => options['ace_mode'],
:wrap => options['wrap'],
:group_name => options['group'],
:searchable => options.key?('searchable') ? options['searchable'] : true,
:searchable => options.fetch('searchable', true),
:search_term => options['search_term'],
:extensions => [options['extensions'].first] + options['extensions'][1..-1].sort,
:extensions => Array(options['extensions']),
:interpreters => options['interpreters'].sort,
:filenames => options['filenames'],
:popular => popular.include?(name)

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,6 @@
# This file should only be edited by GitHub staff
- ActionScript
- Bash
- C
- C#
- C++
@@ -27,3 +26,4 @@
- SQL
- Scala
- Scheme
- Shell

View File

@@ -128,13 +128,20 @@ module Linguist
protected
def compute_stats(old_commit_oid, cache = nil)
file_map = cache ? cache.dup : {}
old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree
read_index
diff = Rugged::Tree.diff(repository, old_tree, current_tree)
# Clear file map and fetch full diff if any .gitattributes files are changed
if cache && diff.each_delta.any? { |delta| File.basename(delta.new_file[:path]) == ".gitattributes" }
diff = Rugged::Tree.diff(repository, old_tree = nil, current_tree)
file_map = {}
else
file_map = cache ? cache.dup : {}
end
diff.each_delta do |delta|
old = delta.old_file[:path]
new = delta.new_file[:path]

View File

@@ -1,11 +1,12 @@
begin
require 'json'
require 'yajl'
rescue LoadError
require 'yaml'
end
require 'linguist/md5'
require 'linguist/classifier'
require 'linguist/shebang'
module Linguist
# Model for accessing classifier training data.
@@ -19,7 +20,7 @@ module Linguist
# Hash of serialized samples object
def self.cache
@cache ||= begin
serializer = defined?(JSON) ? JSON : YAML
serializer = defined?(Yajl) ? Yajl : YAML
serializer.load(File.read(PATH))
end
end
@@ -33,10 +34,6 @@ module Linguist
Dir.entries(ROOT).sort!.each do |category|
next if category == '.' || category == '..'
# Skip text and binary for now
# Possibly reconsider this later
next if category == 'Text' || category == 'Binary'
dirname = File.join(ROOT, category)
Dir.entries(dirname).each do |filename|
next if filename == '.' || filename == '..'
@@ -52,14 +49,16 @@ module Linguist
})
end
else
path = File.join(dirname, filename)
if File.extname(filename) == ""
raise "#{File.join(dirname, filename)} is missing an extension, maybe it belongs in filenames/ subdir"
raise "#{path} is missing an extension, maybe it belongs in filenames/ subdir"
end
yield({
:path => File.join(dirname, filename),
:path => path,
:language => category,
:interpreter => File.exist?(filename) ? Linguist.interpreter_from_shebang(File.read(filename)) : nil,
:interpreter => Shebang.interpreter(File.read(path)),
:extname => File.extname(filename)
})
end
@@ -112,40 +111,4 @@ module Linguist
db
end
end
# Used to retrieve the interpreter from the shebang line of a file's
# data.
def self.interpreter_from_shebang(data)
lines = data.lines.to_a
if lines.any? && (match = lines[0].match(/(.+)\n?/)) && (bang = match[0]) =~ /^#!/
bang.sub!(/^#! /, '#!')
tokens = bang.split(' ')
pieces = tokens.first.split('/')
if pieces.size > 1
script = pieces.last
else
script = pieces.first.sub('#!', '')
end
script = script == 'env' ? tokens[1] : script
# "python2.6" -> "python"
if script =~ /((?:\d+\.?)+)/
script.sub! $1, ''
end
# Check for multiline shebang hacks that call `exec`
if script == 'sh' &&
lines[0...5].any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
script = $1
end
script
else
nil
end
end
end

53
lib/linguist/shebang.rb Normal file
View File

@@ -0,0 +1,53 @@
module Linguist
class Shebang
# Public: Use shebang to detect language of the blob.
#
# blob - An object that quacks like a blob.
#
# Examples
#
# Shebang.call(FileBlob.new("path/to/file"))
#
# Returns an Array with one Language if the blob has a shebang with a valid
# interpreter, or empty if there is no shebang.
def self.call(blob, _ = nil)
Language.find_by_interpreter interpreter(blob.data)
end
# Public: Get the interpreter from the shebang
#
# Returns a String or nil
def self.interpreter(data)
shebang = data.lines.first
# First line must start with #!
return unless shebang && shebang.start_with?("#!")
# Get the parts of the shebang without the #!
tokens = shebang.sub(/^#!\s*/, '').strip.split(' ')
# There was nothing after the #!
return if tokens.empty?
# Get the name of the interpreter
script = File.basename(tokens.first)
# Get next argument if interpreter was /usr/bin/env
script = tokens[1] if script == 'env'
# Interpreter was /usr/bin/env with no arguments
return unless script
# "python2.6" -> "python2"
script.sub! /(\.\d+)$/, ''
# Check for multiline shebang hacks that call `exec`
if script == 'sh' &&
data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
script = $1
end
File.basename(script)
end
end
end

View File

@@ -0,0 +1,20 @@
module Linguist
module Strategy
# Detects language based on filename and/or extension
class Filename
def self.call(blob, _)
name = blob.name.to_s
# A bit of an elegant hack. If the file is executable but extensionless,
# append a "magic" extension so it can be classified with other
# languages that have shebang scripts.
extensions = FileBlob.new(name).extensions
if extensions.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05
name += ".script!"
end
Language.find_by_filename(name)
end
end
end
end

View File

@@ -0,0 +1,30 @@
module Linguist
module Strategy
class Modeline
EmacsModeline = /-\*-\s*mode:\s*(\w+);?\s*-\*-/
VimModeline = /\/\*\s*vim:\s*set\s*(?:ft|filetype)=(\w+):\s*\*\//
# Public: Detects language based on Vim and Emacs modelines
#
# blob - An object that quacks like a blob.
#
# Examples
#
# Modeline.call(FileBlob.new("path/to/file"))
#
# Returns an Array with one Language if the blob has a Vim or Emacs modeline
# that matches a Language name or alias. Returns an empty array if no match.
def self.call(blob, _ = nil)
Array(Language.find_by_alias(modeline(blob.data)))
end
# Public: Get the modeline from the first n-lines of the file
#
# Returns a String or nil
def self.modeline(data)
match = data.match(EmacsModeline) || data.match(VimModeline)
match[1] if match
end
end
end
end

View File

@@ -33,7 +33,8 @@ module Linguist
['<!--', '-->'], # XML
['{-', '-}'], # Haskell
['(*', '*)'], # Coq
['"""', '"""'] # Python
['"""', '"""'], # Python
["'''", "'''"] # Python
]
START_SINGLE_LINE_COMMENT = Regexp.compile(SINGLE_LINE_COMMENTS.map { |c|

View File

@@ -32,31 +32,35 @@
# Erlang bundles
- ^rebar$
- erlang.mk
# Go dependencies
- Godeps/_workspace/
# Bootstrap minified css and js
- (^|/)bootstrap([^.]*)(\.min)?\.(js|css)$
# Minified JavaScript and CSS
- (\.|-)min\.(js|css)$
#Stylesheets imported from packages
- ([^\s]*)import\.(css|less|scss|styl)$
# Bootstrap css and js
- (^|/)bootstrap([^.]*)\.(js|css|less|scss|styl)$
- (^|/)custom\.bootstrap([^\s]*)(js|css|less|scss|styl)$
# Font Awesome
- font-awesome.min.css
- font-awesome.css
- (^|/)font-awesome\.(css|less|scss|styl)$
# Foundation css
- foundation.min.css
- foundation.css
- (^|/)foundation\.(css|less|scss|styl)$
# Normalize.css
- normalize.css
- (^|/)normalize\.(css|less|scss|styl)$
# Bourbon SCSS
- (^|/)[Bb]ourbon/.*\.css$
- (^|/)[Bb]ourbon/.*\.scss$
# Bourbon css
- (^|/)[Bb]ourbon/.*\.(css|less|scss|styl)$
# Animate.css
- animate.css
- animate.min.css
- (^|/)animate\.(css|less|scss|styl)$
# Vendored dependencies
- third[-_]?party/
@@ -73,12 +77,12 @@
## Commonly Bundled JavaScript frameworks ##
# jQuery
- (^|/)jquery([^.]*)(\.min)?\.js$
- (^|/)jquery\-\d\.\d+(\.\d+)?(\.min)?\.js$
- (^|/)jquery([^.]*)\.js$
- (^|/)jquery\-\d\.\d+(\.\d+)?\.js$
# jQuery UI
- (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$
- (^|/)jquery\.(ui|effects)\.([^.]*)(\.min)?\.(js|css)$
- (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?\.(js|css)$
- (^|/)jquery\.(ui|effects)\.([^.]*)\.(js|css)$
# Prototype
- (^|/)prototype(.*)\.js$
@@ -110,27 +114,32 @@
# MathJax
- (^|/)MathJax/
# Chart.js
- (^|/)Chart\.js$
# Codemirror
- (^|/)[Cc]ode[Mm]irror/(lib|mode|theme|addon|keymap)
# SyntaxHighlighter - http://alexgorbatchev.com/
- (^|/)shBrush([^.]*)\.js$
- (^|/)shCore\.js$
- (^|/)shLegacy\.js$
# AngularJS
- (^|/)angular([^.]*)(\.min)?\.js$
- (^|/)angular([^.]*)\.js$
# D3.js
- (^|\/)d3(\.v\d+)?([^.]*)(\.min)?\.js$
- (^|\/)d3(\.v\d+)?([^.]*)\.js$
# React
- (^|/)react(-[^.]*)?(\.min)?\.js$
- (^|/)react(-[^.]*)?\.js$
# Modernizr
- (^|/)modernizr\-\d\.\d+(\.\d+)?(\.min)?\.js$
- (^|/)modernizr\-\d\.\d+(\.\d+)?\.js$
- (^|/)modernizr\.custom\.\d+\.js$
# Knockout
- (^|/)knockout-(\d+\.){3}(debug\.)?js$
- knockout-min.js
## Python ##
@@ -168,8 +177,8 @@
- \.intellisense\.js$
# jQuery validation plugin (MS bundles this with asp.net mvc)
- (^|/)jquery([^.]*)\.validate(\.unobtrusive)?(\.min)?\.js$
- (^|/)jquery([^.]*)\.unobtrusive\-ajax(\.min)?\.js$
- (^|/)jquery([^.]*)\.validate(\.unobtrusive)?\.js$
- (^|/)jquery([^.]*)\.unobtrusive\-ajax\.js$
# Microsoft Ajax
- (^|/)[Mm]icrosoft([Mm]vc)?([Aa]jax|[Vv]alidation)(\.debug)?\.js$
@@ -196,7 +205,7 @@
- (^|/)extjs/welcome/
# Html5shiv
- (^|/)html5shiv(\.min)?\.js$
- (^|/)html5shiv\.js$
# Samples folders
- ^[Ss]amples/
@@ -215,8 +224,8 @@
- ^[Tt]est/fixtures/
# PhoneGap/Cordova
- (^|/)cordova([^.]*)(\.min)?\.js$
- (^|/)cordova\-\d\.\d(\.\d)?(\.min)?\.js$
- (^|/)cordova([^.]*)\.js$
- (^|/)cordova\-\d\.\d(\.\d)?\.js$
# Foundation js
- foundation(\..*)?\.js$
@@ -227,18 +236,18 @@
# .DS_Store's
- .[Dd][Ss]_[Ss]tore$
# Mercury --use-subdirs
- Mercury/
# R packages
- ^vignettes/
- ^inst/extdata/
# Octicons
- octicons.css
- octicons.min.css
- sprockets-octicons.scss
# Typesafe Activator
- (^|/)activator$
- (^|/)activator\.bat$
# ProGuard
- proguard.pro
- proguard-rules.pro

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "3.3.0"
VERSION = "4.3.1"
end

6
package.json Normal file
View File

@@ -0,0 +1,6 @@
{
"repository": "https://github.com/github/linguist",
"dependencies": {
"season": "~>3.0"
}
}

367
samples/APL/UT.dyalog Normal file
View File

@@ -0,0 +1,367 @@
:NameSpace UT
sac ← 0
expect_orig ← expect ← ⎕NS⍬
exception ← ⍬
nexpect_orig ← nexpect ← ⎕NS⍬
∇ {Z}←{Conf}run Argument;PRE_test;POST_test;TEST_step;COVER_step;FromSpace
load_display_if_not_already_loaded
load_salt_scripts_into_current_namespace_if_configured
FromSpace←1⊃⎕RSI
PRE_test←{}
POST_test←{}
COVER_step←{}
:If 0≠⎕NC'Conf'
:If Conf has'cover_target'
PRE_test←{{}⎕PROFILE'start'}
POST_test←{{}⎕PROFILE'stop'}
:EndIf
:EndIf
:If is_function Argument
TEST_step←single_function_test_function
COVER_file←Argument,'_coverage.html'
:ElseIf is_list_of_functions Argument
TEST_step←list_of_functions_test_function
COVER_file←'list_coverage.html'
:ElseIf is_file Argument
TEST_step←file_test_function
COVER_file←(get_file_name Argument),'_coverage.html'
:ElseIf is_dir Argument
test_files←test_files_in_dir Argument
TEST_step←test_dir_function
Argument←test_files
:EndIf
:If 0≠⎕NC'Conf'
:If Conf has'cover_target'
COVER_step←{Conf,←⊂('cover_file'COVER_file)
generate_coverage_page Conf}
:EndIf
:EndIf
PRE_test ⍬
Z←FromSpace TEST_step Argument
POST_test ⍬
COVER_step ⍬
∇ load_display_if_not_already_loaded
:If 0=⎕NC'#.DISPLAY'
'DISPLAY'#.⎕CY'display'
:EndIf
∇ load_salt_scripts_into_current_namespace_if_configured
:If 0≠⎕NC'#.UT.appdir'
:If ⍬≢#.UT.appdir
⎕SE.SALT.Load #.UT.appdir,'src/*.dyalog -target=#'
⎕SE.SALT.Load #.UT.appdir,'test/*.dyalog -target=#'
:EndIf
:EndIf
∇ Z←FromSpace single_function_test_function TestName
Z←run_ut FromSpace TestName
∇ Z←FromSpace list_of_functions_test_function ListOfNames;t
t←⎕TS
Z←run_ut¨{FromSpace ⍵}¨ListOfNames
t←⎕TS-t
('Test execution report')print_passed_crashed_failed Z t
∇ Z←FromSpace file_test_function FilePath;FileNS;Functions;TestFunctions;t
FileNS←⎕SE.SALT.Load FilePath,' -target=#'
Functions←↓FileNS.⎕NL 3
TestFunctions←(is_test¨Functions)/Functions
:If (0/⍬,⊂0/'')≡TestFunctions
⎕←'No test functions found'
Z←⍬
:Else
t←⎕TS
Z←run_ut¨{FileNS ⍵}¨TestFunctions
t←⎕TS-t
(FilePath,' tests')print_passed_crashed_failed Z t
:EndIf
∇ Z←FromSpace test_dir_function Test_files
:If Test_files≡⍬/⍬,⊂''
⎕←'No test files found'
Z←⍬
:Else
Z←#.UT.run¨Test_files
:EndIf
∇ Z←get_file_name Argument;separator
separator←⊃⌽(Argument∊'/\')/Argument
Z←¯7↓separator↓Argument
∇ generate_coverage_page Conf;ProfileData;CoverResults;HTML
ProfileData←⎕PROFILE'data'
ToCover←retrieve_coverables¨(⊃'cover_target'in Conf)
:If (ToCover)≡(⊂1)
ToCover←⊃ToCover
:EndIf
Representations←get_representation¨ToCover
CoverResults←ProfileData∘generate_cover_result¨↓ToCover,[1.5]Representations
HTML←generate_html CoverResults
Conf write_html_to_page HTML
⎕PROFILE'clear'
∇ Z←retrieve_coverables Something;nc;functions
nc←⎕NC Something
:If nc=3
Z←Something
:ElseIf nc=9
functions←strip¨↓⍎Something,'.⎕NL 3'
Z←{(Something,'.',⍵)}¨functions
:EndIf
∇ Z←strip input
Z←(input≠' ')/input
∇ Z←get_representation Function;nc;rep
nc←⎕NC⊂Function
:If nc=3.1
rep←↓⎕CR Function
rep[1]←⊂'∇',⊃rep[1]
rep,←⊂'∇'
rep←↑rep
:Else
rep←⎕CR Function
:EndIf
Z←rep
∇ Z←ProfileData generate_cover_result(name representation);Indices;lines;functionlines;covered_lines
Indices←({name≡⍵}¨ProfileData[;1])/ProfileData[;1]
lines←ProfileData[Indices;2]
nc←⎕NC⊂name
:If 3.1=nc
functionlines←¯2+↓representation
:Else
functionlines←⊃↓representation
:EndIf
covered_lines←(⍬∘≢¨lines)/lines
Z←(nc lines functionlines covered_lines representation)
∇ Z←generate_html CoverResults;Covered;Total;Percentage;CoverageText;ColorizedCode;Timestamp;Page
Covered←⊃⊃+/{4⊃⍵}¨CoverResults
Total←⊃⊃+/{3⊃⍵}¨CoverResults
Percentage←100×Covered÷Total
CoverageText←'Coverage: ',Percentage,'% (',Covered,'/',Total,')'
ColorizedCode←⊃,/{colorize_code_by_coverage ⍵}¨CoverResults
Timestamp←generate_timestamp_text
Page←⍬
Page,←⊂⍬,'<html>'
Page,←⊂⍬,'<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>'
Page,←⊂⍬,'<style>pre cov {line-height:80%;}'
Page,←⊂⍬,'pre cov {color: green;}'
Page,←⊂⍬,'pre uncov {line-height:80%;}'
Page,←⊂⍬,'pre uncov {color:red;}</style>'
Page,←⊂⍬,CoverageText
Page,←⊂⍬,'<pre>'
Page,←ColorizedCode
Page,←⊂⍬,'</pre>'
Page,←Timestamp
Page,←⊂⍬,'</html>'
Z←Page
∇ Z←colorize_code_by_coverage CoverResult;Colors;Ends;Code
:If 3.1=⊃CoverResult
Colors←(2+3⊃CoverResult)⍴⊂'<uncov>'
Colors[1]←⊂''
Colors[Colors]←⊂''
Ends←(2+3⊃CoverResult)⍴⊂'</uncov>'
Ends[1]←⊂''
Ends[Ends]←⊂''
:Else
Colors←(3⊃CoverResult)⍴⊂'<uncov>'
Ends←(3⊃CoverResult)⍴⊂'</uncov>'
:EndIf
Colors[1+4⊃CoverResult]←⊂'<cov>'
Ends[1+4⊃CoverResult]←⊂'</cov>'
Code←↓5⊃CoverResult
Z←Colors,[1.5]Code
Z←{,(⎕UCS 13),⍵}/Z,Ends
∇ Z←generate_timestamp_text;TS;YYMMDD;HHMMSS
TS←⎕TS
YYMMDD←⊃{,'-',⍵}/3↑TS
HHMMSS←⊃{,':',⍵}/3↑3↓TS
Z←'Page generated: ',YYMMDD,'|',HHMMSS
∇ Conf write_html_to_page Page;tie;filename
filename←(⊃'cover_out'in Conf),(⊃'cover_file'in Conf)
:Trap 22
tie←filename ⎕NTIE 0
filename ⎕NERASE tie
filename ⎕NCREATE tie
:Else
tie←filename ⎕NCREATE 0
:EndTrap
Simple_array←⍕⊃,/Page
(⎕UCS'UTF-8'⎕UCS Simple_array)⎕NAPPEND tie
∇ Z←is_function Argument
Z←'_TEST'≡¯5↑Argument
∇ Z←is_list_of_functions Argument
Z←2=≡Argument
∇ Z←is_file Argument
Z←'.dyalog'≡¯7↑Argument
∇ Z←is_dir Argument;attr
:If 'Linux'≡5↑⊃'.'⎕WG'APLVersion'
Z←'yes'≡⊃⎕CMD'test -d ',Argument,' && echo yes || echo no'
:Else
'gfa'⎕NA'I kernel32|GetFileAttributes* <0t'
:If Z←¯1≠attr←gfa⊂Argument ⍝ If file exists
Z←⊃2 16attr ⍝ Return bit 4
:EndIf
:EndIf
∇ Z←test_files_in_dir Argument
:If 'Linux'≡5↑⊃'.'⎕WG'APLVersion'
Z←⎕SH'find ',Argument,' -name \*_tests.dyalog'
:Else
#.⎕CY'files'
Z←#.Files.Dir Argument,'\*_tests.dyalog'
Z←(Argument,'\')∘,¨Z
:EndIf
∇ Z←run_ut ut_data;returned;crashed;pass;crash;fail;message
(returned crashed time)←execute_function ut_data
(pass crash fail)←determine_pass_crash_or_fail returned crashed
message←determine_message pass fail crashed(2⊃ut_data)returned time
print_message_to_screen message
Z←(pass crash fail)
∇ Z←execute_function ut_data;function;t
reset_UT_globals
function←(⍕(⊃ut_data[1])),'.',⊃ut_data[2]
:Trap sac
:If 3.2≡⎕NC⊂function
t←⎕TS
Z←(⍎function,' ⍬')0
t←⎕TS-t
:Else
t←⎕TS
Z←(⍎function)0
t←⎕TS-t
:EndIf
:Else
Z←(↑⎕DM)1
:If exception≢⍬
expect←exception
Z[2]←0
t←⎕TS-t
:EndIf
:EndTrap
Z,←⊂t
∇ reset_UT_globals
expect_orig ← expect← ⎕NS⍬
exception←⍬
nexpect_orig ← nexpect← ⎕NS⍬
∇ Z←is_test FunctionName;wsIndex
wsIndex←FunctionName' '
FunctionName←(wsIndex-1)↑FunctionName
Z←'_TEST'≡¯5↑FunctionName
∇ Heading print_passed_crashed_failed(ArrayRes time)
⎕←'-----------------------------------------'
⎕←Heading
⎕←' ⍋ Passed: ',+/{1⊃⍵}¨ArrayRes
⎕←' ⍟ Crashed: ',+/{2⊃⍵}¨ArrayRes
⎕←' ⍒ Failed: ',+/{3⊃⍵}¨ArrayRes
⎕←' ○ Runtime: ',time[5],'m',time[6],'s',time[7],'ms'
determine_pass_crash_or_fail←{
r c←⍵ ⋄ 0≠c:0 1 0 ⋄ z←(0 0 1)(1 0 0)
expect_orig≢expect:(⎕IO+expect≡r)⊃z ⋄ (⎕IO+nexpect≢r)⊃z
}
∇ Z←determine_message(pass fail crashed name returned time)
:If crashed
Z←'CRASHED: 'failure_message name returned
:ElseIf pass
Z←'Passed ',time[5],'m',time[6],'s',time[7],'ms'
:Else
Z←'FAILED: 'failure_message name returned
:EndIf
∇ print_message_to_screen message
⎕←message
∇ Z←term_to_text Term;Text;Rows
Text←#.DISPLAY Term
Rows←1⊃Text
Z←(Rows 4''),Text
∇ Z←Cause failure_message(name returned);hdr;exp;expterm;got;gotterm
hdr←Cause,name
exp←'Expected'
expterm←term_to_text #.UT.expect
got←'Got'
gotterm←term_to_text returned
Z←align_and_join_message_parts hdr exp expterm got gotterm
∇ Z←align_and_join_message_parts Parts;hdr;exp;expterm;got;gotterm;R1;C1;R2;C2;W
(hdr exp expterm got gotterm)←Parts
(R1 C1)←expterm
(R2 C2)←gotterm
W←⊃⊃⌈/C1 C2(hdr)(exp)(got)
Z←(W↑hdr),[0.5](W↑exp)
Z←Z⍪(R1 W↑expterm)
Z←Z⍪(W↑got)
Z←Z⍪(R2 W↑gotterm)
∇ Z←confparam in config
Z←1↓⊃({confparam≡⊃⍵}¨config)/config
∇ Z←config has confparam
Z←/{confparam≡⊃⍵}¨config
:EndNameSpace

View File

@@ -1,215 +0,0 @@
%{
#include "./../ATEXT/atextfun.hats"
%}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>EFFECTIVATS-DiningPhil2</title>
#patscode_style()
</head>
<body>
<h1>
Effective ATS: Dining Philosophers
</h1>
In this article, I present an implementation of a slight variant of the
famous problem of 5-Dining-Philosophers by Dijkstra that makes simple but
convincing use of linear types.
<h2>
The Original Problem
</h2>
There are five philosophers sitting around a table and there are also 5
forks placed on the table such that each fork is located between the left
hand of a philosopher and the right hand of another philosopher. Each
philosopher does the following routine repeatedly: thinking and dining. In
order to dine, a philosopher needs to first acquire two forks: one located
on his left-hand side and the other on his right-hand side. After
finishing dining, a philosopher puts the two acquired forks onto the table:
one on his left-hand side and the other on his right-hand side.
<h2>
A Variant of the Original Problem
</h2>
The following twist is added to the original version:
<p>
After a fork is used, it becomes a "dirty" fork and needs to be put in a
tray for dirty forks. There is a cleaner who cleans dirty forks and then
puts them back on the table.
<h2>
Channels for Communication
</h2>
A channel is just a shared queue of fixed capacity. The following two
functions are for inserting an element into and taking an element out of a
given channel:
<pre
class="patsyntax">
#pats2xhtml_sats("\
fun{a:vt0p} channel_insert (channel (a), a): void
fun{a:vt0p} channel_takeout (chan: channel (a)): (a)
")</pre>
If [channel_insert] is called on a channel that is full, then the caller is
blocked until an element is taken out of the channel. If [channel_takeout]
is called on a channel that is empty, then the caller is blocked until an
element is inserted into the channel.
<h2>
A Channel for Each Fork
</h2>
Forks are resources given a linear type. Each fork is initially stored in a
channel, which can be obtained by calling the following function:
<pre
class="patsyntax">
#pats2xhtml_sats("\
fun fork_changet (n: nphil): channel(fork)
")</pre>
where the type [nphil] is defined to be [natLt(5)] (for natural numbers
less than 5). The channels for storing forks are chosen to be of capacity
2. The reason that channels of capacity 2 are chosen to store at most one
element (in each of them) is to guarantee that these channels can never be
full (so that there is no attempt made to send signals to awake callers
supposedly being blocked due to channels being full).
<h2>
A Channel for the Fork Tray
</h2>
A tray for storing "dirty" forks is also a channel, which can be obtained
by calling the following function:
<pre
class="patsyntax">
#pats2xhtml_sats("\
fun forktray_changet ((*void*)): channel(fork)
")</pre>
The capacity chosen for the channel is 6 (instead of 5) so that it can
never become full (as there are only 5 forks in total).
<h2>
Philosopher Loop
</h2>
Each philosopher is implemented as a loop:
<pre
class="patsyntax">
#pats2xhtml_dats('\
implement
phil_loop (n) = let
//
val () = phil_think (n)
//
val nl = phil_left (n) // = n
val nr = phil_right (n) // = (n+1) % 5
//
val ch_lfork = fork_changet (nl)
val ch_rfork = fork_changet (nr)
//
val lf = channel_takeout (ch_lfork)
val () = println! ("phil_loop(", n, ") picks left fork")
//
val () = randsleep (2) // sleep up to 2 seconds
//
val rf = channel_takeout (ch_rfork)
val () = println! ("phil_loop(", n, ") picks right fork")
//
val () = phil_dine (n, lf, rf)
//
val ch_forktray = forktray_changet ()
val () = channel_insert (ch_forktray, lf) // left fork to dirty tray
val () = channel_insert (ch_forktray, rf) // right fork to dirty tray
//
in
phil_loop (n)
end // end of [phil_loop]
')</pre>
It should be straighforward to follow the code for [phil_loop].
<h2>
Fork Cleaner Loop
</h2>
A cleaner is implemented as a loop:
<pre
class="patsyntax">
#pats2xhtml_dats('\
implement
cleaner_loop () = let
//
val ch = forktray_changet ()
val f0 = channel_takeout (ch) // [f0] is dirty
//
val () = cleaner_wash (f0) // washes dirty [f0]
val () = cleaner_return (f0) // puts back cleaned [f0]
//
in
cleaner_loop ()
end // end of [cleaner_loop]
')</pre>
The function [cleaner_return] first finds out the number of a given fork
and then uses the number to locate the channel for storing the fork. Its
actual implementation is given as follows:
<pre
class="patsyntax">
#pats2xhtml_dats('\
implement
cleaner_return (f) =
{
val n = fork_get_num (f)
val ch = fork_changet (n)
val () = channel_insert (ch, f)
}
')</pre>
It should now be straighforward to follow the code for [cleaner_loop].
<h2>
Testing
</h2>
The entire code of this implementation is stored in the following files:
<pre>
DiningPhil2.sats
DiningPhil2.dats
DiningPhil2_fork.dats
DiningPhil2_thread.dats
</pre>
There is also a Makefile available for compiling the ATS source code into
an excutable for testing. One should be able to encounter a deadlock after
running the simulation for a while.
<hr size="2">
This article is written by <a href="http://www.cs.bu.edu/~hwxi/">Hongwei Xi</a>.
</body>
</html>
%{
implement main () = fprint_filsub (stdout_ref, "main_atxt.txt")
%}

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="WebBuild">
<!-- generate timestamps -->
<tstamp />
<!-- Debugging Macro -->
<import file="echopath.xml" />
<!-- JS build files macro -->
<import file="rhinoscript.xml" />
<!-- Component Build Files -->
<import file="setup.xml" />
<import file="clean.xml" />
<import file="copy.xml" />
<import file="file.transform.xml" />
<import file="external.tools.xml" />
<import file="rename.xml" />
<import file="js.xml" />
<import file="css.xml" />
<import file="img.xml" />
<import file="png8.xml" />
<import file="yui.xml" />
<import file="cdn.xml" />
<import file="datauri.xml" />
<import file="devlive.xml" />
<!-- This dirname is the only complete path we know for sure, everything builds off of it -->
<dirname property="dir.build" file="${ant.file.WebBuild}" />
<!-- get name for newly built folder -->
<basename property="app.name" file="${basedir}" />
<!-- read global properties file -->
<property file="${dir.build}\build.properties" />
<!-- Build Directories -->
<property name="dir.build.js" location="${dir.build}/js" />
<!-- App Directories -->
<property name="dir.app" location="${dir.result}/${app.name}" />
<property name="dir.app.temp" location="${dir.temp}/${app.name}" />
<property name="dir.app.files" location="${dir.app.temp}/${dir.files}" />
<!-- Files -->
<property name="mapping.js" location="${dir.app.temp}/${mapping.file.js}" />
<property name="mapping.css" location="${dir.app.temp}/${mapping.file.css}" />
<property name="mapping.img" location="${dir.app.temp}/${mapping.file.img}" />
<property name="mapping.swf" location="${dir.app.temp}/${mapping.file.swf}" />
<property name="mapping.fonts" location="${dir.app.temp}/${mapping.file.fonts}" />
<!-- Tool Directories -->
<property name="dir.bin" location="${dir.build}/Bin" />
<property name="dir.jar" location="${dir.bin}/jar" />
<!-- Tool Files -->
<property name="tools.compressor" location="${dir.jar}/${tools.file.compressor}" />
<property name="tools.cssembed" location="${dir.jar}/${tools.file.cssembed}" />
<property name="tools.filetransform" location="${dir.jar}/${tools.file.filetransform}" />
<property name="tools.optipng" location="${dir.bin}/${tools.file.optipng}" />
<property name="tools.jpegtran" location="${dir.bin}/${tools.file.jpegtran}" />
<!-- BUILD TARGETS -->
<!-- low level utility build targets -->
<!-- Build the tools -->
<target name="-setup.build.tools"
depends="-define.filetransform, -define.cssembed, -define.yuicompressor, -define.jsclasspath"
/>
<!-- set up filesystem properties -->
<target
name="-setup"
depends="-setup.mode, -setup.conditions, -setup.js, -setup.css, -setup.swf, -setup.img, -setup.fonts, -setup.yui"
/>
<!-- utility-ish targets -->
<target name="copy" depends="clean, tools, -copy" />
<target name="tools" depends="-setup.build.tools" />
<target name="finalize" depends="copy, -finalize" />
<target name="-prepare" depends="copy, -setup" />
<!-- individual component build targets (empty descriptions are to make sure they show in "ant -p") -->
<target name="devlive" depends="-prepare, -devlive" description="" />
<target name="js" depends="-prepare, -js" description="" />
<target name="css" depends="-prepare, -css" description="" />
<target name="rename" depends="-prepare, -rename" description="" />
<target name="yui" depends="-prepare, rename, -yui" description="" />
<target name="cdn" depends="-prepare, -cdn" description="" />
<!-- high level build targets (Excluding of images is on purpose here, it's slow) -->
<target name="core"
depends="devlive, js, css, cdn, rename, yui, -js.inline"
description="Core build work"
/>
<target name="prod"
depends="core, finalize"
description="Full Production Build"
/>
<!-- debug target -->
<target name="debug" depends="-setup">
<echoproperties/>
</target>
</project>

View File

@@ -0,0 +1 @@
ant.xml

View File

@@ -0,0 +1,66 @@
ORG 0000h
SJMP START
ORG 0003h
LCALL INT0_ISR
RETI
ORG 000Bh
LCALL T0_ISR
RETI
ORG 0013h
LCALL INT1_ISR
RETI
ORG 001Bh
LCALL T1_ISR
RETI
ORG 0023h
LCALL UART_ISR
RETI
ORG 0030h
START:
MOV A,#11111110b
SETB IT0 ; Set External Interrupt 0 to be falling edge triggered
SETB EX0 ; Enable External Interrut 0
SETB EA ; Enable Interrupt
LEFT:
CJNE A,#01111111b,LOOP1
JMP RIGHT
LOOP1:
MOV P1,A
RL A
LCALL DELAY
SJMP LEFT
RIGHT:
CJNE A,#11111110b,LOOP2
JMP LEFT
LOOP2:
MOV P1,A
RR A
LCALL DELAY
SJMP RIGHT
INT0_ISR:
MOV R1,#3
FLASH:
MOV P1,#00h
LCALL DELAY
MOV P1,#0FFh
LCALL DELAY
DJNZ R1,FLASH
RET
T0_ISR:
RET
INT1_ISR:
RET
T1_ISR:
RET
UART_ISR:
RET
DELAY: MOV R5,#20 ;R5*20 mS
D1: MOV R6,#40
D2: MOV R7,#249
DJNZ R7,$
DJNZ R6,D2
DJNZ R5,D1
RET
END

View File

@@ -0,0 +1,25 @@
include gstreamer1.0-libav.inc
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \
file://ext/libav/gstav.h;beginline=1;endline=18;md5=a752c35267d8276fd9ca3db6994fca9c \
file://gst-libs/ext/libav/LICENSE;md5=23a54f59b82572c203a559346e89ed57 \
file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \
file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
SRC_URI = " \
http://gstreamer.freedesktop.org/src/gst-libav/gst-libav-${PV}.tar.xz \
file://0001-Disable-yasm-for-libav-when-disable-yasm.patch \
"
SRC_URI[md5sum] = "86540dee14d31daf976eb2713f2294f3"
SRC_URI[sha256sum] = "585eb7971006100ad771a852e07bd2f3e23bcc6eb0b1253a40b5a0e40e4e7418"
LIBAV_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux \
--cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
--ranlib='${RANLIB}' \
${GSTREAMER_1_0_DEBUG}"
S = "${WORKDIR}/gst-libav-${PV}"

View File

@@ -0,0 +1,13 @@
require qt5-git.inc
require ${PN}.inc
do_install_append() {
# for modules which are still using syncqt and call qtPrepareTool(QMAKE_SYNCQT, syncqt)
# e.g. qt3d, qtwayland
ln -sf syncqt.pl ${D}${OE_QMAKE_PATH_QT_BINS}/syncqt
}
QT_MODULE_BRANCH = "release"
# v5.2.1 + 168 commits
SRCREV = "08cbbde61778276ccdda73d89fd64d02c623779f"

View File

@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("Simple")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@@ -0,0 +1,20 @@
using System;
namespace MongoDB.Serialization.Descriptors
{
internal class BsonPropertyValue
{
public bool IsDictionary { get; private set; }
public Type Type { get; private set; }
public object Value { get; private set; }
public BsonPropertyValue(Type type, object value, bool isDictionary)
{
Type = type;
Value = value;
IsDictionary = isDictionary;
}
}
}

View File

@@ -0,0 +1,153 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
namespace MongoDB.Linq.Expressions
{
internal class MongoExpressionVisitor : ExpressionVisitor
{
protected override Expression Visit(Expression exp)
{
if (exp == null)
return null;
switch ((MongoExpressionType)exp.NodeType)
{
case MongoExpressionType.Collection:
return VisitCollection((CollectionExpression)exp);
case MongoExpressionType.Field:
return VisitField((FieldExpression)exp);
case MongoExpressionType.Projection:
return VisitProjection((ProjectionExpression)exp);
case MongoExpressionType.Select:
return VisitSelect((SelectExpression)exp);
case MongoExpressionType.Aggregate:
return VisitAggregate((AggregateExpression)exp);
case MongoExpressionType.AggregateSubquery:
return VisitAggregateSubquery((AggregateSubqueryExpression)exp);
case MongoExpressionType.Scalar:
return VisitScalar((ScalarExpression)exp);
default:
return base.Visit(exp);
}
}
protected virtual Expression VisitAggregate(AggregateExpression aggregate)
{
var exp = Visit(aggregate.Argument);
if (exp != aggregate.Argument)
return new AggregateExpression(aggregate.Type, aggregate.AggregateType, exp, aggregate.Distinct);
return aggregate;
}
protected virtual Expression VisitAggregateSubquery(AggregateSubqueryExpression aggregateSubquery)
{
Expression e = Visit(aggregateSubquery.AggregateAsSubquery);
ScalarExpression subquery = (ScalarExpression)e;
if (subquery != aggregateSubquery.AggregateAsSubquery)
return new AggregateSubqueryExpression(aggregateSubquery.GroupByAlias, aggregateSubquery.AggregateInGroupSelect, subquery);
return aggregateSubquery;
}
protected virtual Expression VisitCollection(CollectionExpression collection)
{
return collection;
}
protected virtual Expression VisitField(FieldExpression field)
{
var e = Visit(field.Expression);
if (field.Expression != e)
field = new FieldExpression(e, field.Alias, field.Name);
return field;
}
protected virtual Expression VisitProjection(ProjectionExpression projection)
{
var source = (SelectExpression)Visit(projection.Source);
var projector = Visit(projection.Projector);
if (source != projection.Source || projector != projection.Projector)
return new ProjectionExpression(source, projector, projection.Aggregator);
return projection;
}
protected ReadOnlyCollection<OrderExpression> VisitOrderBy(ReadOnlyCollection<OrderExpression> orderBys)
{
if (orderBys != null)
{
List<OrderExpression> alternate = null;
for (int i = 0, n = orderBys.Count; i < n; i++)
{
OrderExpression expr = orderBys[i];
Expression e = this.Visit(expr.Expression);
if (alternate == null && e != expr.Expression)
alternate = orderBys.Take(i).ToList();
if (alternate != null)
alternate.Add(new OrderExpression(expr.OrderType, e));
}
if (alternate != null)
return alternate.AsReadOnly();
}
return orderBys;
}
protected virtual Expression VisitScalar(ScalarExpression scalar)
{
SelectExpression select = (SelectExpression)Visit(scalar.Select);
if (select != scalar.Select)
return new ScalarExpression(scalar.Type, select);
return scalar;
}
protected virtual Expression VisitSelect(SelectExpression select)
{
var from = VisitSource(select.From);
var where = Visit(select.Where);
var groupBy = Visit(select.GroupBy);
var orderBy = VisitOrderBy(select.OrderBy);
var skip = Visit(select.Skip);
var take = Visit(select.Take);
var fields = VisitFieldDeclarationList(select.Fields);
if (from != select.From || where != select.Where || orderBy != select.OrderBy || groupBy != select.GroupBy || skip != select.Skip || take != select.Take || fields != select.Fields)
return new SelectExpression(select.Alias, fields, from, where, orderBy, groupBy, select.IsDistinct, skip, take);
return select;
}
protected virtual Expression VisitSource(Expression source)
{
return Visit(source);
}
protected virtual Expression VisitSubquery(SubqueryExpression subquery)
{
switch ((MongoExpressionType)subquery.NodeType)
{
case MongoExpressionType.Scalar:
return VisitScalar((ScalarExpression)subquery);
}
return subquery;
}
protected virtual ReadOnlyCollection<FieldDeclaration> VisitFieldDeclarationList(ReadOnlyCollection<FieldDeclaration> fields)
{
if (fields == null)
return fields;
List<FieldDeclaration> alternate = null;
for (int i = 0, n = fields.Count; i < n; i++)
{
var f = fields[i];
var e = Visit(f.Expression);
if (f.Expression != e && alternate == null)
alternate = fields.Take(i).ToList();
if (alternate != null)
alternate.Add(new FieldDeclaration(f.Name, e));
}
if (alternate != null)
return alternate.AsReadOnly();
return fields;
}
}
}

86
samples/C++/16F88.h Normal file
View File

@@ -0,0 +1,86 @@
/*
* This file is part of PIC
* Copyright © 2012 Rachel Mant (dx-mon@users.sourceforge.net)
*
* PIC is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PIC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
enum PIC16F88Instruction
{
ADDWF,
ANDWF,
CLRF,
CLRW,
COMF,
DECF,
DECFSZ,
INCF,
INCFSZ,
IORWF,
MOVF,
MOVWF,
NOP,
RLF,
RRF,
SUBWF,
SWAPF,
XORWF,
BCF,
BSF,
BTFSC,
BTFSS,
ADDLW,
ANDLW,
CALL,
CLRWDT,
GOTO,
IORLW,
MOVLW,
RETFIE,
RETLW,
RETURN,
SLEEP,
SUBLW,
XORLW
};
class PIC16F88
{
public:
PIC16F88(ROM *ProgramMemory);
void Step();
private:
uint8_t q;
bool nextIsNop, trapped;
Memory *memory;
ROM *program;
Stack<uint16_t, 8> *CallStack;
Register<uint16_t> *PC;
Register<> *WREG, *PCL, *STATUS, *PCLATCH;
PIC16F88Instruction inst;
uint16_t instrWord;
private:
void DecodeInstruction();
void ProcessInstruction();
uint8_t GetBank();
uint8_t GetMemoryContents(uint8_t partialAddress);
void SetMemoryContents(uint8_t partialAddress, uint8_t newVal);
void CheckZero(uint8_t value);
void StoreValue(uint8_t value, bool updateZero);
uint8_t SetCarry(bool val);
uint16_t GetPCHFinalBits();
};

98
samples/C++/Entity.h Normal file
View File

@@ -0,0 +1,98 @@
/**
* @file Entity.h
* @page EntityPage Entity
* @brief represent an entity in the game
* @author vinz243
* @version 0.1.0
* This file represents an Entity in the game system
* This parent type is a static entity which is shown and loaded into the Physics engine but never updated
*/
#ifndef ENTITY_H
#define ENTITY_H
#include "base.h"
/// @namespace Whitedrop
namespace Whitedrop {
/** @class Entity
* This parent type is a static entity which is shown and loaded into the Physics engine but never updated
*/
class Entity {
public:
/**
* @brief Create static entity
* @details creates a static entity instance according to the mesh and the id, the position
* This needs to be attached to a World after!
* The material name is not the file name but the material name!
* @ref WorldPage
* @param mesh the name of the mesh for the object, file must be in media/meshes
* @param id an unique identifier for the object, shortest as possible
* @param dimensions an Ogre::Vector3 which contains the dimensions in meter
* @param position the Vector3 which contains it position
* @param material the material name
*/
Entity(std::string mesh, std::string id, Ogre::Vector3 dimensions, Ogre::Vector3 position, std::string material);
/**
* @brief The copy constructor
* @details A copy constr
*
* @param ref the Entity to be copied from
*/
Entity(const Entity &ref);
/**
* @brief The assignement operator
* @details
*
* @param ent the entity to be copied
*/
Entity& operator=(const Entity ent);
/**
* @brief destrctor
* @details
*/
virtual ~Entity(void);
/**
* @brief a constance type of the entity
* @details depends of the class.
* May contain STATIC, DYNAMIC or ETHERAL
*/
const std::string type = "STATIC";
/**
* @brief Attach the entity to specified sceneManager
* @details This creates the OgreEntity using sceneMgr,
* set material, create a Node with name as `<id>_n`,
* scale it to match dimensions and translate the node to pos
* @param sceneMgr the scene manager to use
*/
virtual void setup(Ogre::SceneManager* sceneMgr);
/**
* @brief the update method
* @details this method should be called on each world update.
* Even though the method is necessary declared, the main impl of
* a static entity should be empty since it is not updated by physics
* However, a Dynamic entity should implement this function in order to:
* 1) Get from the physics engine the actor position in the physic world
* 2) Update the OgreEntity position and rotation from the previous actor
* @return whether it was successful or not, if falsey engine should stop
*/
virtual bool update(void);
protected:
std::string mMesh = "cube.mesh";
std::string mId;
std::string mMaterial;
Ogre::Vector3 mDimensions;
Ogre::Vector3 mPosition;
Ogre::Entity* mEntity;
Ogre::SceneNode* mNode;
};
}
#endif

32
samples/C++/Memory16F88.h Normal file
View File

@@ -0,0 +1,32 @@
/*
* This file is part of PIC
* Copyright © 2012 Rachel Mant (dx-mon@users.sourceforge.net)
*
* PIC is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PIC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Memory.h"
class Memory16F88 : public Memory
{
private:
uint8_t memory[512];
std::map<uint32_t, MemoryLocation *> memoryMap;
public:
Memory16F88();
uint8_t Dereference(uint8_t bank, uint8_t partialAddress);
uint8_t *Reference(uint8_t bank, uint8_t partialAddress);
uint8_t *operator [](uint32_t ref);
};

View File

@@ -0,0 +1,76 @@
/*
* This file is part of IRCBot
* Copyright © 2014 Rachel Mant (dx-mon@users.sourceforge.net)
*
* IRCBot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* IRCBot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __THREADED_QUEUE_H__
#define __THREADED_QUEUE_H__
#include <pthread.h>
#include <queue>
template<class T>
class ThreadedQueue : public std::queue<T>
{
private:
pthread_mutex_t queueMutex;
pthread_cond_t queueCond;
public:
ThreadedQueue()
{
pthread_mutexattr_t mutexAttrs;
pthread_condattr_t condAttrs;
pthread_mutexattr_init(&mutexAttrs);
pthread_mutexattr_settype(&mutexAttrs, PTHREAD_MUTEX_ERRORCHECK);
pthread_mutex_init(&queueMutex, &mutexAttrs);
pthread_mutexattr_destroy(&mutexAttrs);
pthread_condattr_init(&condAttrs);
pthread_condattr_setpshared(&condAttrs, PTHREAD_PROCESS_PRIVATE);
pthread_cond_init(&queueCond, &condAttrs);
pthread_condattr_destroy(&condAttrs);
}
~ThreadedQueue()
{
pthread_cond_destroy(&queueCond);
pthread_mutex_destroy(&queueMutex);
}
void waitItems()
{
pthread_mutex_lock(&queueMutex);
pthread_cond_wait(&queueCond, &queueMutex);
pthread_mutex_unlock(&queueMutex);
}
void signalItems()
{
pthread_mutex_lock(&queueMutex);
pthread_cond_broadcast(&queueCond);
pthread_mutex_unlock(&queueMutex);
}
void push(T item)
{
std::queue<T>::push(item);
signalItems();
}
};
#endif /*__THREADED_QUEUE_H__*/

10
samples/C++/bar.hh Normal file
View File

@@ -0,0 +1,10 @@
class Bar
{
protected:
char *name;
public:
void hello();
}

116
samples/C++/qsciprinter.cp Normal file
View File

@@ -0,0 +1,116 @@
// This module defines interface to the QsciPrinter class.
//
// Copyright (c) 2011 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public
// License versions 2.0 or 3.0 as published by the Free Software
// Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
// included in the packaging of this file. Alternatively you may (at
// your option) use any later version of the GNU General Public
// License if such license has been publicly approved by Riverbank
// Computing Limited (or its successors, if any) and the KDE Free Qt
// Foundation. In addition, as a special exception, Riverbank gives you
// certain additional rights. These rights are described in the Riverbank
// GPL Exception version 1.1, which can be found in the file
// GPL_EXCEPTION.txt in this package.
//
// If you are unsure which license is appropriate for your use, please
// contact the sales department at sales@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#ifndef QSCIPRINTER_H
#define QSCIPRINTER_H
#ifdef __APPLE__
extern "C++" {
#endif
#include <qprinter.h>
#include <Qsci/qsciglobal.h>
#include <Qsci/qsciscintilla.h>
QT_BEGIN_NAMESPACE
class QRect;
class QPainter;
QT_END_NAMESPACE
class QsciScintillaBase;
//! \brief The QsciPrinter class is a sub-class of the Qt QPrinter class that
//! is able to print the text of a Scintilla document.
//!
//! The class can be further sub-classed to alter to layout of the text, adding
//! headers and footers for example.
class QSCINTILLA_EXPORT QsciPrinter : public QPrinter
{
public:
//! Constructs a printer paint device with mode \a mode.
QsciPrinter(PrinterMode mode = ScreenResolution);
//! Destroys the QsciPrinter instance.
virtual ~QsciPrinter();
//! Format a page, by adding headers and footers for example, before the
//! document text is drawn on it. \a painter is the painter to be used to
//! add customised text and graphics. \a drawing is true if the page is
//! actually being drawn rather than being sized. \a painter drawing
//! methods must only be called when \a drawing is true. \a area is the
//! area of the page that will be used to draw the text. This should be
//! modified if it is necessary to reserve space for any customised text or
//! graphics. By default the area is relative to the printable area of the
//! page. Use QPrinter::setFullPage() because calling printRange() if you
//! want to try and print over the whole page. \a pagenr is the number of
//! the page. The first page is numbered 1.
virtual void formatPage(QPainter &painter, bool drawing, QRect &area,
int pagenr);
//! Return the number of points to add to each font when printing.
//!
//! \sa setMagnification()
int magnification() const {return mag;}
//! Sets the number of points to add to each font when printing to \a
//! magnification.
//!
//! \sa magnification()
virtual void setMagnification(int magnification);
//! Print a range of lines from the Scintilla instance \a qsb. \a from is
//! the first line to print and a negative value signifies the first line
//! of text. \a to is the last line to print and a negative value
//! signifies the last line of text. true is returned if there was no
//! error.
virtual int printRange(QsciScintillaBase *qsb, int from = -1, int to = -1);
//! Return the line wrap mode used when printing. The default is
//! QsciScintilla::WrapWord.
//!
//! \sa setWrapMode()
QsciScintilla::WrapMode wrapMode() const {return wrap;}
//! Sets the line wrap mode used when printing to \a wmode.
//!
//! \sa wrapMode()
virtual void setWrapMode(QsciScintilla::WrapMode wmode);
private:
int mag;
QsciScintilla::WrapMode wrap;
QsciPrinter(const QsciPrinter &);
QsciPrinter &operator=(const QsciPrinter &);
};
#ifdef __APPLE__
}
#endif
#endif

145
samples/C/2D.C Normal file
View File

@@ -0,0 +1,145 @@
#include "2D.h"
#include <math.h>
void set_vgabasemem(void)
{
ULONG vgabase;
SELECTOR tmp;
asm mov [tmp], ds
dpmi_get_sel_base(&vgabase, tmp);
vgabasemem = (char *)(-vgabase + 0xa0000);
}
void drw_chdis(int mode) // change the display!
{
regs.b.ah = 0x00; // seet theh display moode
regs.b.al = mode; // change it to the mode like innit
regs.h.flags = 0x72;// Set the dingoes kidneys out of FLAGS eh?
regs.h.ss = 0; // Like, totally set the stack segment
regs.h.sp = 0; // Set tha stack pointaaaaahhhhh!!!
dpmi_simulate_real_interrupt(0x10, &regs);
}
void drw_pix(int x, int y, enum COLORS col)
{
*VGAPIX(x, y) = col;
}
void drw_line(int x0, int y0, int x1, int y1, enum COLORS col)
{
// Going for the optimized version of bresenham's line algo.
int stp = (abs(y0 - y1) > abs(x0 - x1));
int tmp, dx, dy, err, yi, i, j; // yi = y excrement
if (stp) {
// swappity swap
tmp = y0;
y0 = x0;
x0 = tmp;
tmp = y1;
y1 = x1;
x1 = tmp;
}
// AAAAND NOW WE MUST DO ZEES AGAIN :(
// I'm sure there was a func somewhere that does this? :P
if (x0 > x1) {
tmp = x0;
x0 = x1;
x1 = tmp;
tmp = y0;
y0 = y1;
y1 = tmp;
}
dx = (x1 - x0);
dy = (abs(y1 - y0));
err = (dx / 2);
if (y0 < y1)
yi = 1;
else
yi = -1;
j = y0;
for (i = x0; i < x1; i++)
{
if (stp)
*VGAPIX(j, i) = col;
else
*VGAPIX(i, j) = col;
err -= dy;
if (err < 0) {
j += yi;
err += dx;
}
}
}
void drw_rectl(int x, int y, int w, int h, enum COLORS col)
{
drw_line(x, y, x+w, y, col);
drw_line(x+w, y, x+w, y+h, col);
drw_line(x, y, x, y+h, col);
drw_line(x, y+h, x+w+1, y+h, col);
}
void drw_rectf(int x, int y, int w, int h, enum COLORS col)
{
int i, j;
for (j = y; j < x+h; j++) {
for (i = x; i < y+w; i++) {
*VGAPIX(i, j) = col;
}
}
}
void drw_circl(int x, int y, int rad, enum COLORS col)
{
int mang, i; // max angle, haha
int px, py;
mang = 360; // Yeah yeah I'll switch to rad later
for (i = 0; i <= mang; i++)
{
px = cos(i)*rad + x; // + px; // causes some really cools effects! :D
py = sin(i)*rad + y; // + py;
*VGAPIX(px, py) = col;
}
}
void drw_tex(int x, int y, int w, int h, enum COLORS tex[])
{ // i*w+j
int i, j;
for (i = 0; i < w; i++)
{
for (j = 0; j < h; j++)
{
*VGAPIX(x+i, y+j) = tex[j*w+i];
}
}
}
void 2D_init(void)
{
set_vgabasemem();
drw_chdis(0x13);
}
void 2D_exit(void)
{
drw_chdis(3);
}
/*
int main()
{
set_vgabasemem();
drw_chdis(0x13);
while(!kbhit()) {
if ((getch()) == 0x1b) // escape
break;
}
drw_chdis(3);
return 0;
}
*/

29
samples/C/2D.H Normal file
View File

@@ -0,0 +1,29 @@
#ifndef __2DGFX
#define __2DGFX
// Includes
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <dpmi.h>
// Defines
#define VGAPIX(x,y) (vgabasemem + (x) + (y) * 320)
// Variables
char * vgabasemem;
DPMI_REGS regs;
// Drawing functions:
//void setvgabasemem(void);
void drw_chdis(int mode); // draw_func_change_display
void drw_pix(int x, int y, enum COLORS col);
void drw_line(int x0, int y0, int x1, int y1, enum COLORS col);
void drw_rectl(int x, int y, int w, int h, enum COLORS col);
void drw_rectf(int x, int y, int w, int h, enum COLORS col);
void drw_cirl(int x, int y, int rad, enum COLORS col);
void drw_tex(int x, int y, int w, int h, enum COLORS tex[]);
void 2D_init(void);
void 2D_exit(void);
#endif

93
samples/C/ArrowLeft.h Normal file
View File

@@ -0,0 +1,93 @@
/*
* This file is part of GTK++ (libGTK++)
* Copyright © 2012 Rachel Mant (dx-mon@users.sourceforge.net)
*
* GTK++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GTK++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* GdkPixbuf RGBA C-Source image dump */
#ifdef __SUNPRO_C
#pragma align 4 (ArrowLeft)
#endif
#ifdef __GNUC__
static const uint8_t ArrowLeft[] __attribute__ ((__aligned__ (4))) =
#else
static const uint8_t ArrowLeft[] =
#endif
{ ""
/* Pixbuf magic (0x47646b50) */
"GdkP"
/* length: header (24) + pixel_data (1600) */
"\0\0\6X"
/* pixdata_type (0x1010002) */
"\1\1\0\2"
/* rowstride (80) */
"\0\0\0P"
/* width (20) */
"\0\0\0\24"
/* height (20) */
"\0\0\0\24"
/* pixel_data: */
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377"
"\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377"
"\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0"
"\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\377\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0"};

903
samples/C/GLKMatrix4.h Normal file
View File

@@ -0,0 +1,903 @@
//
// GLKMatrix4.h
// GLKit
//
// Copyright (c) 2011, Apple Inc. All rights reserved.
//
#ifndef __GLK_MATRIX_4_H
#define __GLK_MATRIX_4_H
#include <stddef.h>
#include <stdbool.h>
#include <math.h>
#if defined(__ARM_NEON__)
#include <arm_neon.h>
#endif
#include <GLKit/GLKMathTypes.h>
#include <GLKit/GLKVector3.h>
#include <GLKit/GLKVector4.h>
#include <GLKit/GLKQuaternion.h>
#ifdef __cplusplus
extern "C" {
#endif
#pragma mark -
#pragma mark Prototypes
#pragma mark -
extern const GLKMatrix4 GLKMatrix4Identity;
/*
m30, m31, and m32 correspond to the translation values tx, ty, tz, respectively.
*/
static __inline__ GLKMatrix4 GLKMatrix4Make(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33);
/*
m03, m13, and m23 correspond to the translation values tx, ty, tz, respectively.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeAndTranspose(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33);
/*
m[12], m[13], and m[14] correspond to the translation values tx, ty, and tz, respectively.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeWithArray(float values[16]);
/*
m[3], m[7], and m[11] correspond to the translation values tx, ty, and tz, respectively.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeWithArrayAndTranspose(float values[16]);
/*
row0, row1, and row2's last component should correspond to the translation values tx, ty, and tz, respectively.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeWithRows(GLKVector4 row0,
GLKVector4 row1,
GLKVector4 row2,
GLKVector4 row3);
/*
column3's first three components should correspond to the translation values tx, ty, and tz.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeWithColumns(GLKVector4 column0,
GLKVector4 column1,
GLKVector4 column2,
GLKVector4 column3);
/*
The quaternion will be normalized before conversion.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeWithQuaternion(GLKQuaternion quaternion);
static __inline__ GLKMatrix4 GLKMatrix4MakeTranslation(float tx, float ty, float tz);
static __inline__ GLKMatrix4 GLKMatrix4MakeScale(float sx, float sy, float sz);
static __inline__ GLKMatrix4 GLKMatrix4MakeRotation(float radians, float x, float y, float z);
static __inline__ GLKMatrix4 GLKMatrix4MakeXRotation(float radians);
static __inline__ GLKMatrix4 GLKMatrix4MakeYRotation(float radians);
static __inline__ GLKMatrix4 GLKMatrix4MakeZRotation(float radians);
/*
Equivalent to gluPerspective.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakePerspective(float fovyRadians, float aspect, float nearZ, float farZ);
/*
Equivalent to glFrustum.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeFrustum(float left, float right,
float bottom, float top,
float nearZ, float farZ);
/*
Equivalent to glOrtho.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeOrtho(float left, float right,
float bottom, float top,
float nearZ, float farZ);
/*
Equivalent to gluLookAt.
*/
static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ);
/*
Returns the upper left 3x3 portion of the 4x4 matrix.
*/
static __inline__ GLKMatrix3 GLKMatrix4GetMatrix3(GLKMatrix4 matrix);
/*
Returns the upper left 2x2 portion of the 4x4 matrix.
*/
static __inline__ GLKMatrix2 GLKMatrix4GetMatrix2(GLKMatrix4 matrix);
/*
GLKMatrix4GetRow returns vectors for rows 0, 1, and 2 whose last component will be the translation value tx, ty, and tz, respectively.
Valid row values range from 0 to 3, inclusive.
*/
static __inline__ GLKVector4 GLKMatrix4GetRow(GLKMatrix4 matrix, int row);
/*
GLKMatrix4GetColumn returns a vector for column 3 whose first three components will be the translation values tx, ty, and tz.
Valid column values range from 0 to 3, inclusive.
*/
static __inline__ GLKVector4 GLKMatrix4GetColumn(GLKMatrix4 matrix, int column);
/*
GLKMatrix4SetRow expects that the vector for row 0, 1, and 2 will have a translation value as its last component.
Valid row values range from 0 to 3, inclusive.
*/
static __inline__ GLKMatrix4 GLKMatrix4SetRow(GLKMatrix4 matrix, int row, GLKVector4 vector);
/*
GLKMatrix4SetColumn expects that the vector for column 3 will contain the translation values tx, ty, and tz as its first three components, respectively.
Valid column values range from 0 to 3, inclusive.
*/
static __inline__ GLKMatrix4 GLKMatrix4SetColumn(GLKMatrix4 matrix, int column, GLKVector4 vector);
static __inline__ GLKMatrix4 GLKMatrix4Transpose(GLKMatrix4 matrix);
GLKMatrix4 GLKMatrix4Invert(GLKMatrix4 matrix, bool *isInvertible);
GLKMatrix4 GLKMatrix4InvertAndTranspose(GLKMatrix4 matrix, bool *isInvertible);
static __inline__ GLKMatrix4 GLKMatrix4Multiply(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight);
static __inline__ GLKMatrix4 GLKMatrix4Add(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight);
static __inline__ GLKMatrix4 GLKMatrix4Subtract(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight);
static __inline__ GLKMatrix4 GLKMatrix4Translate(GLKMatrix4 matrix, float tx, float ty, float tz);
static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector3(GLKMatrix4 matrix, GLKVector3 translationVector);
/*
The last component of the GLKVector4, translationVector, is ignored.
*/
static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector4(GLKMatrix4 matrix, GLKVector4 translationVector);
static __inline__ GLKMatrix4 GLKMatrix4Scale(GLKMatrix4 matrix, float sx, float sy, float sz);
static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector3(GLKMatrix4 matrix, GLKVector3 scaleVector);
/*
The last component of the GLKVector4, scaleVector, is ignored.
*/
static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector4(GLKMatrix4 matrix, GLKVector4 scaleVector);
static __inline__ GLKMatrix4 GLKMatrix4Rotate(GLKMatrix4 matrix, float radians, float x, float y, float z);
static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector3(GLKMatrix4 matrix, float radians, GLKVector3 axisVector);
/*
The last component of the GLKVector4, axisVector, is ignored.
*/
static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector4(GLKMatrix4 matrix, float radians, GLKVector4 axisVector);
static __inline__ GLKMatrix4 GLKMatrix4RotateX(GLKMatrix4 matrix, float radians);
static __inline__ GLKMatrix4 GLKMatrix4RotateY(GLKMatrix4 matrix, float radians);
static __inline__ GLKMatrix4 GLKMatrix4RotateZ(GLKMatrix4 matrix, float radians);
/*
Assumes 0 in the w component.
*/
static __inline__ GLKVector3 GLKMatrix4MultiplyVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight);
/*
Assumes 1 in the w component.
*/
static __inline__ GLKVector3 GLKMatrix4MultiplyVector3WithTranslation(GLKMatrix4 matrixLeft, GLKVector3 vectorRight);
/*
Assumes 1 in the w component and divides the resulting vector by w before returning.
*/
static __inline__ GLKVector3 GLKMatrix4MultiplyAndProjectVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight);
/*
Assumes 0 in the w component.
*/
static __inline__ void GLKMatrix4MultiplyVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount);
/*
Assumes 1 in the w component.
*/
static __inline__ void GLKMatrix4MultiplyVector3ArrayWithTranslation(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount);
/*
Assumes 1 in the w component and divides the resulting vector by w before returning.
*/
static __inline__ void GLKMatrix4MultiplyAndProjectVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount);
static __inline__ GLKVector4 GLKMatrix4MultiplyVector4(GLKMatrix4 matrixLeft, GLKVector4 vectorRight);
static __inline__ void GLKMatrix4MultiplyVector4Array(GLKMatrix4 matrix, GLKVector4 *vectors, size_t vectorCount);
#pragma mark -
#pragma mark Implementations
#pragma mark -
static __inline__ GLKMatrix4 GLKMatrix4Make(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33)
{
GLKMatrix4 m = { m00, m01, m02, m03,
m10, m11, m12, m13,
m20, m21, m22, m23,
m30, m31, m32, m33 };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeAndTranspose(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33)
{
GLKMatrix4 m = { m00, m10, m20, m30,
m01, m11, m21, m31,
m02, m12, m22, m32,
m03, m13, m23, m33 };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeWithArray(float values[16])
{
GLKMatrix4 m = { values[0], values[1], values[2], values[3],
values[4], values[5], values[6], values[7],
values[8], values[9], values[10], values[11],
values[12], values[13], values[14], values[15] };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeWithArrayAndTranspose(float values[16])
{
#if defined(__ARM_NEON__)
float32x4x4_t m = vld4q_f32(values);
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m = { values[0], values[4], values[8], values[12],
values[1], values[5], values[9], values[13],
values[2], values[6], values[10], values[14],
values[3], values[7], values[11], values[15] };
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4MakeWithRows(GLKVector4 row0,
GLKVector4 row1,
GLKVector4 row2,
GLKVector4 row3)
{
GLKMatrix4 m = { row0.v[0], row1.v[0], row2.v[0], row3.v[0],
row0.v[1], row1.v[1], row2.v[1], row3.v[1],
row0.v[2], row1.v[2], row2.v[2], row3.v[2],
row0.v[3], row1.v[3], row2.v[3], row3.v[3] };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeWithColumns(GLKVector4 column0,
GLKVector4 column1,
GLKVector4 column2,
GLKVector4 column3)
{
#if defined(__ARM_NEON__)
float32x4x4_t m;
m.val[0] = vld1q_f32(column0.v);
m.val[1] = vld1q_f32(column1.v);
m.val[2] = vld1q_f32(column2.v);
m.val[3] = vld1q_f32(column3.v);
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m = { column0.v[0], column0.v[1], column0.v[2], column0.v[3],
column1.v[0], column1.v[1], column1.v[2], column1.v[3],
column2.v[0], column2.v[1], column2.v[2], column2.v[3],
column3.v[0], column3.v[1], column3.v[2], column3.v[3] };
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4MakeWithQuaternion(GLKQuaternion quaternion)
{
quaternion = GLKQuaternionNormalize(quaternion);
float x = quaternion.q[0];
float y = quaternion.q[1];
float z = quaternion.q[2];
float w = quaternion.q[3];
float _2x = x + x;
float _2y = y + y;
float _2z = z + z;
float _2w = w + w;
GLKMatrix4 m = { 1.0f - _2y * y - _2z * z,
_2x * y + _2w * z,
_2x * z - _2w * y,
0.0f,
_2x * y - _2w * z,
1.0f - _2x * x - _2z * z,
_2y * z + _2w * x,
0.0f,
_2x * z + _2w * y,
_2y * z - _2w * x,
1.0f - _2x * x - _2y * y,
0.0f,
0.0f,
0.0f,
0.0f,
1.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeTranslation(float tx, float ty, float tz)
{
GLKMatrix4 m = GLKMatrix4Identity;
m.m[12] = tx;
m.m[13] = ty;
m.m[14] = tz;
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeScale(float sx, float sy, float sz)
{
GLKMatrix4 m = GLKMatrix4Identity;
m.m[0] = sx;
m.m[5] = sy;
m.m[10] = sz;
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeRotation(float radians, float x, float y, float z)
{
GLKVector3 v = GLKVector3Normalize(GLKVector3Make(x, y, z));
float cos = cosf(radians);
float cosp = 1.0f - cos;
float sin = sinf(radians);
GLKMatrix4 m = { cos + cosp * v.v[0] * v.v[0],
cosp * v.v[0] * v.v[1] + v.v[2] * sin,
cosp * v.v[0] * v.v[2] - v.v[1] * sin,
0.0f,
cosp * v.v[0] * v.v[1] - v.v[2] * sin,
cos + cosp * v.v[1] * v.v[1],
cosp * v.v[1] * v.v[2] + v.v[0] * sin,
0.0f,
cosp * v.v[0] * v.v[2] + v.v[1] * sin,
cosp * v.v[1] * v.v[2] - v.v[0] * sin,
cos + cosp * v.v[2] * v.v[2],
0.0f,
0.0f,
0.0f,
0.0f,
1.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeXRotation(float radians)
{
float cos = cosf(radians);
float sin = sinf(radians);
GLKMatrix4 m = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, cos, sin, 0.0f,
0.0f, -sin, cos, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeYRotation(float radians)
{
float cos = cosf(radians);
float sin = sinf(radians);
GLKMatrix4 m = { cos, 0.0f, -sin, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
sin, 0.0f, cos, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeZRotation(float radians)
{
float cos = cosf(radians);
float sin = sinf(radians);
GLKMatrix4 m = { cos, sin, 0.0f, 0.0f,
-sin, cos, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakePerspective(float fovyRadians, float aspect, float nearZ, float farZ)
{
float cotan = 1.0f / tanf(fovyRadians / 2.0f);
GLKMatrix4 m = { cotan / aspect, 0.0f, 0.0f, 0.0f,
0.0f, cotan, 0.0f, 0.0f,
0.0f, 0.0f, (farZ + nearZ) / (nearZ - farZ), -1.0f,
0.0f, 0.0f, (2.0f * farZ * nearZ) / (nearZ - farZ), 0.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeFrustum(float left, float right,
float bottom, float top,
float nearZ, float farZ)
{
float ral = right + left;
float rsl = right - left;
float tsb = top - bottom;
float tab = top + bottom;
float fan = farZ + nearZ;
float fsn = farZ - nearZ;
GLKMatrix4 m = { 2.0f * nearZ / rsl, 0.0f, 0.0f, 0.0f,
0.0f, 2.0f * nearZ / tsb, 0.0f, 0.0f,
ral / rsl, tab / tsb, -fan / fsn, -1.0f,
0.0f, 0.0f, (-2.0f * farZ * nearZ) / fsn, 0.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeOrtho(float left, float right,
float bottom, float top,
float nearZ, float farZ)
{
float ral = right + left;
float rsl = right - left;
float tab = top + bottom;
float tsb = top - bottom;
float fan = farZ + nearZ;
float fsn = farZ - nearZ;
GLKMatrix4 m = { 2.0f / rsl, 0.0f, 0.0f, 0.0f,
0.0f, 2.0f / tsb, 0.0f, 0.0f,
0.0f, 0.0f, -2.0f / fsn, 0.0f,
-ral / rsl, -tab / tsb, -fan / fsn, 1.0f };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ)
{
GLKVector3 ev = { eyeX, eyeY, eyeZ };
GLKVector3 cv = { centerX, centerY, centerZ };
GLKVector3 uv = { upX, upY, upZ };
GLKVector3 n = GLKVector3Normalize(GLKVector3Add(ev, GLKVector3Negate(cv)));
GLKVector3 u = GLKVector3Normalize(GLKVector3CrossProduct(uv, n));
GLKVector3 v = GLKVector3CrossProduct(n, u);
GLKMatrix4 m = { u.v[0], v.v[0], n.v[0], 0.0f,
u.v[1], v.v[1], n.v[1], 0.0f,
u.v[2], v.v[2], n.v[2], 0.0f,
GLKVector3DotProduct(GLKVector3Negate(u), ev),
GLKVector3DotProduct(GLKVector3Negate(v), ev),
GLKVector3DotProduct(GLKVector3Negate(n), ev),
1.0f };
return m;
}
static __inline__ GLKMatrix3 GLKMatrix4GetMatrix3(GLKMatrix4 matrix)
{
GLKMatrix3 m = { matrix.m[0], matrix.m[1], matrix.m[2],
matrix.m[4], matrix.m[5], matrix.m[6],
matrix.m[8], matrix.m[9], matrix.m[10] };
return m;
}
static __inline__ GLKMatrix2 GLKMatrix4GetMatrix2(GLKMatrix4 matrix)
{
GLKMatrix2 m = { matrix.m[0], matrix.m[1],
matrix.m[4], matrix.m[5] };
return m;
}
static __inline__ GLKVector4 GLKMatrix4GetRow(GLKMatrix4 matrix, int row)
{
GLKVector4 v = { matrix.m[row], matrix.m[4 + row], matrix.m[8 + row], matrix.m[12 + row] };
return v;
}
static __inline__ GLKVector4 GLKMatrix4GetColumn(GLKMatrix4 matrix, int column)
{
#if defined(__ARM_NEON__)
float32x4_t v = vld1q_f32(&(matrix.m[column * 4]));
return *(GLKVector4 *)&v;
#else
GLKVector4 v = { matrix.m[column * 4 + 0], matrix.m[column * 4 + 1], matrix.m[column * 4 + 2], matrix.m[column * 4 + 3] };
return v;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4SetRow(GLKMatrix4 matrix, int row, GLKVector4 vector)
{
matrix.m[row] = vector.v[0];
matrix.m[row + 4] = vector.v[1];
matrix.m[row + 8] = vector.v[2];
matrix.m[row + 12] = vector.v[3];
return matrix;
}
static __inline__ GLKMatrix4 GLKMatrix4SetColumn(GLKMatrix4 matrix, int column, GLKVector4 vector)
{
#if defined(__ARM_NEON__)
float *dst = &(matrix.m[column * 4]);
vst1q_f32(dst, vld1q_f32(vector.v));
return matrix;
#else
matrix.m[column * 4 + 0] = vector.v[0];
matrix.m[column * 4 + 1] = vector.v[1];
matrix.m[column * 4 + 2] = vector.v[2];
matrix.m[column * 4 + 3] = vector.v[3];
return matrix;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4Transpose(GLKMatrix4 matrix)
{
#if defined(__ARM_NEON__)
float32x4x4_t m = vld4q_f32(matrix.m);
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m = { matrix.m[0], matrix.m[4], matrix.m[8], matrix.m[12],
matrix.m[1], matrix.m[5], matrix.m[9], matrix.m[13],
matrix.m[2], matrix.m[6], matrix.m[10], matrix.m[14],
matrix.m[3], matrix.m[7], matrix.m[11], matrix.m[15] };
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4Multiply(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrixLeft = *(float32x4x4_t *)&matrixLeft;
float32x4x4_t iMatrixRight = *(float32x4x4_t *)&matrixRight;
float32x4x4_t m;
m.val[0] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[0], 0));
m.val[1] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[1], 0));
m.val[2] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[2], 0));
m.val[3] = vmulq_n_f32(iMatrixLeft.val[0], vgetq_lane_f32(iMatrixRight.val[3], 0));
m.val[0] = vmlaq_n_f32(m.val[0], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[0], 1));
m.val[1] = vmlaq_n_f32(m.val[1], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[1], 1));
m.val[2] = vmlaq_n_f32(m.val[2], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[2], 1));
m.val[3] = vmlaq_n_f32(m.val[3], iMatrixLeft.val[1], vgetq_lane_f32(iMatrixRight.val[3], 1));
m.val[0] = vmlaq_n_f32(m.val[0], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[0], 2));
m.val[1] = vmlaq_n_f32(m.val[1], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[1], 2));
m.val[2] = vmlaq_n_f32(m.val[2], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[2], 2));
m.val[3] = vmlaq_n_f32(m.val[3], iMatrixLeft.val[2], vgetq_lane_f32(iMatrixRight.val[3], 2));
m.val[0] = vmlaq_n_f32(m.val[0], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[0], 3));
m.val[1] = vmlaq_n_f32(m.val[1], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[1], 3));
m.val[2] = vmlaq_n_f32(m.val[2], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[2], 3));
m.val[3] = vmlaq_n_f32(m.val[3], iMatrixLeft.val[3], vgetq_lane_f32(iMatrixRight.val[3], 3));
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m;
m.m[0] = matrixLeft.m[0] * matrixRight.m[0] + matrixLeft.m[4] * matrixRight.m[1] + matrixLeft.m[8] * matrixRight.m[2] + matrixLeft.m[12] * matrixRight.m[3];
m.m[4] = matrixLeft.m[0] * matrixRight.m[4] + matrixLeft.m[4] * matrixRight.m[5] + matrixLeft.m[8] * matrixRight.m[6] + matrixLeft.m[12] * matrixRight.m[7];
m.m[8] = matrixLeft.m[0] * matrixRight.m[8] + matrixLeft.m[4] * matrixRight.m[9] + matrixLeft.m[8] * matrixRight.m[10] + matrixLeft.m[12] * matrixRight.m[11];
m.m[12] = matrixLeft.m[0] * matrixRight.m[12] + matrixLeft.m[4] * matrixRight.m[13] + matrixLeft.m[8] * matrixRight.m[14] + matrixLeft.m[12] * matrixRight.m[15];
m.m[1] = matrixLeft.m[1] * matrixRight.m[0] + matrixLeft.m[5] * matrixRight.m[1] + matrixLeft.m[9] * matrixRight.m[2] + matrixLeft.m[13] * matrixRight.m[3];
m.m[5] = matrixLeft.m[1] * matrixRight.m[4] + matrixLeft.m[5] * matrixRight.m[5] + matrixLeft.m[9] * matrixRight.m[6] + matrixLeft.m[13] * matrixRight.m[7];
m.m[9] = matrixLeft.m[1] * matrixRight.m[8] + matrixLeft.m[5] * matrixRight.m[9] + matrixLeft.m[9] * matrixRight.m[10] + matrixLeft.m[13] * matrixRight.m[11];
m.m[13] = matrixLeft.m[1] * matrixRight.m[12] + matrixLeft.m[5] * matrixRight.m[13] + matrixLeft.m[9] * matrixRight.m[14] + matrixLeft.m[13] * matrixRight.m[15];
m.m[2] = matrixLeft.m[2] * matrixRight.m[0] + matrixLeft.m[6] * matrixRight.m[1] + matrixLeft.m[10] * matrixRight.m[2] + matrixLeft.m[14] * matrixRight.m[3];
m.m[6] = matrixLeft.m[2] * matrixRight.m[4] + matrixLeft.m[6] * matrixRight.m[5] + matrixLeft.m[10] * matrixRight.m[6] + matrixLeft.m[14] * matrixRight.m[7];
m.m[10] = matrixLeft.m[2] * matrixRight.m[8] + matrixLeft.m[6] * matrixRight.m[9] + matrixLeft.m[10] * matrixRight.m[10] + matrixLeft.m[14] * matrixRight.m[11];
m.m[14] = matrixLeft.m[2] * matrixRight.m[12] + matrixLeft.m[6] * matrixRight.m[13] + matrixLeft.m[10] * matrixRight.m[14] + matrixLeft.m[14] * matrixRight.m[15];
m.m[3] = matrixLeft.m[3] * matrixRight.m[0] + matrixLeft.m[7] * matrixRight.m[1] + matrixLeft.m[11] * matrixRight.m[2] + matrixLeft.m[15] * matrixRight.m[3];
m.m[7] = matrixLeft.m[3] * matrixRight.m[4] + matrixLeft.m[7] * matrixRight.m[5] + matrixLeft.m[11] * matrixRight.m[6] + matrixLeft.m[15] * matrixRight.m[7];
m.m[11] = matrixLeft.m[3] * matrixRight.m[8] + matrixLeft.m[7] * matrixRight.m[9] + matrixLeft.m[11] * matrixRight.m[10] + matrixLeft.m[15] * matrixRight.m[11];
m.m[15] = matrixLeft.m[3] * matrixRight.m[12] + matrixLeft.m[7] * matrixRight.m[13] + matrixLeft.m[11] * matrixRight.m[14] + matrixLeft.m[15] * matrixRight.m[15];
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4Add(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrixLeft = *(float32x4x4_t *)&matrixLeft;
float32x4x4_t iMatrixRight = *(float32x4x4_t *)&matrixRight;
float32x4x4_t m;
m.val[0] = vaddq_f32(iMatrixLeft.val[0], iMatrixRight.val[0]);
m.val[1] = vaddq_f32(iMatrixLeft.val[1], iMatrixRight.val[1]);
m.val[2] = vaddq_f32(iMatrixLeft.val[2], iMatrixRight.val[2]);
m.val[3] = vaddq_f32(iMatrixLeft.val[3], iMatrixRight.val[3]);
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m;
m.m[0] = matrixLeft.m[0] + matrixRight.m[0];
m.m[1] = matrixLeft.m[1] + matrixRight.m[1];
m.m[2] = matrixLeft.m[2] + matrixRight.m[2];
m.m[3] = matrixLeft.m[3] + matrixRight.m[3];
m.m[4] = matrixLeft.m[4] + matrixRight.m[4];
m.m[5] = matrixLeft.m[5] + matrixRight.m[5];
m.m[6] = matrixLeft.m[6] + matrixRight.m[6];
m.m[7] = matrixLeft.m[7] + matrixRight.m[7];
m.m[8] = matrixLeft.m[8] + matrixRight.m[8];
m.m[9] = matrixLeft.m[9] + matrixRight.m[9];
m.m[10] = matrixLeft.m[10] + matrixRight.m[10];
m.m[11] = matrixLeft.m[11] + matrixRight.m[11];
m.m[12] = matrixLeft.m[12] + matrixRight.m[12];
m.m[13] = matrixLeft.m[13] + matrixRight.m[13];
m.m[14] = matrixLeft.m[14] + matrixRight.m[14];
m.m[15] = matrixLeft.m[15] + matrixRight.m[15];
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4Subtract(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrixLeft = *(float32x4x4_t *)&matrixLeft;
float32x4x4_t iMatrixRight = *(float32x4x4_t *)&matrixRight;
float32x4x4_t m;
m.val[0] = vsubq_f32(iMatrixLeft.val[0], iMatrixRight.val[0]);
m.val[1] = vsubq_f32(iMatrixLeft.val[1], iMatrixRight.val[1]);
m.val[2] = vsubq_f32(iMatrixLeft.val[2], iMatrixRight.val[2]);
m.val[3] = vsubq_f32(iMatrixLeft.val[3], iMatrixRight.val[3]);
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m;
m.m[0] = matrixLeft.m[0] - matrixRight.m[0];
m.m[1] = matrixLeft.m[1] - matrixRight.m[1];
m.m[2] = matrixLeft.m[2] - matrixRight.m[2];
m.m[3] = matrixLeft.m[3] - matrixRight.m[3];
m.m[4] = matrixLeft.m[4] - matrixRight.m[4];
m.m[5] = matrixLeft.m[5] - matrixRight.m[5];
m.m[6] = matrixLeft.m[6] - matrixRight.m[6];
m.m[7] = matrixLeft.m[7] - matrixRight.m[7];
m.m[8] = matrixLeft.m[8] - matrixRight.m[8];
m.m[9] = matrixLeft.m[9] - matrixRight.m[9];
m.m[10] = matrixLeft.m[10] - matrixRight.m[10];
m.m[11] = matrixLeft.m[11] - matrixRight.m[11];
m.m[12] = matrixLeft.m[12] - matrixRight.m[12];
m.m[13] = matrixLeft.m[13] - matrixRight.m[13];
m.m[14] = matrixLeft.m[14] - matrixRight.m[14];
m.m[15] = matrixLeft.m[15] - matrixRight.m[15];
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4Translate(GLKMatrix4 matrix, float tx, float ty, float tz)
{
GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3],
matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7],
matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11],
matrix.m[0] * tx + matrix.m[4] * ty + matrix.m[8] * tz + matrix.m[12],
matrix.m[1] * tx + matrix.m[5] * ty + matrix.m[9] * tz + matrix.m[13],
matrix.m[2] * tx + matrix.m[6] * ty + matrix.m[10] * tz + matrix.m[14],
matrix.m[15] };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector3(GLKMatrix4 matrix, GLKVector3 translationVector)
{
GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3],
matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7],
matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11],
matrix.m[0] * translationVector.v[0] + matrix.m[4] * translationVector.v[1] + matrix.m[8] * translationVector.v[2] + matrix.m[12],
matrix.m[1] * translationVector.v[0] + matrix.m[5] * translationVector.v[1] + matrix.m[9] * translationVector.v[2] + matrix.m[13],
matrix.m[2] * translationVector.v[0] + matrix.m[6] * translationVector.v[1] + matrix.m[10] * translationVector.v[2] + matrix.m[14],
matrix.m[15] };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4TranslateWithVector4(GLKMatrix4 matrix, GLKVector4 translationVector)
{
GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3],
matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7],
matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11],
matrix.m[0] * translationVector.v[0] + matrix.m[4] * translationVector.v[1] + matrix.m[8] * translationVector.v[2] + matrix.m[12],
matrix.m[1] * translationVector.v[0] + matrix.m[5] * translationVector.v[1] + matrix.m[9] * translationVector.v[2] + matrix.m[13],
matrix.m[2] * translationVector.v[0] + matrix.m[6] * translationVector.v[1] + matrix.m[10] * translationVector.v[2] + matrix.m[14],
matrix.m[15] };
return m;
}
static __inline__ GLKMatrix4 GLKMatrix4Scale(GLKMatrix4 matrix, float sx, float sy, float sz)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrix = *(float32x4x4_t *)&matrix;
float32x4x4_t m;
m.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)sx);
m.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)sy);
m.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)sz);
m.val[3] = iMatrix.val[3];
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m = { matrix.m[0] * sx, matrix.m[1] * sx, matrix.m[2] * sx, matrix.m[3] * sx,
matrix.m[4] * sy, matrix.m[5] * sy, matrix.m[6] * sy, matrix.m[7] * sy,
matrix.m[8] * sz, matrix.m[9] * sz, matrix.m[10] * sz, matrix.m[11] * sz,
matrix.m[12], matrix.m[13], matrix.m[14], matrix.m[15] };
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector3(GLKMatrix4 matrix, GLKVector3 scaleVector)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrix = *(float32x4x4_t *)&matrix;
float32x4x4_t m;
m.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)scaleVector.v[0]);
m.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)scaleVector.v[1]);
m.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)scaleVector.v[2]);
m.val[3] = iMatrix.val[3];
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m = { matrix.m[0] * scaleVector.v[0], matrix.m[1] * scaleVector.v[0], matrix.m[2] * scaleVector.v[0], matrix.m[3] * scaleVector.v[0],
matrix.m[4] * scaleVector.v[1], matrix.m[5] * scaleVector.v[1], matrix.m[6] * scaleVector.v[1], matrix.m[7] * scaleVector.v[1],
matrix.m[8] * scaleVector.v[2], matrix.m[9] * scaleVector.v[2], matrix.m[10] * scaleVector.v[2], matrix.m[11] * scaleVector.v[2],
matrix.m[12], matrix.m[13], matrix.m[14], matrix.m[15] };
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4ScaleWithVector4(GLKMatrix4 matrix, GLKVector4 scaleVector)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrix = *(float32x4x4_t *)&matrix;
float32x4x4_t m;
m.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)scaleVector.v[0]);
m.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)scaleVector.v[1]);
m.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)scaleVector.v[2]);
m.val[3] = iMatrix.val[3];
return *(GLKMatrix4 *)&m;
#else
GLKMatrix4 m = { matrix.m[0] * scaleVector.v[0], matrix.m[1] * scaleVector.v[0], matrix.m[2] * scaleVector.v[0], matrix.m[3] * scaleVector.v[0],
matrix.m[4] * scaleVector.v[1], matrix.m[5] * scaleVector.v[1], matrix.m[6] * scaleVector.v[1], matrix.m[7] * scaleVector.v[1],
matrix.m[8] * scaleVector.v[2], matrix.m[9] * scaleVector.v[2], matrix.m[10] * scaleVector.v[2], matrix.m[11] * scaleVector.v[2],
matrix.m[12], matrix.m[13], matrix.m[14], matrix.m[15] };
return m;
#endif
}
static __inline__ GLKMatrix4 GLKMatrix4Rotate(GLKMatrix4 matrix, float radians, float x, float y, float z)
{
GLKMatrix4 rm = GLKMatrix4MakeRotation(radians, x, y, z);
return GLKMatrix4Multiply(matrix, rm);
}
static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector3(GLKMatrix4 matrix, float radians, GLKVector3 axisVector)
{
GLKMatrix4 rm = GLKMatrix4MakeRotation(radians, axisVector.v[0], axisVector.v[1], axisVector.v[2]);
return GLKMatrix4Multiply(matrix, rm);
}
static __inline__ GLKMatrix4 GLKMatrix4RotateWithVector4(GLKMatrix4 matrix, float radians, GLKVector4 axisVector)
{
GLKMatrix4 rm = GLKMatrix4MakeRotation(radians, axisVector.v[0], axisVector.v[1], axisVector.v[2]);
return GLKMatrix4Multiply(matrix, rm);
}
static __inline__ GLKMatrix4 GLKMatrix4RotateX(GLKMatrix4 matrix, float radians)
{
GLKMatrix4 rm = GLKMatrix4MakeXRotation(radians);
return GLKMatrix4Multiply(matrix, rm);
}
static __inline__ GLKMatrix4 GLKMatrix4RotateY(GLKMatrix4 matrix, float radians)
{
GLKMatrix4 rm = GLKMatrix4MakeYRotation(radians);
return GLKMatrix4Multiply(matrix, rm);
}
static __inline__ GLKMatrix4 GLKMatrix4RotateZ(GLKMatrix4 matrix, float radians)
{
GLKMatrix4 rm = GLKMatrix4MakeZRotation(radians);
return GLKMatrix4Multiply(matrix, rm);
}
static __inline__ GLKVector3 GLKMatrix4MultiplyVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight)
{
GLKVector4 v4 = GLKMatrix4MultiplyVector4(matrixLeft, GLKVector4Make(vectorRight.v[0], vectorRight.v[1], vectorRight.v[2], 0.0f));
return GLKVector3Make(v4.v[0], v4.v[1], v4.v[2]);
}
static __inline__ GLKVector3 GLKMatrix4MultiplyVector3WithTranslation(GLKMatrix4 matrixLeft, GLKVector3 vectorRight)
{
GLKVector4 v4 = GLKMatrix4MultiplyVector4(matrixLeft, GLKVector4Make(vectorRight.v[0], vectorRight.v[1], vectorRight.v[2], 1.0f));
return GLKVector3Make(v4.v[0], v4.v[1], v4.v[2]);
}
static __inline__ GLKVector3 GLKMatrix4MultiplyAndProjectVector3(GLKMatrix4 matrixLeft, GLKVector3 vectorRight)
{
GLKVector4 v4 = GLKMatrix4MultiplyVector4(matrixLeft, GLKVector4Make(vectorRight.v[0], vectorRight.v[1], vectorRight.v[2], 1.0f));
return GLKVector3MultiplyScalar(GLKVector3Make(v4.v[0], v4.v[1], v4.v[2]), 1.0f / v4.v[3]);
}
static __inline__ void GLKMatrix4MultiplyVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount)
{
size_t i;
for (i=0; i < vectorCount; i++)
vectors[i] = GLKMatrix4MultiplyVector3(matrix, vectors[i]);
}
static __inline__ void GLKMatrix4MultiplyVector3ArrayWithTranslation(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount)
{
size_t i;
for (i=0; i < vectorCount; i++)
vectors[i] = GLKMatrix4MultiplyVector3WithTranslation(matrix, vectors[i]);
}
static __inline__ void GLKMatrix4MultiplyAndProjectVector3Array(GLKMatrix4 matrix, GLKVector3 *vectors, size_t vectorCount)
{
size_t i;
for (i=0; i < vectorCount; i++)
vectors[i] = GLKMatrix4MultiplyAndProjectVector3(matrix, vectors[i]);
}
static __inline__ GLKVector4 GLKMatrix4MultiplyVector4(GLKMatrix4 matrixLeft, GLKVector4 vectorRight)
{
#if defined(__ARM_NEON__)
float32x4x4_t iMatrix = *(float32x4x4_t *)&matrixLeft;
float32x4_t v;
iMatrix.val[0] = vmulq_n_f32(iMatrix.val[0], (float32_t)vectorRight.v[0]);
iMatrix.val[1] = vmulq_n_f32(iMatrix.val[1], (float32_t)vectorRight.v[1]);
iMatrix.val[2] = vmulq_n_f32(iMatrix.val[2], (float32_t)vectorRight.v[2]);
iMatrix.val[3] = vmulq_n_f32(iMatrix.val[3], (float32_t)vectorRight.v[3]);
iMatrix.val[0] = vaddq_f32(iMatrix.val[0], iMatrix.val[1]);
iMatrix.val[2] = vaddq_f32(iMatrix.val[2], iMatrix.val[3]);
v = vaddq_f32(iMatrix.val[0], iMatrix.val[2]);
return *(GLKVector4 *)&v;
#else
GLKVector4 v = { matrixLeft.m[0] * vectorRight.v[0] + matrixLeft.m[4] * vectorRight.v[1] + matrixLeft.m[8] * vectorRight.v[2] + matrixLeft.m[12] * vectorRight.v[3],
matrixLeft.m[1] * vectorRight.v[0] + matrixLeft.m[5] * vectorRight.v[1] + matrixLeft.m[9] * vectorRight.v[2] + matrixLeft.m[13] * vectorRight.v[3],
matrixLeft.m[2] * vectorRight.v[0] + matrixLeft.m[6] * vectorRight.v[1] + matrixLeft.m[10] * vectorRight.v[2] + matrixLeft.m[14] * vectorRight.v[3],
matrixLeft.m[3] * vectorRight.v[0] + matrixLeft.m[7] * vectorRight.v[1] + matrixLeft.m[11] * vectorRight.v[2] + matrixLeft.m[15] * vectorRight.v[3] };
return v;
#endif
}
static __inline__ void GLKMatrix4MultiplyVector4Array(GLKMatrix4 matrix, GLKVector4 *vectors, size_t vectorCount)
{
size_t i;
for (i=0; i < vectorCount; i++)
vectors[i] = GLKMatrix4MultiplyVector4(matrix, vectors[i]);
}
#ifdef __cplusplus
}
#endif
#endif /* __GLK_MATRIX_4_H */

99
samples/C/NWMan.h Normal file
View File

@@ -0,0 +1,99 @@
#ifndef _NME_WMAN_H
#define _NME_WMAN_H
// Internal window manager API
#include "NCompat.h"
START_HEAD
#include "NPos.h"
#include "NUtil.h"
#include "NTypes.h"
NTS(NWMan_event);
NSTRUCT(NWMan, {
// Init stuff
bool (*init)();
bool (*destroy)();
// Window stuff
bool (*create_window)();
bool (*destroy_window)();
void (*swap_buffers)();
// Event stuff
bool (*next_event)(NWMan_event* event);
// Time stuff
uint (*get_millis)();
void (*sleep)(uint millis);
// Info
int rshift_key;
int lshift_key;
int left_key;
int right_key;
});
NENUM(NWMan_event_type, {
N_WMAN_MOUSE_MOVE = 0,
N_WMAN_MOUSE_BUTTON = 1,
N_WMAN_MOUSE_WHEEL = 2,
N_WMAN_KEYBOARD = 10,
N_WMAN_QUIT = 20,
N_WMAN_RESIZE = 21,
N_WMAN_FOCUS = 22
});
#define N_WMAN_MOUSE_LEFT 0
#define N_WMAN_MOUSE_RIGHT 1
#define N_WMAN_MOUSE_MIDDLE 2
NSTRUCT(NWMan_event, {
NWMan_event_type type;
union {
// Mouse
NPos2i mouse_pos;
struct {
short id;
bool state;
} mouse_button;
signed char mouse_wheel; // 1 if up, -1 if down
// Keyboard
struct {
int key;
bool state;
} keyboard;
// Window
bool window_quit; // Will always be true if WM_QUIT
NPos2i window_size;
bool window_focus;
};
});
NWMan_event NWMan_event_new(NWMan_event_type type);
bool NWMan_init();
bool NWMan_destroy();
extern NWMan N_WMan;
END_HEAD
#endif

27
samples/C/Nightmare.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef _NMEX_NIGHTMARE_H
#define _NMEX_NIGHTMARE_H
//#define NMEX
#include "../src/NCompat.h"
START_HEAD
#include "../src/NTypes.h"
#include "../src/NUtil.h"
#include "../src/NPorting.h"
#include "../src/NGlobals.h"
#include "../src/NLog.h"
#include "../src/NWMan.h"
#include "../src/NRsc.h"
#include "../src/NShader.h"
#include "../src/NSquare.h"
#include "../src/NImage.h"
#include "../src/NSprite.h"
#include "../src/NSpritesheet.h"
#include "../src/NEntity.h"
#include "../src/Game.h"
END_HEAD
#endif

47
samples/C/bitmap.h Normal file
View File

@@ -0,0 +1,47 @@
#pragma once
/* Copyright © 2010 Christoph Sünderhauf
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include "generic.h"
typedef struct {
uint32_t numbits;
/* an array large enough for numbits to fit in. Might
* (if numbits%8!=0) have some spare bits at the end
*/
uint32_t* bits;
} bitmap_t;
// creates a new bitmap.
// CONTENT IS RANDOM! - use bitmap_clearall() to clear the bitmap.
bitmap_t bitmap_init(uint32_t numbits);
// returns 1 or 0
uint8_t bitmap_get(bitmap_t bitmap, uint32_t bitnum);
// sets a bit (to 1)
void bitmap_set(bitmap_t bitmap, uint32_t bitnum);
// clears a bit (to 0)
void bitmap_clear(bitmap_t bitmap, uint32_t bitnum);
// clears every bit to 0
void bitmap_clearAll(bitmap_t bitmap);
// finds the first bit set to 0 returns 0 if no cleared bit found (0 is also returned if the first bit is cleared)
uint32_t bitmap_findFirstClear(bitmap_t bitmap);

44
samples/C/color.h Normal file
View File

@@ -0,0 +1,44 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
typedef struct {
uint32_t background;
uint32_t foreground;
} console_color_t;
#define CONSOLE_COLOR_BLACK 0x0
#define CONSOLE_COLOR_BLUE 0x1
#define CONSOLE_COLOR_GREEN 0x2
#define CONSOLE_COLOR_CYAN 0x3
#define CONSOLE_COLOR_RED 0x4
#define CONSOLE_COLOR_MAGENTA 0x5
#define CONSOLE_COLOR_BROWN 0x6
#define CONSOLE_COLOR_LGREY 0x7
#define CONSOLE_COLOR_DGREY 0x8
#define CONSOLE_COLOR_LBLUE 0x9
#define CONSOLE_COLOR_LGREEN 0xa
#define CONSOLE_COLOR_LCYAN 0xb
#define CONSOLE_COLOR_LRED 0xc
#define CONSOLE_COLOR_LMAGENTA 0xd
#define CONSOLE_COLOR_YELLOW 0xe
#define CONSOLE_COLOR_WHITE 0xf

52
samples/C/driver.h Normal file
View File

@@ -0,0 +1,52 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <console/info.h>
#define CONSOLE_DRV_CAP_CLEAR 0x01
#define CONSOLE_DRV_CAP_SCROLL 0x02
#define CONSOLE_DRV_CAP_SET_CURSOR 0x04
// Input modifier keys
typedef struct {
bool shift_left:1;
bool shift_right:1;
bool control_left:1;
bool control_right:1;
bool alt:1;
bool super:1;
} console_modifiers_t;
typedef struct {
char character;
console_modifiers_t* modifiers;
} console_read_t;
typedef struct {
int (*write)(console_info_t*, char);
console_read_t* (*read)(console_info_t*);
int capabilities;
int (*_clear)(console_info_t*);
int (*scroll)(console_info_t*, int32_t);
void (*setCursor)(console_info_t*, uint32_t, uint32_t);
} console_driver_t;

70
samples/C/elf.h Normal file
View File

@@ -0,0 +1,70 @@
#pragma once
/* Copyright © 2011 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <tasks/scheduler.h>
#define ELF_TYPE_NONE 0
#define ELF_TYPE_REL 1
#define ELF_TYPE_EXEC 2
#define ELF_TYPE_DYN 3
#define ELF_TYPE_CORE 4
#define ELF_ARCH_NONE 0
#define ELF_ARCH_386 3
#define ELF_VERSION_CURRENT 1
typedef struct {
unsigned char magic[4];
/* Note: There _is_ other stuff in here, but we don't need it */
unsigned char pad[12];
} __attribute__((packed)) elf_ident_t;
typedef struct {
uint32_t type;
uint32_t offset;
void* virtaddr;
void* physaddr;
uint32_t filesize;
uint32_t memsize;
uint32_t flags;
uint32_t alignment;
} __attribute__((packed)) elf_program_t;
typedef struct {
elf_ident_t ident;
uint16_t type; /* Object file type */
uint16_t machine; /* Architecture */
uint32_t version; /* Object file version */
void* entry; /* Entry point virtual address */
uint32_t phoff; /* Program header table file offset */
uint32_t shoff; /* Section header table file offset */
uint32_t flags; /* Processor-specific flags */
uint16_t ehsize; /* ELF header size in bytes */
uint16_t phentsize; /* Program header table entry size */
uint16_t phnum; /* Program header table entry count */
uint16_t shentsize; /* Section header table entry size */
uint16_t shnum; /* Section header table entry count */
uint16_t shstrndx; /* Section header string table index */
} __attribute__((packed)) elf_t;
task_t* elf_load(elf_t* bin, char* name, char** environ, char** argv, int argc);
task_t* elf_load_file(char* path, char** environ, char** argv, int argc);

45
samples/C/filter.h Normal file
View File

@@ -0,0 +1,45 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <console/info.h>
#include <console/driver.h>
struct console_filter {
// General callback for all actions etc.
// Preferred prototype:
// char <name>(char c, console_info_t *info, console_driver_t *input, console_driver_t *output);
char (*callback)(char, console_info_t*, console_driver_t*, console_driver_t*);
// Specific callbacks for read and write
// Preferred prototype:
// char <name>(char c, console_info_t *info, console_driver_t *input);
char (*read_callback)(char, console_info_t*, console_driver_t*);
// Preferred prototype:
// char <name>(char c, console_info_t *info, console_driver_t *output);
char (*write_callback)(char, console_info_t*, console_driver_t*);
// The next filter in the filter chain
struct console_filter* next;
};
typedef struct console_filter console_filter_t;

44
samples/C/info.h Normal file
View File

@@ -0,0 +1,44 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <console/color.h>
typedef struct {
uint32_t cursor_x;
uint32_t cursor_y;
uint32_t rows;
uint32_t columns;
uint32_t tabstop;
console_color_t default_color;
console_color_t current_color;
uint8_t nonblocking;
uint8_t reverse_video;
uint8_t bold;
uint8_t blink;
uint8_t underline;
uint8_t newline_mode;
uint8_t auto_echo;
uint8_t handle_backspace;
} console_info_t;

47
samples/C/interface.h Normal file
View File

@@ -0,0 +1,47 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <console/info.h>
#include <console/filter.h>
#include <console/driver.h>
typedef struct {
console_info_t info;
console_filter_t* input_filter;
console_filter_t* output_filter;
console_driver_t* input_driver;
console_driver_t* output_driver;
} console_t;
console_t* default_console;
// Generate raw console, connected to the Display, Keyboard and the
// ECMA-48-Filter
void console_init();
size_t console_write(console_t* console, const char* buffer, int32_t length);
#define console_write2(console, buffer) console_write(console, buffer, strlen(buffer))
size_t console_read(console_t* console, char* buffer, size_t length);
size_t console_scroll(console_t* console, int32_t pages);
void console_clear(console_t* console);

50
samples/C/ip4.h Normal file
View File

@@ -0,0 +1,50 @@
#pragma once
/* Copyright © 2011 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <net/net.h>
#define IP4_TOS_ICMP 0
typedef uint32_t ip4_addr_t;
typedef struct {
unsigned int hl:4; /* both fields are 4 bits */
unsigned int version:4;
uint8_t tos;
uint16_t len;
uint16_t id;
uint16_t off;
uint8_t ttl;
uint8_t p;
uint16_t checksum;
ip4_addr_t src;
ip4_addr_t dst;
} ip4_header_t;
typedef struct {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint16_t id;
uint16_t sequence;
} ip4_icmp_header_t;
void ip4_receive(net_device_t* origin, net_l2proto_t proto, size_t size, void* raw);

110
samples/C/multiboot.h Normal file
View File

@@ -0,0 +1,110 @@
#pragma once
/* Copyright © 2010, 2011 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#define MULTIBOOT_KERNELMAGIC 0x2BADB002
#define MULTIBOOT_FLAG_MEM 0x001
#define MULTIBOOT_FLAG_DEVICE 0x002
#define MULTIBOOT_FLAG_CMDLINE 0x004
#define MULTIBOOT_FLAG_MODS 0x008
#define MULTIBOOT_FLAG_AOUT 0x010
#define MULTIBOOT_FLAG_ELF 0x020
#define MULTIBOOT_FLAG_MMAP 0x040
#define MULTIBOOT_FLAG_CONFIG 0x080
#define MULTIBOOT_FLAG_LOADER 0x100
#define MULTIBOOT_FLAG_APM 0x200
#define MULTIBOOT_FLAG_VBE 0x400
// The symbol table for a.out.
typedef struct
{
uint32_t tabSize;
uint32_t strSize;
uint32_t addr;
uint32_t reserved;
} __attribute__((packed)) multiboot_aoutSymbolTable_t;
// The section header table for ELF.
typedef struct
{
uint32_t num;
uint32_t size;
uint32_t addr;
uint32_t shndx;
} __attribute__((packed)) multiboot_elfSectionHeaderTable_t;
typedef struct
{
uint32_t size;
uint64_t addr;
uint64_t length;
uint32_t type;
} __attribute__((packed)) multiboot_memoryMap_t;
typedef struct
{
uint32_t start;
uint32_t end;
char* cmdLine;
uint32_t reserved;
} __attribute__((packed)) multiboot_module_t;
typedef struct
{
uint32_t flags;
uint32_t memLower;
uint32_t memUpper;
uint32_t bootDevice;
char* cmdLine;
uint32_t modsCount;
multiboot_module_t* modsAddr;
union
{
multiboot_aoutSymbolTable_t aoutSym;
multiboot_elfSectionHeaderTable_t elfSec;
} u;
uint32_t mmapLength;
uint32_t mmapAddr;
uint32_t drivesLength;
uint32_t drivesAddr;
// ROM configuration table
uint32_t configTable;
char* bootLoaderName;
uint32_t apmTable;
// Video
uint32_t vbeControlInfo;
uint32_t vbeModeInfo;
uint16_t vbeMode;
uint16_t vbeInterfaceSeg;
uint16_t vbeInterfaceOff;
uint16_t vbeInterfaceLen;
} __attribute__((packed)) multiboot_info_t;
multiboot_info_t* multiboot_info;
void arch_multiboot_printInfo();

89
samples/C/ntru_encrypt.h Normal file
View File

@@ -0,0 +1,89 @@
/*
* Copyright (C) 2014 FH Bielefeld
*
* This file is part of a FH Bielefeld project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* @file ntru_encrypt.h
* Header for the internal API of ntru_encrypt.c.
* @brief header for encrypt.c
*/
#ifndef PQC_ENCRYPT_H
#define PQC_ENCRYPT_H
#include "ntru_params.h"
#include "ntru_poly.h"
#include "ntru_string.h"
#include <fmpz_poly.h>
#include <fmpz.h>
/**
* encrypt the msg, using the math:
* e = (h r) + m (mod q)
*
* e = the encrypted poly
*
* h = the public key
*
* r = the random poly
*
* m = the message poly
*
* q = large mod
*
* @param msg_tern the message to encrypt, in ternary format
* @param pub_key the public key
* @param rnd the random poly (should have relatively small
* coefficients, but not restricted to {-1, 0, 1})
* @param out the output poly which is in the range {0, q-1}
* (not ternary!) [out]
* @param params ntru_params the ntru context
*/
void
ntru_encrypt_poly(
const fmpz_poly_t msg_tern,
const fmpz_poly_t pub_key,
const fmpz_poly_t rnd,
fmpz_poly_t out,
const ntru_params *params);
/**
* Encrypt a message in the form of a null-terminated char array and
* return a string.
*
* @param msg the message
* @param pub_key the public key
* @param rnd the random poly (should have relatively small
* coefficients, but not restricted to {-1, 0, 1})
* @param params ntru_params the ntru context
* @return the newly allocated encrypted string
*/
string *
ntru_encrypt_string(
const string *msg,
const fmpz_poly_t pub_key,
const fmpz_poly_t rnd,
const ntru_params *params);
#endif /* PQC_ENCRYPT_H */

43
samples/C/portio.h Normal file
View File

@@ -0,0 +1,43 @@
#pragma once
/* Copyright © 2011 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <lib/stdint.h>
// Legacy
#define outb(args...) portio_out8(args)
#define outw(args...) portio_out16(args)
#define outl(args...) portio_out32(args)
#define outq(args...) portio_out64(args)
#define inb(args...) portio_in8(args)
#define inw(args...) portio_in16(args)
#define inl(args...) portio_in32(args)
#define inq(args...) portio_in64(args)
void portio_out8(uint16_t port, uint8_t value);
void portio_out16(uint16_t port, uint16_t value);
void portio_out32(uint16_t port, uint32_t value);
void portio_out64(uint16_t port, uint64_t value);
uint8_t portio_in8(uint16_t port);
uint16_t portio_in16(uint16_t port);
uint32_t portio_in32(uint16_t port);
uint64_t portio_in64(uint16_t port);

69
samples/C/scheduler.h Normal file
View File

@@ -0,0 +1,69 @@
#pragma once
/* Copyright © 2011 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <hw/cpu.h>
#include <memory/vmem.h>
#define SCHEDULER_MAXNAME 256
#define SCHEDULER_TASK_PATH_MAX 256
// Single linked list
typedef struct task {
uint32_t pid;
char name[SCHEDULER_MAXNAME];
struct task *parent;
cpu_state_t* state;
struct task* next;
struct task* previous;
void* stack;
void* entry;
struct vmem_context *memory_context;
// Current task state
enum {
TASK_STATE_KILLED,
TASK_STATE_TERMINATED,
TASK_STATE_BLOCKING,
TASK_STATE_STOPPED,
TASK_STATE_RUNNING
} task_state;
char** environ;
char** argv;
int argc;
// TODO Is this actually the same as PATH_MAX in our toolchain?
char cwd[SCHEDULER_TASK_PATH_MAX + 1];
} task_t;
int scheduler_state;
task_t* scheduler_new(void* entry, task_t* parent, char name[SCHEDULER_MAXNAME],
char** environ, char** argv, int argc, struct vmem_context* memory_context, bool map_structs);
void scheduler_add(task_t *task);
void scheduler_terminate_current();
task_t* scheduler_get_current();
task_t* scheduler_select(cpu_state_t* lastRegs);
void scheduler_init();
void scheduler_yield();
void scheduler_remove(task_t *t);
task_t* scheduler_fork(task_t* to_fork, cpu_state_t* state);

95
samples/C/syscalls.h Normal file
View File

@@ -0,0 +1,95 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#include <tasks/syscall.h>
#include "syscalls/write.h"
#include "syscalls/exit.h"
#include "syscalls/getpid.h"
#include "syscalls/getppid.h"
#include "syscalls/read.h"
#include "syscalls/brk.h"
#include "syscalls/mmap.h"
#include "syscalls/munmap.h"
#include "syscalls/test.h"
#include "syscalls/hostname.h"
#include "syscalls/uname.h"
#include "syscalls/open.h"
#include "syscalls/execve.h"
#include "syscalls/seek.h"
#include "syscalls/opendir.h"
#include "syscalls/readdir.h"
#include "syscalls/kill.h"
#include "syscalls/getexecdata.h"
#include "syscalls/cwd.h"
#include "syscalls/fork.h"
syscall_t syscall_table[] = {
NULL,
sys_exit, // 1
sys_read, // 2
sys_write, // 3
sys_getpid, // 4
sys_brk, // 5
sys_getppid, // 6
sys_mmap, // 7
sys_munmap, // 8
sys_test, // 9
sys_get_hostname, // 10
sys_set_hostname, // 11
sys_uname, // 12
sys_open, // 13
sys_execve, // 14
sys_seek, // 15
sys_opendir, // 16
sys_readdir, // 17
sys_kill, // 18
sys_getexecdata, // 19
sys_chdir, // 20
sys_getcwd, // 21
sys_fork, // 22
};
char* syscall_name_table[] = {
NULL,
"exit", // 1
"read", // 2
"write", // 3
"getpid", // 4
"brk", // 5
"getppid", // 6
"mmap", // 7
"munmap", // 8
"test", // 9
"get_hostname", // 10
"set_hostname", // 11
"uname", // 12
"open", // 13
"execve", // 14
"seek", // 15
"opendir", // 16
"readdir", // 17
"kill", // 18
"getexecdata", // 19
"chdir", // 20
"getcwd", // 21
"fork", // 22
};

56
samples/C/vfs.h Normal file
View File

@@ -0,0 +1,56 @@
#pragma once
/* Copyright © 2010, 2011 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
#define VFS_SEEK_SET 0
#define VFS_SEEK_CUR 1
#define VFS_SEEK_END 2
typedef struct {
uint64_t num;
char path[512];
char mount_path[512];
uint32_t offset;
uint32_t mountpoint;
} vfs_file_t;
typedef struct {
uint64_t num;
char path[512];
char mount_path[512];
uint32_t mountpoint;
} vfs_dir_t;
typedef void* (*vfs_read_callback_t)(char* path, uint32_t offset, uint32_t size);
typedef char* (*vfs_read_dir_callback_t)(char* path, uint32_t offset);
// Used to always store the last read/write attempt (used for kernel panic debugging)
char vfs_last_read_attempt[512];
vfs_file_t* vfs_get_from_id(uint32_t id);
vfs_dir_t* vfs_get_dir_from_id(uint32_t id);
void* vfs_read(vfs_file_t* fp, uint32_t size);
char* vfs_dir_read(vfs_dir_t* dir, uint32_t offset);
void vfs_seek(vfs_file_t* fp, uint32_t offset, int origin);
vfs_file_t* vfs_open(char* path);
vfs_dir_t* vfs_dir_open(char* path);
int vfs_mount(char* path, vfs_read_callback_t read_callback, vfs_read_dir_callback_t read_dir_callback);

94
samples/C/vmem.h Normal file
View File

@@ -0,0 +1,94 @@
#pragma once
/* Copyright © 2011 Fritz Grimpen
* Copyright © 2013 Lukas Martini
*
* This file is part of Xelix.
*
* Xelix is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xelix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xelix. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lib/generic.h>
struct vmem_context;
struct vmem_page
{
enum
{
VMEM_SECTION_STACK, /* Initial stack */
VMEM_SECTION_CODE, /* Contains program code and is read-only */
VMEM_SECTION_DATA, /* Contains static data */
VMEM_SECTION_HEAP, /* Allocated by brk(2) at runtime */
VMEM_SECTION_MMAP, /* Allocated by mmap(2) at runtime */
VMEM_SECTION_KERNEL, /* Contains kernel-internal data */
VMEM_SECTION_UNMAPPED /* Unmapped */
} section;
bool readonly:1;
bool cow:1; /* Copy-on-Write mechanism */
bool allocated:1;
void *cow_src_addr;
void *virt_addr;
void *phys_addr;
};
typedef void (*vmem_iterator_t)(struct vmem_context *, struct vmem_page *, uint32_t);
/* Initialize vmem_kernelContext for paging_init() */
void vmem_init();
struct vmem_context *vmem_kernelContext;
struct vmem_context *vmem_currentContext;
struct vmem_context *vmem_processContext;
void *vmem_faultAddress;
/* Some callbacks for magic functions */
void (*vmem_applyPage)(struct vmem_context *, struct vmem_page *);
/* Generate new page context */
struct vmem_context *vmem_new();
struct vmem_page *vmem_new_page();
int vmem_add_page(struct vmem_context *ctx, struct vmem_page *pg);
struct vmem_page *vmem_get_page_phys(struct vmem_context *ctx, void *phys_addr);
struct vmem_page *vmem_get_page_virt(struct vmem_context *ctx, void *virt_addr);
struct vmem_page *vmem_get_page(struct vmem_context *ctx, uint32_t offset);
/* Remove pages in a specific context by physical or virtual address */
struct vmem_page *vmem_rm_page_phys(struct vmem_context *ctx, void *phys_addr);
struct vmem_page *vmem_rm_page_virt(struct vmem_context *ctx, void *virt_addr);
/* Iterator */
int vmem_iterate(struct vmem_context *ctx, vmem_iterator_t callback);
uint32_t vmem_count_pages(struct vmem_context *ctx);
void vmem_dump_page(struct vmem_page *pg);
void vmem_dump(struct vmem_context *ctx);
void vmem_handle_fault(uint32_t code, void *addr, void *instruction);
/* Get/Set cached paging context */
void vmem_set_cache(struct vmem_context *ctx, void *cache);
void *vmem_get_cache(struct vmem_context *ctx);
#ifdef __i386__
#define PAGE_SIZE 4096
#define VMEM_ALIGN(x) (typeof(x))(((intptr_t)(x) & 0xFFFFF000) + 0x1000)
#define VMEM_ALIGN_DOWN(x) (typeof(x))( \
((intptr_t)(x) - ((intptr_t)(x) % PAGE_SIZE)))
#else
#define PAGE_SIZE 0
#define VMEM_ALIGN(x) (x)
#endif

343
samples/CLIPS/demo.clp Normal file
View File

@@ -0,0 +1,343 @@
;;;***************************
;;;* DEFFACTS KNOWLEDGE BASE *
;;;***************************
(deffacts MAIN::knowledge-base
(welcome (message WelcomeMessage))
(goal (variable type.animal))
(legalanswers (values yes no))
(displayanswers (values "Yes" "No"))
(rule (if backbone is yes)
(then superphylum is backbone))
(rule (if backbone is no)
(then superphylum is jellyback))
(question (variable backbone)
(query backbone.query))
(rule (if superphylum is backbone and
warm.blooded is yes)
(then phylum is warm))
(rule (if superphylum is backbone and
warm.blooded is no)
(then phylum is cold))
(question (variable warm.blooded)
(query warm.blooded.query))
(rule (if superphylum is jellyback and
live.prime.in.soil is yes)
(then phylum is soil))
(rule (if superphylum is jellyback and
live.prime.in.soil is no)
(then phylum is elsewhere))
(question (variable live.prime.in.soil)
(query live.prime.in.soil.query))
(rule (if phylum is warm and
has.breasts is yes)
(then class is breasts))
(rule (if phylum is warm and
has.breasts is no)
(then type.animal is bird))
(question (variable has.breasts)
(query has.breasts.query))
(rule (if phylum is cold and
always.in.water is yes)
(then class is water))
(rule (if phylum is cold and
always.in.water is no)
(then class is dry))
(question (variable always.in.water)
(query always.in.water.query))
(rule (if phylum is soil and
flat.bodied is yes)
(then type.animal is flatworm))
(rule (if phylum is soil and
flat.bodied is no)
(then type.animal is worm.leech))
(question (variable flat.bodied)
(query flat.bodied.query))
(rule (if phylum is elsewhere and
body.in.segments is yes)
(then class is segments))
(rule (if phylum is elsewhere and
body.in.segments is no)
(then class is unified))
(question (variable body.in.segments)
(query body.in.segments.query))
(rule (if class is breasts and
can.eat.meat is yes)
(then order is meat))
(rule (if class is breasts and
can.eat.meat is no)
(then order is vegy))
(question (variable can.eat.meat)
(query can.eat.meat.query))
(rule (if class is water and
boney is yes)
(then type.animal is fish))
(rule (if class is water and
boney is no)
(then type.animal is shark.ray))
(question (variable boney)
(query boney.query))
(rule (if class is dry and
scaly is yes)
(then order is scales))
(rule (if class is dry and
scaly is no)
(then order is soft))
(question (variable scaly)
(query scaly.query))
(rule (if class is segments and
shell is yes)
(then order is shell))
(rule (if class is segments and
shell is no)
(then type.animal is centipede.millipede.insect))
(question (variable shell)
(query shell.query))
(rule (if class is unified and
digest.cells is yes)
(then order is cells))
(rule (if class is unified and
digest.cells is no)
(then order is stomach))
(question (variable digest.cells)
(query digest.cells.query))
(rule (if order is meat and
fly is yes)
(then type.animal is bat))
(rule (if order is meat and
fly is no)
(then family is nowings))
(question (variable fly)
(query fly.query))
(rule (if order is vegy and
hooves is yes)
(then family is hooves))
(rule (if order is vegy and
hooves is no)
(then family is feet))
(question (variable hooves)
(query hooves.query))
(rule (if order is scales and
rounded.shell is yes)
(then type.animal is turtle))
(rule (if order is scales and
rounded.shell is no)
(then family is noshell))
(question (variable rounded.shell)
(query rounded.shell.query))
(rule (if order is soft and
jump is yes)
(then type.animal is frog))
(rule (if order is soft and
jump is no)
(then type.animal is salamander))
(question (variable jump)
(query jump.query))
(rule (if order is shell and
tail is yes)
(then type.animal is lobster))
(rule (if order is shell and
tail is no)
(then type.animal is crab))
(question (variable tail)
(query tail.query))
(rule (if order is cells and
stationary is yes)
(then family is stationary))
(rule (if order is cells and
stationary is no)
(then type.animal is jellyfish))
(question (variable stationary)
(query stationary.query))
(rule (if order is stomach and
multicelled is yes)
(then family is multicelled))
(rule (if order is stomach and
multicelled is no)
(then type.animal is protozoa))
(question (variable multicelled)
(query multicelled.query))
(rule (if family is nowings and
opposing.thumb is yes)
(then genus is thumb))
(rule (if family is nowings and
opposing.thumb is no)
(then genus is nothumb))
(question (variable opposing.thumb)
(query opposing.thumb.query))
(rule (if family is hooves and
two.toes is yes)
(then genus is twotoes))
(rule (if family is hooves and
two.toes is no)
(then genus is onetoe))
(question (variable two.toes)
(query two.toes.query))
(rule (if family is feet and
live.in.water is yes)
(then genus is water))
(rule (if family is feet and
live.in.water is no)
(then genus is dry))
(question (variable live.in.water)
(query live.in.water.query))
(rule (if family is noshell and
limbs is yes)
(then type.animal is crocodile.alligator))
(rule (if family is noshell and
limbs is no)
(then type.animal is snake))
(question (variable limbs)
(query limbs.query))
(rule (if family is stationary and
spikes is yes)
(then type.animal is sea.anemone))
(rule (if family is stationary and
spikes is no)
(then type.animal is coral.sponge))
(question (variable spikes)
(query spikes.query))
(rule (if family is multicelled and
spiral.shell is yes)
(then type.animal is snail))
(rule (if family is multicelled and
spiral.shell is no)
(then genus is noshell))
(question (variable spiral.shell)
(query spiral.shell.query))
(rule (if genus is thumb and
prehensile.tail is yes)
(then type.animal is monkey))
(rule (if genus is thumb and
prehensile.tail is no)
(then species is notail))
(question (variable prehensile.tail)
(query prehensile.tail.query))
(rule (if genus is nothumb and
over.400 is yes)
(then species is 400))
(rule (if genus is nothumb and
over.400 is no)
(then species is under400))
(question (variable over.400)
(query over.400.query))
(rule (if genus is twotoes and
horns is yes)
(then species is horns))
(rule (if genus is twotoes and
horns is no)
(then species is nohorns))
(question (variable horns)
(query horns.query))
(rule (if genus is onetoe and
plating is yes)
(then type.animal is rhinoceros))
(rule (if genus is onetoe and
plating is no)
(then type.animal is horse.zebra))
(question (variable plating)
(query plating.query))
(rule (if genus is water and
hunted is yes)
(then type.animal is whale))
(rule (if genus is water and
hunted is no)
(then type.animal is dolphin.porpoise))
(question (variable hunted)
(query hunted.query))
(rule (if genus is dry and
front.teeth is yes)
(then species is teeth))
(rule (if genus is dry and
front.teeth is no)
(then species is noteeth))
(question (variable front.teeth)
(query front.teeth.query))
(rule (if genus is noshell and
bivalve is yes)
(then type.animal is clam.oyster))
(rule (if genus is noshell and
bivalve is no)
(then type.animal is squid.octopus))
(question (variable bivalve)
(query bivalve.query))
(rule (if species is notail and
nearly.hairless is yes)
(then type.animal is man))
(rule (if species is notail and
nearly.hairless is no)
(then subspecies is hair))
(question (variable nearly.hairless)
(query nearly.hairless.query))
(rule (if species is 400 and
land.based is yes)
(then type.animal is bear.tiger.lion))
(rule (if species is 400 and
land.based is no)
(then type.animal is walrus))
(question (variable land.based)
(query land.based.query))
(rule (if species is under400 and
thintail is yes)
(then type.animal is cat))
(rule (if species is under400 and
thintail is no)
(then type.animal is coyote.wolf.fox.dog))
(question (variable thintail)
(query thintail.query))
(rule (if species is nohorns and
lives.in.desert is yes)
(then type.animal is camel))
(rule (if species is nohorns and
lives.in.desert is no and
semi.aquatic is no)
(then type.animal is giraffe))
(rule (if species is nohorns and
lives.in.desert is no and
semi.aquatic is yes)
(then type.animal is hippopotamus))
(question (variable lives.in.desert)
(query lives.in.desert.query))
(question (variable semi.aquatic)
(query semi.aquatic.query))
(rule (if species is teeth and
large.ears is yes)
(then type.animal is rabbit))
(rule (if species is teeth and
large.ears is no)
(then type.animal is rat.mouse.squirrel.beaver.porcupine))
(question (variable large.ears)
(query large.ears.query))
(rule (if species is noteeth and
pouch is yes)
(then type.animal is kangaroo.koala.bear))
(rule (if species is noteeth and
pouch is no)
(then type.animal is mole.shrew.elephant))
(question (variable pouch)
(query pouch.query))
(rule (if subspecies is hair and
long.powerful.arms is yes)
(then type.animal is orangutan.gorilla.chimpanzee))
(rule (if subspecies is hair and
long.powerful.arms is no)
(then type.animal is baboon))
(question (variable long.powerful.arms)
(query long.powerful.arms.query))
(rule (if species is horns and
fleece is yes)
(then type.animal is sheep.goat))
(rule (if species is horns and
fleece is no)
(then subsubspecies is nofleece))
(question (variable fleece)
(query fleece.query))
(rule (if subsubspecies is nofleece and
domesticated is yes)
(then type.animal is cow))
(rule (if subsubspecies is nofleece and
domesticated is no)
(then type.animal is deer.moose.antelope))
(question (variable domesticated)
(query domesticated.query))
(answer (prefix "I think your animal is a ") (variable type.animal) (postfix ".")))

281
samples/CLIPS/sudoku.clp Normal file
View File

@@ -0,0 +1,281 @@
;;; http://www.angusj.com/sudoku/hints
;;; http://www.scanraid.com/BasicStrategies.htm
;;; http://www.sudokuoftheday.com/pages/techniques-overview
;;; http://www.sudokuonline.us/sudoku_solving_techniques
;;; http://www.sadmansoftware.com/sudoku/techniques.htm
;;; http://www.krazydad.com/blog/2005/09/29/an-index-of-sudoku-strategies/
;;; #######################
;;; DEFTEMPLATES & DEFFACTS
;;; #######################
(deftemplate possible
(slot row)
(slot column)
(slot value)
(slot group)
(slot id))
(deftemplate impossible
(slot id)
(slot value)
(slot priority)
(slot reason))
(deftemplate technique-employed
(slot reason)
(slot priority))
(deftemplate technique
(slot name)
(slot priority))
(deffacts startup
(phase grid-values))
(deftemplate size-value
(slot size)
(slot value))
(deffacts values
(size-value (size 1) (value 1))
(size-value (size 2) (value 2))
(size-value (size 2) (value 3))
(size-value (size 2) (value 4))
(size-value (size 3) (value 5))
(size-value (size 3) (value 6))
(size-value (size 3) (value 7))
(size-value (size 3) (value 8))
(size-value (size 3) (value 9))
(size-value (size 4) (value 10))
(size-value (size 4) (value 11))
(size-value (size 4) (value 12))
(size-value (size 4) (value 13))
(size-value (size 4) (value 14))
(size-value (size 4) (value 15))
(size-value (size 4) (value 16))
(size-value (size 5) (value 17))
(size-value (size 5) (value 18))
(size-value (size 5) (value 19))
(size-value (size 5) (value 20))
(size-value (size 5) (value 21))
(size-value (size 5) (value 22))
(size-value (size 5) (value 23))
(size-value (size 5) (value 24))
(size-value (size 5) (value 25)))
;;; ###########
;;; SETUP RULES
;;; ###########
;;; ***********
;;; stress-test
;;; ***********
(defrule stress-test
(declare (salience 10))
(phase match)
(stress-test)
(priority ?last)
(not (priority ?p&:(> ?p ?last)))
(technique (priority ?next&:(> ?next ?last)))
(not (technique (priority ?p&:(> ?p ?last)&:(< ?p ?next))))
=>
(assert (priority ?next)))
;;; *****************
;;; enable-techniques
;;; *****************
(defrule enable-techniques
(declare (salience 10))
(phase match)
(size ?)
(not (possible (value any)))
=>
(assert (priority 1)))
;;; **********
;;; expand-any
;;; **********
(defrule expand-any
(declare (salience 10))
(phase expand-any)
?f <- (possible (row ?r) (column ?c) (value any) (group ?g) (id ?id))
(not (possible (value any) (id ?id2&:(< ?id2 ?id))))
(size ?s)
(size-value (size ?as&:(<= ?as ?s)) (value ?v))
(not (possible (row ?r) (column ?c) (value ?v)))
(not (and (size-value (value ?v2&:(< ?v2 ?v)))
(not (possible (row ?r) (column ?c) (value ?v2)))))
=>
(assert (possible (row ?r) (column ?c) (value ?v) (group ?g) (id ?id))))
;;; *****************
;;; position-expanded
;;; *****************
(defrule position-expanded
(declare (salience 10))
(phase expand-any)
?f <- (possible (row ?r) (column ?c) (value any) (group ?g) (id ?id))
(size ?s)
(not (and (size-value (size ?as&:(<= ?as ?s)) (value ?v))
(not (possible (row ?r) (column ?c) (value ?v)))))
=>
(retract ?f))
;;; ###########
;;; PHASE RULES
;;; ###########
;;; ***************
;;; expand-any-done
;;; ***************
(defrule expand-any-done
(declare (salience 10))
?f <- (phase expand-any)
(not (possible (value any)))
=>
(retract ?f)
(assert (phase initial-output))
(assert (print-position 1 1)))
;;; ***********
;;; begin-match
;;; ***********
(defrule begin-match
(declare (salience -20))
?f <- (phase initial-output)
=>
(retract ?f)
(assert (phase match)))
;;; *****************
;;; begin-elimination
;;; *****************
(defrule begin-elimination
(declare (salience -20))
?f <- (phase match)
(not (not (impossible)))
=>
(retract ?f)
(assert (phase elimination)))
;;; *************
;;; next-priority
;;; *************
(defrule next-priority
(declare (salience -20))
(phase match)
(not (impossible))
(priority ?last)
(not (priority ?p&:(> ?p ?last)))
(technique (priority ?next&:(> ?next ?last)))
(not (technique (priority ?p&:(> ?p ?last)&:(< ?p ?next))))
=>
(assert (priority ?next)))
;;; ************
;;; begin-output
;;; ************
(defrule begin-output
(declare (salience -20))
?f <- (phase match)
(not (impossible))
(priority ?last)
(not (priority ?p&:(> ?p ?last)))
(not (technique (priority ?next&:(> ?next ?last))))
=>
(retract ?f)
(assert (phase final-output))
(assert (print-position 1 1)))

View File

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 2.8)
project(Foo)
set(CMAKE_SKIP_RPATH TRUE)
set(CMAKE_INSTALL_PREFIX "/usr/local")
add_subdirectory(bar)
add_executable(foo foo.c)
target_link_libraries(foo pthread)
install(TARGETS foo DESTINATION bin)

View File

@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.6)
enable_testing()
set(CMAKE_BUILD_TYPE debug)
include_directories("/usr/local/include")
find_library(ssl_LIBRARY NAMES ssl PATHS "/usr/local/lib")
add_custom_command(OUTPUT "ver.c" "ver.h" COMMAND ./ver.sh)
add_executable(foo foo.c bar.c baz.c ver.c)
target_link_libraries(foo ${ssl_LIBRARY})

View File

@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(PCLVisualizer)
target_link_libraries (PCLVisualizer ${PCL_LIBRARIES})
#it seems it's needed only on OS X 10.9
find_package(GLEW REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/include -v")
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(PCL_BUILD_TYPE Release)
file(GLOB PCL_openni_viewer_SRC
"src/*.h"
"src/*.cpp"
)
add_executable(PCLVisualizer ${PCL_openni_viewer_SRC})
#add this line to solve probem in mac os x 10.9
target_link_libraries(PCLVisualizer ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_VISUALIZATION_LIBRARIES} ${PCL_FEATURES_LIBRARIES})

View File

@@ -0,0 +1,33 @@
# Specifications for building user and development documentation.
#
# ====================================================================
# Copyright (c) 2009 Ian Blumel. All rights reserved.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
# ====================================================================
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_FILE( SPHINX sphinx-build.exe)
# If we are windows call to the make.bat file, otherwise rely on the Makefile
# to handle the processing.
IF(WIN32)
SET(SPHINX_MAKE make.bat)
ELSE(WIN32)
SET(SPHINX_MAKE make)
ENDIF(WIN32)
ADD_CUSTOM_TARGET(
doc_usr
COMMAND ${SPHINX_MAKE} html
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/usr
)
ADD_CUSTOM_TARGET(
doc_dev
COMMAND ${SPHINX_MAKE} html
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dev
)

View File

@@ -0,0 +1,33 @@
cmake_minimum_required (VERSION 2.6)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala)
find_package(Vala REQUIRED)
include(ValaPrecompile)
include(ValaVersion)
ensure_vala_version("0.11.0" MINIMUM)
project (template C)
find_package(PkgConfig)
pkg_check_modules(GOBJECT REQUIRED gobject-2.0)
add_definitions(${GOBJECT_CFLAGS} ${GOBJECT_CFLAGS_OTHER})
link_libraries(${GOBJECT_LIBRARIES})
link_directories(${GOBJECT_LIBRARY_DIRS})
vala_precompile(VALA_C
src/template.vala
PACKAGES
OPTIONS
--thread
CUSTOM_VAPIS
GENERATE_VAPI
GENERATE_HEADER
DIRECTORY
gen
)
add_executable("template" ${VALA_C})

View File

@@ -0,0 +1,89 @@
# - Check if the STDCALL function exists.
# This works for non-cdecl functions (kernel32 functions, for example)
# CHECK_STDCALL_FUNCTION_EXISTS(FUNCTION FUNCTION_DUMMY_ARGS VARIABLE)
# - macro which checks if the stdcall function exists
# FUNCTION_DECLARATION - the definition of the function ( e.g.: Sleep(500) )
# VARIABLE - variable to store the result
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
# CMAKE_EXTRA_INCLUDE_FILES = list of extra includes to check in
MACRO(CHECK_STDCALL_FUNCTION_EXISTS FUNCTION_DECLARATION VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
#get includes
SET(CHECK_STDCALL_FUNCTION_PREMAIN)
FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES})
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"${def}\"\n")
ENDFOREACH(def)
#add some default includes
IF ( HAVE_WINDOWS_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"windows.h\"\n")
ENDIF ( HAVE_WINDOWS_H )
IF ( HAVE_UNISTD_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"unistd.h\"\n")
ENDIF ( HAVE_UNISTD_H )
IF ( HAVE_DIRECT_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"direct.h\"\n")
ENDIF ( HAVE_DIRECT_H )
IF ( HAVE_IO_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"io.h\"\n")
ENDIF ( HAVE_IO_H )
IF ( HAVE_SYS_TIMEB_H )
SET(CHECK_STDCALL_FUNCTION_PREMAIN "${CHECK_STDCALL_FUNCTION_PREMAIN}#include \"sys/timeb.h\"\n")
ENDIF ( HAVE_SYS_TIMEB_H )
STRING(REGEX REPLACE "(\\(.*\\))" "" CHECK_STDCALL_FUNCTION_EXISTS_FUNCTION ${FUNCTION_DECLARATION} )
SET(MACRO_CHECK_STDCALL_FUNCTION_DEFINITIONS "${CMAKE_REQUIRED_FLAGS}")
MESSAGE(STATUS "Looking for ${CHECK_STDCALL_FUNCTION_EXISTS_FUNCTION}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ELSE(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_LIBRARIES)
ENDIF(CMAKE_REQUIRED_LIBRARIES)
IF(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
ELSE(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_STDCALL_FUNCTION_EXISTS_ADD_INCLUDES)
ENDIF(CMAKE_REQUIRED_INCLUDES)
SET(CHECK_STDCALL_FUNCTION_DECLARATION ${FUNCTION_DECLARATION})
CONFIGURE_FILE("${clucene-shared_SOURCE_DIR}/cmake/CheckStdCallFunctionExists.cpp.in"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckStdCallFunctionExists.cpp" IMMEDIATE @ONLY)
FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckStdCallFunctionExists.cpp"
CHECK_STDCALL_FUNCTION_CONTENT)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckStdCallFunctionExists.cpp"
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_STDCALL_FUNCTION_DEFINITIONS}
"${CHECK_STDCALL_FUNCTION_EXISTS_ADD_LIBRARIES}"
"${CHECK_STDCALL_FUNCTION_EXISTS_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION_DECLARATION}")
MESSAGE(STATUS "Looking for ${FUNCTION_DECLARATION} - found")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the stdcall function ${FUNCTION_DECLARATION} exists passed with the following output:\n"
"${OUTPUT}\nCheckStdCallFunctionExists.cpp:\n${CHECK_STDCALL_FUNCTION_CONTENT}\n\n")
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for ${FUNCTION_DECLARATION} - not found")
SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION_DECLARATION}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the stdcall function ${FUNCTION_DECLARATION} exists failed with the following output:\n"
"${OUTPUT}\nCheckStdCallFunctionExists.cpp:\n${CHECK_STDCALL_FUNCTION_CONTENT}\n\n")
ENDIF(${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_STDCALL_FUNCTION_EXISTS)

View File

@@ -0,0 +1,22 @@
IF (NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
MESSAGE (FATAL_ERROR "Cannot find install manifest: \"@PROJECT_BINARY_DIR@/install_manifest.txt\"")
ENDIF (NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
FILE (READ "@PROJECT_BINARY_DIR@/install_manifest.txt" files)
STRING (REGEX REPLACE "\n" ";" files "${files}")
FOREACH (file ${files})
MESSAGE (STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF (EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM (
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF (NOT "${rm_retval}" STREQUAL 0)
MESSAGE (FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF (NOT "${rm_retval}" STREQUAL 0)
ELSE (EXISTS "$ENV{DESTDIR}${file}")
MESSAGE (STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF (EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH (file)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
###* @cjsx React.DOM ###
define 'myProject.ReactExampleComponent', [
'React'
'myProject.ExampleStore'
'myProject.ExampleActions'
'myProject.ReactExampleTable'
], (React, ExampleStore, ExampleActions, ReactExampleTable ) ->
ReactExampleComponent = React.createClass
mixins: [ListenMixin]
getInitialState: ->
rows: ExampleStore.getRows()
meta: ExampleStore.getMeta()
componentWillMount: ->
@listenTo ExampleStore
componentDidMount: ->
ExampleActions.getExampleData()
onStoreChange: ->
if this.isMounted()
@setState
rows: ExampleStore.getRows()
meta: ExampleStore.getMeta()
componentWillUnmount: ->
@stopListening ExampleStore
render: ->
<div className="page-wrap">
<header>
<strong> {@state.title} </strong>
<header>
<ReactExampleTable
rows={@state.rows},
meta={@state.meta}
/>
</div>

View File

@@ -0,0 +1,21 @@
;;;; -*- lisp -*-
(in-package :foo)
;;; Header comment.
(defvar *foo*)
(eval-when (:execute :compile-toplevel :load-toplevel)
(defun add (x &optional y &key z)
(declare (ignore z))
;; Inline comment.
(+ x (or y 1))))
#|
Multi-line comment.
|#
(defmacro foo (x &body b)
(if x
`(1+ ,x) ;After-line comment.
42))

26
samples/Cool/list.cl Normal file
View File

@@ -0,0 +1,26 @@
(* This simple example of a list class is adapted from an example in the
Cool distribution. *)
class List {
isNil() : Bool { true };
head() : Int { { abort(); 0; } };
tail() : List { { abort(); self; } };
cons(i : Int) : List {
(new Cons).init(i, self)
};
};
class Cons inherits List {
car : Int; -- The element in this list cell
cdr : List; -- The rest of the list
isNil() : Bool { false };
head() : Int { car };
tail() : List { cdr };
init(i : Int, rest : List) : List {
{
car <- i;
cdr <- rest;
self;
}
};
};

71
samples/Cool/sample.cl Normal file
View File

@@ -0,0 +1,71 @@
(* Refer to Alex Aiken, "The Cool Reference Manual":
http://theory.stanford.edu/~aiken/software/cool/cool-manual.pdf
for language specification.
*)
-- Exhibit various language constructs
class Sample {
testCondition(x: Int): Bool {
if x = 0
then false
else
if x < (1 + 2) * 3
then true
else false
fi
fi
};
testLoop(y: Int): Bool {
while y > 0 loop
{
if not condition(y)
then y <- y / 2
else y <- y - 1;
}
pool
};
testAssign(z: Int): Bool {
i : Int;
i <- ~z;
};
testCase(var: Sample): SELF_TYPE {
io : IO <- new IO;
case var of
a : A => io.out_string("Class type is A\n");
b : B => io.out_string("Class type is B\n");
s : Sample => io.out_string("Class type is Sample\n");
o : Object => io.out_string("Class type is object\n");
esac
};
testLet(i: Int): Int {
let (a: Int in
let(b: Int <- 3, c: Int <- 4 in
{
a <- 2;
a * b * 2 / c;
}
)
)
};
};
-- Used to test subclasses
class A inherits Sample {};
class B inherits A {};
class C {
main() : Int {
(new Sample).testLet(1)
};
};
-- "Hello, world" example
class Main inherits IO {
main(): SELF_TYPE {
out_string("Hello, World.\n")
};
};

View File

@@ -0,0 +1,29 @@
;; -*- mode: emacs-lisp; coding: emacs-mule; -*-
;; --------------------------------------------------------------------------
;; Desktop File for Emacs
;; --------------------------------------------------------------------------
;; Created Sat Jan 3 12:46:35 2015
;; Desktop file format version 206
;; Emacs version 24.3.1
;; Global section:
(setq desktop-missing-file-warning nil)
(setq tags-file-name nil)
(setq tags-table-list nil)
(setq search-ring nil)
(setq regexp-search-ring nil)
(setq register-alist nil)
(setq file-name-history nil)
;; Buffer section -- buffers listed in same order as in buffer list:
(desktop-create-buffer 206
"/home/foo/bar"
"bar"
'fundamental-mode
nil
11572
'(11554 nil)
nil
nil
'((buffer-file-coding-system . undecided-unix)))

49
samples/F#/Combinators.fs Normal file
View File

@@ -0,0 +1,49 @@
namespace Nessos.FsPickler.Combinators
open Nessos.FsPickler
open Nessos.FsPickler.Json
/// Json pickling methods
[<RequireQualifiedAccess>]
module Json =
let private jsonSerializer = lazy(FsPickler.CreateJson(omitHeader = true))
/// <summary>
/// Pickles a value to Json.
/// </summary>
/// <param name="pickler">utilized pickler.</param>
/// <param name="value">input value.</param>
let pickle (pickler : Pickler<'T>) (value : 'T) : string =
jsonSerializer.Value.PickleToString (pickler, value)
/// <summary>
/// Unpickles a value from Json.
/// </summary>
/// <param name="pickler">utilized pickler.</param>
/// <param name="pickle">input pickle.</param>
let unpickle (pickler : Pickler<'T>) (pickle : string) : 'T =
jsonSerializer.Value.UnPickleOfString (pickler, pickle)
/// Bson pickling methods
[<RequireQualifiedAccess>]
module Bson =
let private bsonPickler = lazy(FsPickler.CreateBson())
/// <summary>
/// Pickles a value to Bson.
/// </summary>
/// <param name="pickler">utilized pickler.</param>
/// <param name="value">input value.</param>
let pickle (pickler : Pickler<'T>) (value : 'T) : byte [] =
bsonPickler.Value.Pickle (pickler, value)
/// <summary>
/// Unpickles a value from bson.
/// </summary>
/// <param name="pickler">utilized pickler.</param>
/// <param name="pickle">input pickle.</param>
let unpickle (pickler : Pickler<'T>) (pickle : byte []) : 'T =
bsonPickler.Value.UnPickle (pickler, pickle)

65
samples/F#/JsonFormat.fs Normal file
View File

@@ -0,0 +1,65 @@
namespace Nessos.FsPickler.Json
open System
open System.IO
open System.Text
open Newtonsoft.Json
open Nessos.FsPickler
/// <summary>
/// Factory methods for the Json serialization format.
/// </summary>
type JsonPickleFormatProvider internal (indent, omitHeader) as self =
let isCustomSeq isTopLevelSequence =
isTopLevelSequence && self.OmitHeader && self.UseCustomTopLevelSequenceSeparator
let mutable sequenceSeparator = " "
member val Indent = indent with get,set
member val OmitHeader = omitHeader with get,set
member val UseCustomTopLevelSequenceSeparator = false with get,set
member __.SequenceSeparator
with get () = sequenceSeparator
and set sep =
if sep <> null && String.IsNullOrWhiteSpace sep then
sequenceSeparator <- sep
else
invalidArg "SequenceSeparator" "should be non-null whitespace."
interface ITextPickleFormatProvider with
member __.Name = "Json"
// see discussion : https://github.com/nessos/FsPickler/issues/17
member __.DefaultEncoding = new UTF8Encoding(false) :> Encoding
member __.CreateWriter (stream, encoding, isTopLevelSequence, leaveOpen) =
#if NET40
if leaveOpen then raise <| new NotSupportedException("'leaveOpen' not supported in .NET 40.")
let sw = new StreamWriter(stream, encoding)
#else
let sw = new StreamWriter(stream, encoding, 1024, leaveOpen)
#endif
let jw = new JsonTextWriter(sw)
new JsonPickleWriter(jw, __.OmitHeader, __.Indent, isCustomSeq isTopLevelSequence, sequenceSeparator, leaveOpen) :> _
member __.CreateReader (stream, encoding, isTopLevelSequence, leaveOpen) =
#if NET40
if leaveOpen then raise <| new NotSupportedException("'leaveOpen' not supported in .NET 40.")
let sr = new StreamReader(stream, encoding)
#else
let sr = new StreamReader(stream, encoding, true, 1024, leaveOpen)
#endif
let jr = new JsonTextReader(sr)
new JsonPickleReader(jr, __.OmitHeader, isCustomSeq isTopLevelSequence, leaveOpen) :> _
member __.CreateWriter (textWriter, isTopLevelSequence, leaveOpen) =
let jw = new JsonTextWriter(textWriter)
new JsonPickleWriter(jw, __.OmitHeader, __.Indent, isCustomSeq isTopLevelSequence, sequenceSeparator, leaveOpen) :> _
member __.CreateReader (textReader, isTopLevelSequence, leaveOpen) =
let jr = new JsonTextReader(textReader)
new JsonPickleReader(jr, __.OmitHeader, isCustomSeq isTopLevelSequence, leaveOpen) :> _

202
samples/F#/JsonReader.fs Normal file
View File

@@ -0,0 +1,202 @@
namespace Nessos.FsPickler.Json
open System
open System.Collections.Generic
open System.Globalization
open System.IO
open System.Numerics
open System.Text
open Newtonsoft.Json
open Nessos.FsPickler
/// <summary>
/// Json format deserializer
/// </summary>
type internal JsonPickleReader (jsonReader : JsonReader, omitHeader, isTopLevelSequence, leaveOpen) =
do
jsonReader.CloseInput <- not leaveOpen
jsonReader.SupportMultipleContent <- isTopLevelSequence
let isBsonReader = match jsonReader with :? Bson.BsonReader -> true | _ -> false
let mutable depth = 0
let arrayStack = new Stack<int> ()
do arrayStack.Push Int32.MinValue
// do not write tag if omitting header or array element
let omitTag () = (omitHeader && depth = 0) || arrayStack.Peek() = depth - 1
interface IPickleFormatReader with
member __.BeginReadRoot (tag : string) =
do jsonReader.Read() |> ignore
if omitHeader then () else
if jsonReader.TokenType <> JsonToken.StartObject then raise <| new FormatException("invalid json root object.")
else
do jsonReader.MoveNext()
let version = jsonReader.ReadPrimitiveAs<string> false "FsPickler"
if version <> jsonFormatVersion then
let v = Version(version)
raise <| new FormatException(sprintf "Invalid FsPickler format version %O." version)
let sTag = jsonReader.ReadPrimitiveAs<string> false "type"
if tag <> sTag then
raise <| new InvalidPickleTypeException(tag, sTag)
member __.EndReadRoot () =
if not omitHeader then jsonReader.Read() |> ignore
member __.BeginReadObject (tag : string) =
if not <| omitTag () then
jsonReader.ReadProperty tag
jsonReader.MoveNext ()
if isTopLevelSequence && depth = 0 then
arrayStack.Push depth
depth <- depth + 1
ObjectFlags.IsSequenceHeader
else
match jsonReader.TokenType with
| JsonToken.Null -> ObjectFlags.IsNull
| JsonToken.StartArray ->
jsonReader.MoveNext()
arrayStack.Push depth
depth <- depth + 1
ObjectFlags.IsSequenceHeader
| JsonToken.StartObject ->
do jsonReader.MoveNext()
depth <- depth + 1
if jsonReader.ValueAs<string> () = "_flags" then
jsonReader.MoveNext()
let csvFlags = jsonReader.ValueAs<string>()
jsonReader.MoveNext()
parseFlagCsv csvFlags
else
ObjectFlags.None
| token -> raise <| new FormatException(sprintf "expected start of Json object but was '%O'." token)
member __.EndReadObject () =
if isTopLevelSequence && depth = 1 then
arrayStack.Pop () |> ignore
depth <- depth - 1
jsonReader.Read() |> ignore
else
match jsonReader.TokenType with
| JsonToken.Null -> ()
| JsonToken.EndObject -> depth <- depth - 1
| JsonToken.EndArray ->
arrayStack.Pop() |> ignore
depth <- depth - 1
| token -> raise <| new FormatException(sprintf "expected end of Json object but was '%O'." token)
if omitHeader && depth = 0 then ()
else jsonReader.Read() |> ignore
member __.SerializeUnionCaseNames = true
member __.PreferLengthPrefixInSequences = false
member __.ReadNextSequenceElement () =
if isTopLevelSequence && depth = 1 then
jsonReader.TokenType <> JsonToken.None
else
jsonReader.TokenType <> JsonToken.EndArray
member __.ReadCachedObjectId () = jsonReader.ReadPrimitiveAs<int64> false "id"
member __.ReadBoolean tag = jsonReader.ReadPrimitiveAs<bool> (omitTag ()) tag
member __.ReadByte tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> byte
member __.ReadSByte tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> sbyte
member __.ReadInt16 tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> int16
member __.ReadInt32 tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> int
member __.ReadInt64 tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag
member __.ReadUInt16 tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> uint16
member __.ReadUInt32 tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> uint32
member __.ReadUInt64 tag = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag |> uint64
member __.ReadSingle tag =
if not <| omitTag () then
jsonReader.ReadProperty tag
jsonReader.MoveNext()
let value =
match jsonReader.TokenType with
| JsonToken.Float -> jsonReader.ValueAs<double> () |> single
| JsonToken.String -> Single.Parse(jsonReader.ValueAs<string>(), CultureInfo.InvariantCulture)
| _ -> raise <| new FormatException("not a float.")
jsonReader.Read() |> ignore
value
member __.ReadDouble tag =
if not <| omitTag () then
jsonReader.ReadProperty tag
jsonReader.MoveNext()
let value =
match jsonReader.TokenType with
| JsonToken.Float -> jsonReader.ValueAs<double> ()
| JsonToken.String -> Double.Parse(jsonReader.ValueAs<string>(), CultureInfo.InvariantCulture)
| _ -> raise <| new FormatException("not a float.")
jsonReader.Read() |> ignore
value
member __.ReadChar tag = let value = jsonReader.ReadPrimitiveAs<string> (omitTag ()) tag in value.[0]
member __.ReadString tag = jsonReader.ReadPrimitiveAs<string> (omitTag ()) tag
member __.ReadBigInteger tag = jsonReader.ReadPrimitiveAs<string> (omitTag ()) tag |> BigInteger.Parse
member __.ReadGuid tag =
if isBsonReader then
jsonReader.ReadPrimitiveAs<Guid> (omitTag ()) tag
else
jsonReader.ReadPrimitiveAs<string> (omitTag ()) tag |> Guid.Parse
member __.ReadTimeSpan tag = jsonReader.ReadPrimitiveAs<string> (omitTag ()) tag |> TimeSpan.Parse
member __.ReadDecimal tag = jsonReader.ReadPrimitiveAs<string> (omitTag ()) tag |> decimal
// BSON spec mandates the use of Unix time;
// this has millisecond precision which results in loss of accuracy w.r.t. ticks
// since the goal of FsPickler is to offer faithful representations of .NET objects
// we choose to override the spec and serialize ticks outright.
// see also https://json.codeplex.com/discussions/212067
member __.ReadDate tag =
if isBsonReader then
let ticks = jsonReader.ReadPrimitiveAs<int64> (omitTag ()) tag
DateTime(ticks)
else
jsonReader.ReadPrimitiveAs<DateTime> (omitTag ()) tag
member __.ReadBytes tag =
if not <| omitTag () then
jsonReader.ReadProperty tag
jsonReader.Read() |> ignore
let bytes =
if jsonReader.TokenType = JsonToken.Null then null
elif isBsonReader then jsonReader.ValueAs<byte []> ()
else
let base64 = jsonReader.ValueAs<string> ()
Convert.FromBase64String base64
jsonReader.Read() |> ignore
bytes
member __.IsPrimitiveArraySerializationSupported = false
member __.ReadPrimitiveArray _ _ = raise <| new NotImplementedException()
member __.Dispose () = (jsonReader :> IDisposable).Dispose()

View File

@@ -0,0 +1,85 @@
namespace Nessos.FsPickler.Json
open System
open Nessos.FsPickler
type internal OAttribute = System.Runtime.InteropServices.OptionalAttribute
type internal DAttribute = System.Runtime.InteropServices.DefaultParameterValueAttribute
/// <summary>
/// Json pickler instance.
/// </summary>
type JsonSerializer =
inherit FsPicklerTextSerializer
val private format : JsonPickleFormatProvider
/// <summary>
/// Initializes a new Json pickler instance.
/// </summary>
/// <param name="indent">indent out Json pickles.</param>
/// <param name="omitHeader">omit FsPickler header in Json pickles.</param>
/// <param name="typeConverter">specify a custom type name converter.</param>
new ([<O;D(null)>] ?indent, [<O;D(null)>] ?omitHeader, [<O;D(null)>] ?typeConverter) =
let indent = defaultArg indent false
let omitHeader = defaultArg omitHeader false
let json = new JsonPickleFormatProvider(indent, omitHeader)
{
inherit FsPicklerTextSerializer(json, ?typeConverter = typeConverter)
format = json
}
/// <summary>
/// Gets or sets whether Json output should be indented.
/// </summary>
member x.Indent
with get () = x.format.Indent
and set b = x.format.Indent <- b
/// <summary>
/// Gets or sets whether FsPickler headers should be ignored in pickle format.
/// </summary>
member x.OmitHeader
with get () = x.format.OmitHeader
and set b = x.format.OmitHeader <- b
/// <summary>
/// Gets or sets a non-null whitespace string that serves as a custom, top-level sequence separator.
/// </summary>
member x.SequenceSeparator
with get () = x.format.SequenceSeparator
and set sep = x.format.SequenceSeparator <- sep
/// <summary>
/// Gets or sets whether top-level sequences should be serialized using the custom separator.
/// </summary>
member x.UseCustomTopLevelSequenceSeparator
with get () = x.format.UseCustomTopLevelSequenceSeparator
and set e = x.format.UseCustomTopLevelSequenceSeparator <- e
/// <summary>
/// BSON pickler instance.
/// </summary>
type BsonSerializer([<O;D(null)>] ?typeConverter) =
inherit FsPicklerSerializer(new BsonPickleFormatProvider(), ?typeConverter = typeConverter)
/// FsPickler static methods.
type FsPickler =
/// <summary>
/// Initializes a new Json pickler instance.
/// </summary>
/// <param name="indent">indent out Json pickles.</param>
/// <param name="omitHeader">omit FsPickler header in Json pickles.</param>
/// <param name="typeConverter">specify a custom type name converter.</param>
static member CreateJson([<O;D(null)>] ?indent, [<O;D(null)>] ?omitHeader, [<O;D(null)>] ?typeConverter) =
new JsonSerializer(?indent = indent, ?omitHeader = omitHeader, ?typeConverter = typeConverter)
/// <summary>
/// Initializes a new Bson pickler instance.
/// </summary>
/// <param name="typeConverter">specify a custom type name converter.</param>
static member CreateBson([<O;D(null)>] ?typeConverter) =
new BsonSerializer(?typeConverter = typeConverter)

142
samples/F#/JsonWriter.fs Normal file
View File

@@ -0,0 +1,142 @@
namespace Nessos.FsPickler.Json
open System
open System.IO
open System.Collections.Generic
open Newtonsoft.Json
open Nessos.FsPickler
/// <summary>
/// Json format serializer.
/// </summary>
type internal JsonPickleWriter (jsonWriter : JsonWriter, omitHeader, indented, isTopLevelSequence, separator, leaveOpen) =
do
jsonWriter.Formatting <- if indented then Formatting.Indented else Formatting.None
jsonWriter.CloseOutput <- not leaveOpen
let isBsonWriter = match jsonWriter with :? Bson.BsonWriter -> true | _ -> false
let mutable depth = 0
let mutable isTopLevelSequenceHead = false
let mutable currentValueIsNull = false
let arrayStack = new Stack<int> ()
do arrayStack.Push Int32.MinValue
// do not write tag if omitting header or array element
let omitTag () = (omitHeader && depth = 0) || arrayStack.Peek() = depth - 1
interface IPickleFormatWriter with
member __.BeginWriteRoot (tag : string) =
if omitHeader then () else
jsonWriter.WriteStartObject()
writePrimitive jsonWriter false "FsPickler" jsonFormatVersion
writePrimitive jsonWriter false "type" tag
member __.EndWriteRoot () =
if not omitHeader then jsonWriter.WriteEnd()
member __.BeginWriteObject (tag : string) (flags : ObjectFlags) =
if not <| omitTag () then
jsonWriter.WritePropertyName tag
if flags.HasFlag ObjectFlags.IsNull then
currentValueIsNull <- true
jsonWriter.WriteNull()
elif flags.HasFlag ObjectFlags.IsSequenceHeader then
if isTopLevelSequence && depth = 0 then
isTopLevelSequenceHead <- true
else
jsonWriter.WriteStartArray()
arrayStack.Push depth
depth <- depth + 1
else
jsonWriter.WriteStartObject()
depth <- depth + 1
if flags = ObjectFlags.None then ()
else
let flagCsv = mkFlagCsv flags
writePrimitive jsonWriter false "_flags" flagCsv
member __.EndWriteObject () =
if currentValueIsNull then
currentValueIsNull <- false
else
depth <- depth - 1
if arrayStack.Peek () = depth then
if isTopLevelSequence && depth = 0 then ()
else
jsonWriter.WriteEndArray()
arrayStack.Pop () |> ignore
else
jsonWriter.WriteEndObject()
member __.SerializeUnionCaseNames = true
member __.PreferLengthPrefixInSequences = false
member __.WriteNextSequenceElement hasNext =
if isTopLevelSequence && depth = 1 then
if isTopLevelSequenceHead then
isTopLevelSequenceHead <- false
else
jsonWriter.WriteWhitespace separator
member __.WriteCachedObjectId id = writePrimitive jsonWriter false "id" id
member __.WriteBoolean (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteByte (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteSByte (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteInt16 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteInt32 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteInt64 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteUInt16 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteUInt32 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteUInt64 (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteSingle (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteDouble (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteDecimal (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag (string value)
member __.WriteChar (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteString (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteBigInteger (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag (string value)
member __.WriteGuid (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteTimeSpan (tag : string) value = writePrimitive jsonWriter (omitTag ()) tag (string value)
// BSON spec mandates the use of Unix time;
// this has millisecond precision which results in loss of accuracy w.r.t. ticks
// since the goal of FsPickler is to offer faithful representations of .NET objects
// we choose to override the spec and serialize ticks outright.
// see also https://json.codeplex.com/discussions/212067
member __.WriteDate (tag : string) value =
if isBsonWriter then
writePrimitive jsonWriter (omitTag ()) tag value.Ticks
else
writePrimitive jsonWriter (omitTag ()) tag value
member __.WriteBytes (tag : string) (value : byte []) =
if not <| omitTag () then
jsonWriter.WritePropertyName tag
if obj.ReferenceEquals(value, null) then
jsonWriter.WriteNull()
else
jsonWriter.WriteValue value
member __.IsPrimitiveArraySerializationSupported = false
member __.WritePrimitiveArray _ _ = raise <| NotSupportedException()
member __.Dispose () = jsonWriter.Flush()

View File

@@ -0,0 +1,68 @@
namespace Nessos.FsPickler.Tests
open PerfUtil
open PerfUtil.NUnit
open NUnit.Framework
open Nessos.FsPickler
open Nessos.FsPickler.Json
[<AbstractClass>]
type PerfTester () =
inherit NUnitPerf<Serializer> ()
let tests = PerfTest.OfModuleMarker<PerformanceTests.Marker> ()
override __.PerfTests = tests
type ``Serializer Comparison`` () =
inherit PerfTester()
let fsp = FsPickler.initBinary()
let bfs = new BinaryFormatterSerializer() :> Serializer
let ndc = new NetDataContractSerializer() :> Serializer
let jdn = new JsonDotNetSerializer() :> Serializer
let bdn = new JsonDotNetBsonSerializer () :> Serializer
let pbn = new ProtoBufSerializer() :> Serializer
let ssj = new ServiceStackJsonSerializer() :> Serializer
let sst = new ServiceStackTypeSerializer() :> Serializer
let comparer = new WeightedComparer(spaceFactor = 0.2, leastAcceptableImprovementFactor = 1.)
let tester = new ImplementationComparer<_>(fsp, [bfs;ndc;jdn;bdn;pbn;ssj;sst], throwOnError = true, warmup = true, comparer = comparer)
override __.PerfTester = tester :> _
type ``FsPickler Formats Comparison`` () =
inherit PerfTester ()
let binary = FsPickler.initBinary()
let json = FsPickler.initJson()
let bson = FsPickler.initBson()
let xml = FsPickler.initXml()
let tester = new ImplementationComparer<_>(binary, [json ; bson; xml], warmup = true, throwOnError = false)
override __.PerfTester = tester :> _
type ``Past FsPickler Versions Comparison`` () =
inherit PerfTester ()
let persistResults = true
let persistenceFile = "fspPerf.xml"
let fsp = FsPickler.initBinary()
let version = typeof<FsPickler>.Assembly.GetName().Version
let comparer = new WeightedComparer(spaceFactor = 0.2, leastAcceptableImprovementFactor = 0.8)
let tester =
new PastImplementationComparer<Serializer>(
fsp, version, historyFile = persistenceFile, throwOnError = true, warmup = true, comparer = comparer)
override __.PerfTester = tester :> _
[<TestFixtureTearDown>]
member __.Persist() =
if persistResults then tester.PersistCurrentResults ()

View File

@@ -0,0 +1,207 @@
namespace Nessos.FsPickler.Tests
open System
open System.Collections.Generic
open PerfUtil
open Nessos.FsPickler
open Nessos.FsPickler.Tests.Serializer
open Nessos.FsPickler.Tests.TestTypes
module PerformanceTests =
type Marker = class end
let guid = Guid.NewGuid()
[<PerfTest(1000)>]
let ``Value: Guid`` s = roundtrip guid s
let date = DateTime.Now
[<PerfTest(1000)>]
let ``Value: DateTime`` s = roundtrip date s
[<PerfTest(10000)>]
let ``Value: String`` s = roundtrip stringValue s
let boxed = box ([| 1 .. 1000 |], "lorem ipsum")
[<PerfTest(1000)>]
let ``Boxed Object`` s = roundtrip boxed s
let fsClass = new Class(42, stringValue)
[<PerfTest(10000)>]
let ``Class: Simple F# Class`` s = roundtrip fsClass s
let serializableClass = new SerializableClass<_>(42, stringValue, [|1..1000|])
[<PerfTest(10000)>]
let ``Class: ISerializable`` s = roundtrip serializableClass s
let boxedClass = box(Some 42)
[<PerfTest(10000)>]
let ``Subtype Resolution`` s = roundtrip boxedClass s
let floatArray = Array.init 100000 (fun i -> float i)
[<PerfTest(10)>]
let ``Array: Float`` s = roundtrip floatArray s
let intArray = Array.init 100000 id
[<PerfTest(10)>]
let ``Array: Int`` s = roundtrip intArray s
let stringArray = Array.init 10000 (fun i -> stringValue + string i)
[<PerfTest(100)>]
let ``Array: String`` s = roundtrip stringArray s
let kvarr = [|1..10000|] |> Array.map (fun i -> i, string i)
[<PerfTest(100)>]
let ``Array: Key-Value Pairs`` s = roundtrip kvarr s
let duArray = [| for i in 1 .. 10000 -> (Something ("asdasdasdas", i)) |]
[<PerfTest(100)>]
let ``Array: Discriminated Unions`` s = roundtrip duArray s
let objArray =
[|
box 2; box 3; box "hello" ; box <| Some 3; box(2,3) ;
box <| new Class(2, stringValue) ; box <| new SerializableClass<int option>(2, stringValue, Some 12);
box stringValue
|]
[<PerfTest(1000)>]
let ``Array: Objects`` s = roundtrip objArray s
let array3D = Array3D.init 100 100 100 (fun i j k -> float (i * j + k))
[<PerfTest(10)>]
let ``Array: Rank-3 Float`` s = roundtrip array3D s
let bclDict = dict [ for i in 1 .. 1000 -> (string i, i)]
[<PerfTest(100)>]
let ``.NET Dictionary`` s = roundtrip bclDict s
let bclStack = new Stack<string>([for i in 1 .. 1000 -> string i])
[<PerfTest(100)>]
let ``.NET Stack`` s = roundtrip bclStack s
let bclList = new List<string * int>([for i in 1 .. 1000 -> string i, i])
[<PerfTest(100)>]
let ``.NET List`` s = roundtrip bclList s
let bclSet = new SortedSet<_>([for i in 1 .. 1000 -> string i])
[<PerfTest(100)>]
let ``.NET Set`` s = roundtrip bclSet s
let smallTuple = (1, DateTime.Now,"hello")
[<PerfTest(10000)>]
let ``FSharp: Tuple Small`` s = roundtrip smallTuple s
let largeTuple = (stringValue, 1, 2, 3, true, "", Some(3.14, [2]), 3, 2, 1, stringValue)
[<PerfTest(10000)>]
let ``FSharp: Tuple Large`` s =
roundtrip largeTuple s
let intList = [1..1000]
[<PerfTest(1000)>]
let ``FSharp: List Int`` s = roundtrip intList s
let stringList = [ for i in 1 .. 1000 -> stringValue + string i ]
[<PerfTest(1000)>]
let ``FSharp: List String`` s = roundtrip stringList s
let pairList = [ for i in 1 .. 1000 -> (string i, i) ]
[<PerfTest(1000)>]
let ``FSharp: List Key-Value`` s = roundtrip pairList s
let nestedLst = let n = [1..1000] in [for _ in 1 .. 100 -> n]
[<PerfTest(1000)>]
let ``FSharp: List Nested`` s = roundtrip nestedLst s
let union = SomethingElse(stringValue, 42, box (Some 42))
[<PerfTest(10000)>]
let ``FSharp: Union`` s = roundtrip union s
let record = { Int = 42 ; String = stringValue ; Tuple = (13, "") }
[<PerfTest(10000)>]
let ``FSharp: Record`` s = roundtrip record s
let peano = int2Peano 100
[<PerfTest(100)>]
let ``FSharp: Peano Rectype`` s = roundtrip peano s
let closure = (@) [ Some([1..100], Set.ofList [1..100]) ]
[<PerfTest(1000)>]
let ``FSharp: Curried Function`` s = roundtrip closure s
let binTree = mkTree 10
[<PerfTest(100)>]
let ``FSharp: Binary Tree`` s = roundtrip binTree s
let intSet = [1..1000] |> List.map string |> set
[<PerfTest(1000)>]
let ``FSharp: Set`` s = roundtrip intSet s
let fsMap = [1..1000] |> Seq.map (fun i -> (string i,i)) |> Map.ofSeq
[<PerfTest(1000)>]
let ``FSharp: Map`` s = roundtrip fsMap s
let testType = typeof<int * string option * Map<int * string [], string ref option>>
[<PerfTest(1000)>]
let ``Reflection: Type`` s = roundtrip testType s
let quotationSmall = <@ fun x -> pown 2 x @>
let quotationLarge =
<@
async {
let rec fibAsync n =
async {
match n with
| _ when n < 0 -> return invalidArg "negative" "n"
| _ when n < 2 -> return n
| n ->
let! fn = fibAsync (n-1)
let! fnn = fibAsync (n-2)
return fn + fnn
}
let! values = [1..100] |> Seq.map fibAsync |> Async.Parallel
return Seq.sum values
}
@>
[<PerfTest(10000)>]
let ``FSharp: Quotation Small`` s = roundtrip quotationSmall s
[<PerfTest(1000)>]
let ``FSharp: Quotation Large`` s = roundtrip quotationLarge s

15
samples/F#/sample.fs Normal file
View File

@@ -0,0 +1,15 @@
module Sample
open System
type Foo =
{
Bar : string
}
type Baz = interface end
let Sample1(xs : int list) : string =
xs
|> List.map (fun x -> string x)
|> String.concat ","

25
samples/FORTRAN/sample1.f Normal file
View File

@@ -0,0 +1,25 @@
c comment
* comment
program main
end
subroutine foo( i, x, b )
INTEGER i
REAL x
LOGICAL b
if( i.ne.0 ) then
call bar( -i )
end if
return
end
double complex function baz()
baz = (0.0d0,0.0d0)
return
end

View File

@@ -0,0 +1,25 @@
c comment
* comment
program main
end
subroutine foo( i, x, b )
INTEGER i
REAL x
LOGICAL b
if( i.ne.0 ) then
call bar( -i )
end if
return
end
double complex function baz()
baz = (0.0d0,0.0d0)
return
end

25
samples/FORTRAN/sample2.f Normal file
View File

@@ -0,0 +1,25 @@
PROGRAM MAIN
END
C comment
* comment
SUBROUTINE foo( i, x, b )
INTEGER i
REAL x
LOGICAL b
IF( i.NE.0 ) THEN
CALL bar( -i )
END IF
RETURN
END
DOUBLE COMPLEX FUNCTION baz()
baz = (0.0d0,0.0d0)
RETURN
END

25
samples/FORTRAN/sample3.F Normal file
View File

@@ -0,0 +1,25 @@
c comment
* comment
program main
end
subroutine foo( i, x, b )
INTEGER i
REAL x
LOGICAL b
if( i.ne.0 ) then
call bar( -i )
end if
return
end
double complex function baz()
baz = (0.0d0,0.0d0)
return
end

244
samples/Forth/asm.fr Normal file
View File

@@ -0,0 +1,244 @@
\ Copyright 2013-2014 Lars Brinkhoff
\ Assembler for x86.
\ Adds to FORTH vocabulary: ASSEMBLER CODE ;CODE.
\ Creates ASSEMBLER vocabulary with: END-CODE and x86 opcodes.
\ Conventional prefix syntax: "<source> <destination> <opcode>,".
\ Addressing modes:
\ - immediate: "n #"
\ - direct: n
\ - register: <reg>
\ - indirect: "<reg> )"
\ - indirect with displacement: "n <reg> )#"
\ - indexed: not supported yet
require lib/common.fth
require search.fth
vocabulary assembler
also assembler definitions
\ Access to the target image.
' header, defer header, is header,
' cell defer cell is cell
' dp defer dp is dp
0 value delta
: aligned cell + 1 - cell negate nand invert ;
: align dp @ aligned dp ! ;
: allot dp +! ;
: here dp @ ;
: cells cell * ;
: c! delta + c! ;
: c, here c! 1 allot ;
: h, dup c, 8 rshift c, ;
: , dup h, 16 rshift h, ;
base @ hex
\ This constant signals that an operand is not a direct address.
deadbeef constant -addr
\ Assembler state.
variable opcode
variable d
variable s
variable dir?
variable mrrm defer ?mrrm,
variable sib defer ?sib,
variable disp defer ?disp,
variable imm defer ?imm,
defer imm,
defer immediate-opcode
defer reg
defer ?opsize
\ Set opcode. And destination: register or memory.
: opcode! 3@ is immediate-opcode >r opcode ! ;
: !reg dir? @ if 2 d ! then dir? off ;
: !mem dir? off ;
\ Set bits in mod/reg/rm byte.
: -mrrm ['] nop is ?mrrm, ;
: mod! mrrm c0 !bits ;
: reg@ mrrm 38 @bits ;
: reg! mrrm 38 !bits ;
: rm@ mrrm 7 @bits ;
: rm! rm@ 3 lshift reg! mrrm 7 !bits ;
: reg>opcode rm@ opcode 07 !bits ;
: opcode>reg opcode @ dup 3 rshift rm! 8 rshift opcode ! ;
\ Write parts of instruction to memory.
: ds d @ s @ + ;
: ?twobyte dup FF > if dup 8 rshift c, then ;
: opcode, opcode @ ?twobyte ds + c, ;
: mrrm, mrrm @ c, ;
: sib, sib @ c, ;
: imm8, imm @ c, ;
: imm16, imm @ h, ;
: imm32, imm @ , ;
: disp8, disp @ c, ;
: disp32, disp @ , ;
\ Set operand size.
: -opsize 2drop r> drop ;
: opsize! is imm, s ! ['] -opsize is ?opsize ;
: !op8 0 ['] imm8, ?opsize ;
: !op32 1 ['] imm32, ?opsize ;
: !op16 1 ['] imm16, ?opsize 66 c, ;
\ Set SIB byte.
: !sib ['] sib, is ?sib, ;
: sib! 3 lshift + sib ! !sib ;
\ Set displacement.
: byte? -80 80 within ;
: disp! is ?disp, disp ! ;
: !disp8 ['] disp8, disp! ;
: !disp32 ['] disp32, disp! ;
: !disp ( a -- u ) dup byte? if !disp8 40 else !disp32 80 then ;
: -pc here 5 + negate ;
: relative -pc disp +! ;
\ Set immediate operand.
: imm! imm ! ['] imm, is ?imm, ;
\ Implements addressing modes: register, indirect, indexed, and direct.
: reg1 rm! !reg ;
: reg2 3 lshift reg! ;
: !reg2 ['] reg2 is reg ;
: ind dup mod! rm! !mem !reg2 ;
: ind# swap !disp + ind ;
: idx 04 ind sib! ;
: idx# rot !disp 04 + ind sib! ;
: addr !disp32 05 ind ;
\ Reset assembler state.
: 0opsize ['] opsize! is ?opsize ;
: 0ds d off s off ;
: 0reg ['] reg1 is reg ;
: 0mrrm c0 mrrm ! ['] mrrm, is ?mrrm, ;
: 0sib ['] nop is ?sib, ;
: 0disp ['] nop is ?disp, ;
: 0imm imm off ['] nop is ?imm, 0 is imm, ;
: 0asm 0imm 0disp 0reg 0ds 0mrrm 0sib 0opsize dir? on ;
\ Enter and exit assembler mode.
: start-code also assembler 0asm ;
: end-code align previous ;
\ Implements addressing mode: immediate.
: imm8? imm @ byte? ;
: ?sign-extend d off imm8? if 2 d ! ['] imm8, is ?imm, then ;
: alu# opcode @ reg! 80 opcode ! ?sign-extend ;
: mov# B0 s @ 3 lshift + rm@ + opcode ! 0ds -mrrm ;
: push# imm8? if ['] imm8, 6A else ['] imm32, 68 then dup opcode ! rm! is ?imm, ;
: test# F6 opcode ! ;
: imm-op imm! immediate-opcode ;
\ Process one operand. All operands except a direct address
\ have the stack picture ( n*x xt -addr ).
: addr? dup -addr <> ;
: op addr? if addr else drop execute then ;
\ Define instruction formats.
: instruction, opcode! opcode, ?mrrm, ?sib, ?disp, ?imm, 0asm ;
: mnemonic ( u a "name" -- ) create ['] nop 3, does> instruction, ;
: format: create ] !csp does> mnemonic ;
: immediate: ' latestxt >body ! ;
\ Instruction formats.
format: 0op -mrrm ;
format: 1reg op reg>opcode 0ds -mrrm ;
format: 1op opcode>reg op d off ;
format: 2op op op ;
format: 2op-d op op d off ;
format: 2op-ds op op 0ds ;
format: 1addr op relative -mrrm ;
format: 1imm8 !op8 op -mrrm ;
\ Instruction mnemonics.
00 2op add, immediate: alu#
08 2op or, immediate: alu#
0F44 2op-ds cmove, \ Todo: other condition codes.
0FB6 2op-ds movzx,
0FBE 2op-ds movsx,
10 2op adc, immediate: alu#
18 2op sbb, immediate: alu#
20 2op and, immediate: alu#
26 0op es,
28 2op sub, immediate: alu#
2E 0op cs,
30 2op xor, immediate: alu#
36 0op ss,
38 2op cmp, immediate: alu#
3E 0op ds,
50 1reg push, immediate: push#
58 1reg pop,
64 0op fs,
65 0op gs,
\ 70 jcc
84 2op-d test, immediate: test#
86 2op-d xchg,
88 2op mov, immediate: mov#
8D 2op-ds lea,
\ 8F/0 pop, rm
90 0op nop,
C3 0op ret,
\ C6/0 immediate mov to r/m
\ C7/0 immediate mov to r/m
CD 1imm8 int,
E8 1addr call,
E9 1addr jmp,
\ EB jmp rel8
F0 0op lock,
F2 0op rep,
F3 0op repz,
F4 0op hlt,
F5 0op cmc,
F610 1op not,
F618 1op neg,
F8 0op clc,
F9 0op stc,
FA 0op cli,
FB 0op sti,
FC 0op cld,
FD 0op std,
\ FE 0 inc rm
\ FF 1 dec rm
\ FF 2 call rm
\ FF 4 jmp rm
\ FF 6 push rm
: sp? dup 4 = ;
\ Addressing mode syntax: immediate, indirect, and displaced indirect.
: # ['] imm-op -addr ;
: ) 2drop sp? if 4 ['] idx else ['] ind then -addr 0reg 0opsize ;
: )# 2drop sp? if 4 ['] idx# else ['] ind# then -addr 0reg 0opsize ;
\ Define registers.
: reg8 create , does> @ ['] reg -addr !op8 ;
: reg16 create , does> @ ['] reg -addr !op16 ;
: reg32 create , does> @ ['] reg -addr !op32 ;
: reg: dup reg8 dup reg16 dup reg32 1+ ;
\ Register names.
0
reg: al ax eax reg: cl cx ecx reg: dl dx edx reg: bl bx ebx
reg: ah sp esp reg: ch bp ebp reg: dh si esi reg: bh di edi
drop
\ Runtime for ;CODE. CODE! is defined elsewhere.
: (;code) r> code! ;
base ! only forth definitions also assembler
\ Standard assembler entry points.
: code parse-name header, ?code, start-code ;
: ;code postpone (;code) reveal postpone [ ?csp start-code ; immediate
0asm
previous

252
samples/Forth/core.f Normal file
View File

@@ -0,0 +1,252 @@
: immediate lastxt @ dup c@ negate swap c! ;
: \ source nip >in ! ; immediate \ Copyright 2004, 2012 Lars Brinkhoff
: char \ ( "word" -- char )
bl-word here 1+ c@ ;
: ahead here 0 , ;
: resolve here swap ! ;
: ' bl-word here find 0branch [ ahead ] exit [ resolve ] 0 ;
: postpone-nonimmediate [ ' literal , ' compile, ] literal , ;
: create dovariable_code header, reveal ;
create postponers
' postpone-nonimmediate ,
' abort ,
' , ,
: word \ ( char "<chars>string<char>" -- caddr )
drop bl-word here ;
: postpone \ ( C: "word" -- )
bl word find 1+ cells postponers + @ execute ; immediate
: unresolved \ ( C: "word" -- orig )
postpone postpone postpone ahead ; immediate
: chars \ ( n1 -- n2 )
;
: else \ ( -- ) ( C: orig1 -- orig2 )
unresolved branch swap resolve ; immediate
: if \ ( flag -- ) ( C: -- orig )
unresolved 0branch ; immediate
: then \ ( -- ) ( C: orig -- )
resolve ; immediate
: [char] \ ( "word" -- )
char postpone literal ; immediate
: (does>) lastxt @ dodoes_code over >code ! r> swap >does ! ;
: does> postpone (does>) ; immediate
: begin \ ( -- ) ( C: -- dest )
here ; immediate
: while \ ( x -- ) ( C: dest -- orig dest )
unresolved 0branch swap ; immediate
: repeat \ ( -- ) ( C: orig dest -- )
postpone branch , resolve ; immediate
: until \ ( x -- ) ( C: dest -- )
postpone 0branch , ; immediate
: recurse lastxt @ compile, ; immediate
: pad \ ( -- addr )
here 1024 + ;
: parse \ ( char "string<char>" -- addr n )
pad >r begin
source? if <source 2dup <> else 0 0 then
while
r@ c! r> 1+ >r
repeat 2drop pad r> over - ;
: ( \ ( "string<paren>" -- )
[ char ) ] literal parse 2drop ; immediate
\ TODO: If necessary, refill and keep parsing.
: string, ( addr n -- )
here over allot align swap cmove ;
: (s") ( -- addr n ) ( R: ret1 -- ret2 )
r> dup @ swap cell+ 2dup + aligned >r swap ;
create squote 128 allot
: s" ( "string<quote>" -- addr n )
state @ if
postpone (s") [char] " parse dup , string,
else
[char] " parse >r squote r@ cmove squote r>
then ; immediate
: (abort") ( ... addr n -- ) ( R: ... -- )
cr type cr abort ;
: abort" ( ... x "string<quote>" -- ) ( R: ... -- )
postpone if postpone s" postpone (abort") postpone then ; immediate
\ ----------------------------------------------------------------------
( Core words. )
\ TODO: #
\ TODO: #>
\ TODO: #s
: and ( x y -- x&y ) nand invert ;
: * 1 2>r 0 swap begin r@ while
r> r> swap 2dup dup + 2>r and if swap over + swap then dup +
repeat r> r> 2drop drop ;
\ TODO: */mod
: +loop ( -- ) ( C: nest-sys -- )
postpone (+loop) postpone 0branch , postpone unloop ; immediate
: space bl emit ;
: ?.- dup 0 < if [char] - emit negate then ;
: digit [char] 0 + emit ;
: (.) base @ /mod ?dup if recurse then digit ;
: ." ( "string<quote>" -- ) postpone s" postpone type ; immediate
: . ( x -- ) ?.- (.) space ;
: postpone-number ( caddr -- )
0 0 rot count >number dup 0= if
2drop nip
postpone (literal) postpone (literal) postpone ,
postpone literal postpone ,
else
." Undefined: " type cr abort
then ;
' postpone-number postponers cell+ !
: / ( x y -- x/y ) /mod nip ;
: 0< ( n -- flag ) 0 < ;
: 1- ( n -- n-1 ) -1 + ;
: 2! ( x1 x2 addr -- ) swap over ! cell+ ! ;
: 2* ( n -- 2n ) dup + ;
\ Kernel: 2/
: 2@ ( addr -- x1 x2 ) dup cell+ @ swap @ ;
\ Kernel: 2drop
\ Kernel: 2dup
\ TODO: 2over ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 )
\ 3 pick 3 pick ;
\ TODO: 2swap
\ TODO: <#
: abs ( n -- |n| )
dup 0< if negate then ;
\ TODO: accept
: c, ( n -- )
here c! 1 chars allot ;
: char+ ( n1 -- n2 )
1+ ;
: constant create , does> @ ;
: decimal ( -- )
10 base ! ;
: depth ( -- n )
data_stack 100 cells + 'SP @ - /cell / 2 - ;
: do ( n1 n2 -- ) ( R: -- loop-sys ) ( C: -- do-sys )
postpone 2>r here ; immediate
\ TODO: environment?
\ TODO: evaluate
\ TODO: fill
\ TODO: fm/mod )
\ TODO: hold
: j ( -- x1 ) ( R: x1 x2 x3 -- x1 x2 x3 )
'RP @ 3 cells + @ ;
\ TODO: leave
: loop ( -- ) ( C: nest-sys -- )
postpone 1 postpone (+loop)
postpone 0branch ,
postpone unloop ; immediate
: lshift begin ?dup while 1- swap dup + swap repeat ;
: rshift 1 begin over while dup + swap 1- swap repeat nip
2>r 0 1 begin r@ while
r> r> 2dup swap dup + 2>r and if swap over + swap then dup +
repeat r> r> 2drop drop ;
: max ( x y -- max[x,y] )
2dup > if drop else nip then ;
\ Kernel: min
\ TODO: mod
\ TODO: move
: (quit) ( R: ... -- )
return_stack 100 cells + 'RP !
0 'source-id ! tib ''source ! #tib ''#source !
postpone [
begin
refill
while
interpret state @ 0= if ." ok" cr then
repeat
bye ;
' (quit) ' quit >body cell+ !
\ TODO: s>d
\ TODO: sign
\ TODO: sm/rem
: spaces ( n -- )
0 do space loop ;
\ TODO: u.
: signbit ( -- n ) -1 1 rshift invert ;
: xor ( x y -- x^y ) 2dup nand >r r@ nand swap r> nand nand ;
: u< ( x y -- flag ) signbit xor swap signbit xor > ;
\ TODO: um/mod
: variable ( "word" -- )
create /cell allot ;
: ['] \ ( C: "word" -- )
' postpone literal ; immediate

Some files were not shown because too many files have changed in this diff Show More