Merge pull request #1093 from github/1005-update

1005 update
This commit is contained in:
Arfon Smith
2014-04-21 12:55:58 -05:00
9 changed files with 443 additions and 13 deletions

View File

@@ -28,6 +28,9 @@ module Linguist
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
disambiguate_cl(data, languages) disambiguate_cl(data, languages)
end end
if languages.all? { |l| ["Rebol", "R"].include?(l) }
disambiguate_r(data, languages)
end
end end
end end
@@ -73,6 +76,13 @@ module Linguist
matches matches
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
end
def self.active? def self.active?
!!ACTIVE !!ACTIVE
end end

View File

@@ -1571,10 +1571,12 @@ Rebol:
type: programming type: programming
lexer: REBOL lexer: REBOL
color: "#358a5b" color: "#358a5b"
primary_extension: .rebol primary_extension: .reb
extensions: extensions:
- .r
- .r2 - .r2
- .r3 - .r3
- .rebol
Redcode: Redcode:
primary_extension: .cw primary_extension: .cw

View File

@@ -407,7 +407,11 @@
".rdoc" ".rdoc"
], ],
"Rebol": [ "Rebol": [
".r" ".r",
".r2",
".r3",
".reb",
".rebol"
], ],
"RMarkdown": [ "RMarkdown": [
".rmd" ".rmd"
@@ -612,8 +616,8 @@
".gemrc" ".gemrc"
] ]
}, },
"tokens_total": 529578, "tokens_total": 530100,
"languages_total": 647, "languages_total": 652,
"tokens": { "tokens": {
"ABAP": { "ABAP": {
"*/**": 1, "*/**": 1,
@@ -46428,12 +46432,155 @@
"purpose.": 1 "purpose.": 1
}, },
"Rebol": { "Rebol": {
"REBOL": 1, "REBOL": 5,
"[": 3, "[": 54,
"]": 3, "System": 1,
"hello": 2, "Title": 2,
"func": 1, "Rights": 1,
"print": 1 "{": 8,
"Copyright": 1,
"Technologies": 2,
"is": 4,
"a": 2,
"trademark": 1,
"of": 1,
"}": 8,
"License": 2,
"Licensed": 1,
"under": 1,
"the": 3,
"Apache": 1,
"Version": 1,
"See": 1,
"http": 1,
"//www.apache.org/licenses/LICENSE": 1,
"-": 26,
"Purpose": 1,
"These": 1,
"are": 2,
"used": 3,
"to": 2,
"define": 1,
"natives": 1,
"and": 2,
"actions.": 1,
"Bind": 1,
"attributes": 1,
"for": 4,
"this": 1,
"block": 5,
"BIND_SET": 1,
"SHALLOW": 1,
"]": 61,
";": 19,
"Special": 1,
"as": 1,
"spec": 3,
"datatype": 2,
"test": 1,
"functions": 1,
"(": 30,
"e.g.": 1,
"time": 2,
")": 33,
"value": 1,
"any": 1,
"type": 1,
"The": 1,
"native": 5,
"function": 3,
"must": 1,
"be": 1,
"defined": 1,
"first.": 1,
"This": 1,
"special": 1,
"boot": 1,
"created": 1,
"manually": 1,
"within": 1,
"C": 1,
"code.": 1,
"Creates": 2,
"internal": 2,
"usage": 2,
"only": 2,
".": 4,
"no": 3,
"check": 2,
"required": 2,
"we": 2,
"know": 2,
"it": 2,
"correct": 2,
"action": 2,
"Rebol": 4,
"re": 20,
"func": 5,
"s": 5,
"/i": 1,
"rejoin": 1,
"compose": 1,
"either": 1,
"i": 1,
"little": 1,
"helper": 1,
"standard": 1,
"grammar": 1,
"regex": 2,
"date": 6,
"naive": 1,
"string": 1,
"|": 22,
"S": 3,
"*": 7,
"<(?:[^^\\>": 1,
"d": 3,
"+": 6,
"/": 5,
"@": 1,
"%": 2,
"A": 3,
"F": 1,
"url": 1,
"PR_LITERAL": 10,
"string_url": 1,
"email": 1,
"string_email": 1,
"binary": 1,
"binary_base_two": 1,
"binary_base_sixty_four": 1,
"binary_base_sixteen": 1,
"re/i": 2,
"issue": 1,
"string_issue": 1,
"values": 1,
"value_date": 1,
"value_time": 1,
"tuple": 1,
"value_tuple": 1,
"pair": 1,
"value_pair": 1,
"number": 2,
"PR": 1,
"Za": 2,
"z0": 2,
"<[=>": 1,
"rebol": 1,
"red": 1,
"/system": 1,
"world": 1,
"topaz": 1,
"true": 1,
"false": 1,
"yes": 1,
"on": 1,
"off": 1,
"none": 1,
"#": 1,
"hello": 8,
"print": 4,
"author": 1
}, },
"RMarkdown": { "RMarkdown": {
"Some": 1, "Some": 1,
@@ -55196,7 +55343,7 @@
"Racket": 331, "Racket": 331,
"Ragel in Ruby Host": 593, "Ragel in Ruby Host": 593,
"RDoc": 279, "RDoc": 279,
"Rebol": 11, "Rebol": 533,
"RMarkdown": 19, "RMarkdown": 19,
"RobotFramework": 483, "RobotFramework": 483,
"Ruby": 3862, "Ruby": 3862,
@@ -55359,7 +55506,7 @@
"Racket": 2, "Racket": 2,
"Ragel in Ruby Host": 3, "Ragel in Ruby Host": 3,
"RDoc": 1, "RDoc": 1,
"Rebol": 1, "Rebol": 6,
"RMarkdown": 1, "RMarkdown": 1,
"RobotFramework": 3, "RobotFramework": 3,
"Ruby": 17, "Ruby": 17,
@@ -55402,5 +55549,5 @@
"YAML": 2, "YAML": 2,
"Zephir": 2 "Zephir": 2
}, },
"md5": "947962ee2f115cece2c5dca6a4d48148" "md5": "c03f5780c3430c9d636060acee77293a"
} }

View File

@@ -0,0 +1,217 @@
Rebol [Title: "Google Code Prettify Datatypes"]
re: func [s /i] [rejoin compose ["/^^" (s) "/" either i ["i"][""]]] ; little helper for standard grammar regex used
date-re: "\d{1,2}[\-\/](\d{1,2}|\w{3,9})[\-\/]\d{2,4}" ; naive date! regex
string-re: {\"(?:[^^\"\\]|\\[\s\S])*(?:\"|$)}
brace-re: "\{(?:[^^\}\^^]|\^^[\s\S])*(?:\}|$)" ; TODO - could build this from string-re
block-re: "\[(?:[^^\]\\]|\\[\s\S])*(?:\]|$)"
tag-re: "\<(?:[^^\>\\]|\\[\s\S])*(?:\>|$)" ; TODO - could build this from string-re
number-re: "(?:[.,]\d+|\d+['\d]*(?:[.,]\d*)?)(?:e[-+]?\d+)?"
word-re: "[A-Za-z=\-?!_*+.`~&][A-Za-z0-9=\-!?_*+.`~&]*"
|: "|"
types: compose/deep [
; comments
comment! [
PR_LITERAL
; comment_shebang -- Script tag (shebang!)
(re/i "#![^^\r\n]+")
; comment_line -- A line comment that starts with ;
(re ";[^^\r\n]*")
; comment_multiline_string -- Multi-line comment
(re ["comment\s*" brace-re])
; comment_multiline_block
(re ["comment\s*" block-re])
]
; type_literal
; logic
logic! [
PR_LITERAL
(re "#\[(?:true|false|yes|no|on|off)\]")
]
; none
none! [
PR_LITERAL
(re "#\[none\]")
]
; strings
; character
char! [
PR_LITERAL
(re/i "#^"(?:[^^^^^"]|\^^(?:[\^^^"\/\-A-Z]|\((?:[0-9A-F]{2,4}|tab|newline)\)))^"")
]
string! [
PR_LITERAL
; string_quoted
(re "^"(?:[^^^"\\]|\\[\s\S])*(?:^"|$)")
; string_multiline -- Multi-line string {braces} - allowed within: { ^{ ^}
(re brace-re)
]
; string_tag_comment
comment! [
PR_LITERAL
(re "<!--(?:[^^-]|-(?!->))+-->")
]
; string_tag
tag! [
PR_LITERAL
(re "<[^^^"<=>\x00\x09\x0A\x0D\x20\u005D\u007F][^^>\x00]*>")
]
file! [
PR_LITERAL
; string_file
(re "%(?:[a-zA-Z?!.*&|=_~0-9'+\-,:\/\\@]|%[0-9A-F]{2})+")
; string_file_quoted
(re "%^"(?:[^^^"])*^"")
]
url! [
PR_LITERAL
; string_url
(re "[a-zA-Z?!.*&|=_~][a-zA-Z?!.*&|=_~0-9'+-,]*:(?:[a-zA-Z?!.*&|=_~0-9'+\-,:\/@]|%[0-9A-F]{2})+")
]
email! [
PR_LITERAL
; string_email
(re "[\w\d\+\-\.]+\@[\w\d\+\-\.]+\b")
]
binary! [
PR_LITERAL
; binary_base_two
(re "2#\{(?:[01\r\n\t ])*\}")
; binary_base_sixty_four
(re "64#\{(?:[0-9+\/a-yA-Z=\r\n\t ])*\}")
; binary_base_sixteen
(re/i "(?:16)?#\{(?:[0-9a-f\r\n\t ])*\}")
]
issue! [
PR_LITERAL
; string_issue
(re "#[\w\d\-]+(?=[\s\n\t]|$)")
]
; values
date! [
PR_LITERAL
; value_date
(re [date-re "\/\d{1,2}\:\d{1,2}\:\d{1,2}(\+|\-)\d{1,2}\:(00|30)\b"])
(re [date-re "\/\d{1,2}\:\d{1,2}\:\d{1,2}\b"])
(re [date-re "\b"])
(re "\d{2,4}[\/\-](\d{1,2}|\w{3,9})[\/\-]\d{1,2}(?:\/\d{1,2}\:\d{1,2}(?:\:\d{1,2})?(?:[-+]\d{1,2}:[03]0)?)?")
]
time! [
PR_LITERAL
; value_time
(re "[-+]?\d{1,2}:\d{1,2}(?::\d{1,2}(?:\.\d+)?)?\b")
]
tuple! [
PR_LITERAL
; value_tuple
(re "\d+(?:\.\d+){2,9}")
]
pair! [
PR_LITERAL
; value_pair
(re/i ["[-+]?" number-re "x[-+]?" number-re])
]
; [PR['PR_LITERAL'], /^\d(?:[\.\,\'\d]*)x\d(?:[\.\,\'\d]*)\b/]
money! [
PR_LITERAL
; value_money
(re ["[-+]?[A-Z]{0,3}\$" number-re])
; [PR['PR_LITERAL'], /^\$\d[\d\.\,\']*\b/]
; [PR['PR_LITERAL'], /^[\+\-\w]{1,4}\$\d[\d\.\,\']*\b/]
]
; value_number
number! [
PR_LITERAL
(re/i ["[-+]?" number-re "%?"])
; percent! [PR_LITERAL (re "(\+|\-|\d)(?:[\.\,\'\d]*)\%\b")]
; decimal! [PR_LITERAL (re "(\+|\-|\d)\d*(?:[\.\,]\d+)\b")]
; integer! [PR_LITERAL (re "(\+|\-|\d)\d*\b")]
]
; words
datatype! [
PR_LITERAL
; word_datatype
(re "(?:[A-Za-z\-]+)\!(?![A-Za-z0-9\-])")
]
set-word! [
PR_LITERAL
; word_set
(re [word-re "(?:\/" word-re "|\/\d+)*:"])
]
; -- get-word!
get-word! [
PR_LITERAL
; word_get
(re [":" word-re])
]
; -- lit-word!
lit-word! [
PR_LITERAL
; word_lit
(re ["'" word-re])
]
refinement! [
PR_LITERAL
; word_refine
(re reduce ["\/" replace copy find next word-re "[" "]*" "]+" "(?![A-Za-z0-9\-])"])
]
op! [
PR_LITERAL
; word_native
(re "(?:!=?=?|\*\*?|[+-]|\/\/?|<[=>]?|=[=?]?|>=?)(?![A-Za-z0-9\-])")
]
function! [
PR_LITERAL
(re make-keywords-string)
; [REB['function!'], /\b(?:to\-relative\-file\/as\-local|or\~|pwd|abs|map|not|rm|at|do|dp|ds|dt|cd|in|ls|to|or|if)\s/]
]
rebol! [
PR_LITERAL
; word_header
(re/i "(?:rebol|red(?:\/system)?|world|topaz)$")
]
logic! [
PR_LITERAL
; word_logic
(re "(?:true|false|yes|no|on|off)$")
]
; word_none
none! [PR_LITERAL (re "none$")]
; word
word! [PR_LITERAL (re word-re)]
; -- literal!
; literal! [PR_LITERAL (re ["#" block-re])]
]

31
samples/Rebol/booters.r Normal file
View File

@@ -0,0 +1,31 @@
REBOL [
System: "REBOL [R3] Language Interpreter and Run-time Environment"
Title: "Special boot native function specs"
Rights: {
Copyright 2012 REBOL Technologies
REBOL is a trademark of REBOL Technologies
}
License: {
Licensed under the Apache License, Version 2.0.
See: http://www.apache.org/licenses/LICENSE-2.0
}
Purpose: {
These are used to define natives and actions.
Bind attributes for this block are: BIND_SET and SHALLOW
}
]
; Special block used as spec to the datatype test functions (e.g. time?):
["Returns TRUE if it is this type." value [any-type!] 0]
; The native function must be defined first. This is a
; special boot function created manually within the C code.
native: native [
{Creates native function (for internal usage only).}
spec ; [block!] -- no check required, we know it is correct
]
action: native [
{Creates datatype action (for internal usage only).}
spec ; [block!] -- no check required, we know it is correct
]

View File

@@ -1,5 +1,7 @@
REBOL [] REBOL []
hello: func [] [ hello: func [] [
print "hello, world!" print "hello, world!"
] ]
hello hello

View File

@@ -0,0 +1,7 @@
Rebol []
hello: func [] [
print "hello, world!"
]
hello

View File

@@ -0,0 +1,5 @@
Rebol []
hello: func [] [
print "hello, world!"
]
hello

View File

@@ -0,0 +1,9 @@
Rebol [
author: "Rebol user"
]
hello: func [] [
print "hello, world!"
]
hello