diff --git a/.gitignore b/.gitignore index ceba2ce9..813d6c10 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .* !/.gitignore .*.gz +*.tmTheme.js # A handy place to put stuff that git should ignore: /ignore/ diff --git a/demo/kitchen-sink/doclist.js b/demo/kitchen-sink/doclist.js index e4f4833b..81fc5081 100644 --- a/demo/kitchen-sink/doclist.js +++ b/demo/kitchen-sink/doclist.js @@ -135,7 +135,16 @@ var docs = { "docs/xml.xml": "XML", "docs/xquery.xq": "XQuery", "docs/yaml.yaml": "YAML", - "docs/c9search.c9search_results": "C9 Search Results" + "docs/c9search.c9search_results": "C9 Search Results", + + "docs/actionscript.as": "ActionScript", + "docs/erlang/erl": "Erlang", + "docs/forth.frt": "Forth", + "docs/fortran.f95": "Fortran", + "docs/haskell.hs": "Haskell", + "docs/julia.js": "Julia", + "docs/prolog/plg": "Prolog", + "docs/rust.rs": "Rust" }; var ownSource = { diff --git a/demo/kitchen-sink/docs/actionscript.as b/demo/kitchen-sink/docs/actionscript.as new file mode 100644 index 00000000..ffe21fbf --- /dev/null +++ b/demo/kitchen-sink/docs/actionscript.as @@ -0,0 +1,51 @@ +package code +{ + /***************************************** + * based on textmate actionscript bundle + ****************************************/ + + import fl.events.SliderEvent; + + public class Foo extends MovieClip + { + //************************* + // Properties: + + public var activeSwatch:MovieClip; + + // Color offsets + public var c1:Number = 0; // R + + //************************* + // Constructor: + + public function Foo() + { + // Respond to mouse events + swatch1_btn.addEventListener(MouseEvent.CLICK,swatchHandler,false,0,false); + previewBox_btn.addEventListener(MouseEvent.MOUSE_DOWN,dragPressHandler); + + // Respond to drag events + red_slider.addEventListener(SliderEvent.THUMB_DRAG,sliderHandler); + + // Draw a frame later + addEventListener(Event.ENTER_FRAME,draw); + } + + protected function clickHandler(event:MouseEvent):void + { + car.transform.colorTransform = new ColorTransform(0,0,0,1,c1,c2,c3); + } + + protected function changeRGBHandler(event:Event):void + { + c1 = Number(c1_txt.text); + + if(!(c1>=0)){ + c1 = 0; + } + + updateSliders(); + } + } +} \ No newline at end of file diff --git a/demo/kitchen-sink/docs/erlang.erl b/demo/kitchen-sink/docs/erlang.erl new file mode 100644 index 00000000..705642b3 --- /dev/null +++ b/demo/kitchen-sink/docs/erlang.erl @@ -0,0 +1,20 @@ + %% A process whose only job is to keep a counter. + %% First version + -module(counter). + -export([start/0, codeswitch/1]). + + start() -> loop(0). + + loop(Sum) -> + receive + {increment, Count} -> + loop(Sum+Count); + {counter, Pid} -> + Pid ! {counter, Sum}, + loop(Sum); + code_switch -> + ?MODULE:codeswitch(Sum) + % Force the use of 'codeswitch/1' from the latest MODULE version + end. + + codeswitch(Sum) -> loop(Sum). \ No newline at end of file diff --git a/demo/kitchen-sink/docs/forth.frt b/demo/kitchen-sink/docs/forth.frt new file mode 100644 index 00000000..dc85cd7b --- /dev/null +++ b/demo/kitchen-sink/docs/forth.frt @@ -0,0 +1,41 @@ +: HELLO ( -- ) CR ." Hello, world!" ; + +HELLO +Hello, world! + +: [CHAR] CHAR POSTPONE LITERAL ; IMMEDIATE + +0 value ii 0 value jj +0 value KeyAddr 0 value KeyLen +create SArray 256 allot \ state array of 256 bytes +: KeyArray KeyLen mod KeyAddr ; + +: get_byte + c@ ; +: set_byte + c! ; +: as_byte 255 and ; +: reset_ij 0 TO ii 0 TO jj ; +: i_update 1 + as_byte TO ii ; +: j_update ii SArray get_byte + as_byte TO jj ; +: swap_s_ij + jj SArray get_byte + ii SArray get_byte jj SArray set_byte + ii SArray set_byte +; + +: rc4_init ( KeyAddr KeyLen -- ) + 256 min TO KeyLen TO KeyAddr + 256 0 DO i i SArray set_byte LOOP + reset_ij + BEGIN + ii KeyArray get_byte jj + j_update + swap_s_ij + ii 255 < WHILE + ii i_update + REPEAT + reset_ij +; +: rc4_byte + ii i_update jj j_update + swap_s_ij + ii SArray get_byte jj SArray get_byte + as_byte SArray get_byte xor +; \ No newline at end of file diff --git a/demo/kitchen-sink/docs/fortran.f95 b/demo/kitchen-sink/docs/fortran.f95 new file mode 100644 index 00000000..8dbd8809 --- /dev/null +++ b/demo/kitchen-sink/docs/fortran.f95 @@ -0,0 +1,28 @@ +! sum.f90 +! Performs summations using in a loop using EXIT statement +! Saves input information and the summation in a data file + +program summation +implicit none +integer :: sum, a + +print*, "This program performs summations. Enter 0 to stop." +open(unit=10, file="SumData.DAT") + +sum = 0 + +do + print*, "Add:" + read*, a + if (a == 0) then + exit + else + sum = sum + a + end if + write(10,*) a +end do + +print*, "Summation =", sum +write(10,*) "Summation =", sum +close(10) + \ No newline at end of file diff --git a/demo/kitchen-sink/docs/haskell.hs b/demo/kitchen-sink/docs/haskell.hs new file mode 100644 index 00000000..5c0defc2 --- /dev/null +++ b/demo/kitchen-sink/docs/haskell.hs @@ -0,0 +1,20 @@ +-- Type annotation (optional) +fib :: Int -> Integer + +-- With self-referencing data +fib n = fibs !! n + where fibs = 0 : scanl (+) 1 fibs + -- 0,1,1,2,3,5,... + +-- Same, coded directly +fib n = fibs !! n + where fibs = 0 : 1 : next fibs + next (a : t@(b:_)) = (a+b) : next t + +-- Similar idea, using zipWith +fib n = fibs !! n + where fibs = 0 : 1 : zipWith (+) fibs (tail fibs) + +-- Using a generator function +fib n = fibs (0,1) !! n + where fibs (a,b) = a : fibs (b,a+b) \ No newline at end of file diff --git a/demo/kitchen-sink/docs/julia.jl b/demo/kitchen-sink/docs/julia.jl new file mode 100644 index 00000000..97178469 --- /dev/null +++ b/demo/kitchen-sink/docs/julia.jl @@ -0,0 +1,15 @@ +for op = (:+, :*, :&, :|, :$) + @eval ($op)(a,b,c) = ($op)(($op)(a,b),c) +end + + +function g(x,y) + return x * y + x + y +end + +cd("data") do + open("outfile", "w") do f + write(f, data) + end +end diff --git a/demo/kitchen-sink/docs/prolog.plg b/demo/kitchen-sink/docs/prolog.plg new file mode 100644 index 00000000..2c867157 --- /dev/null +++ b/demo/kitchen-sink/docs/prolog.plg @@ -0,0 +1,18 @@ +partition([], _, [], []). +partition([X|Xs], Pivot, Smalls, Bigs) :- + ( X @< Pivot -> + Smalls = [X|Rest], + partition(Xs, Pivot, Rest, Bigs) + ; Bigs = [X|Rest], + partition(Xs, Pivot, Smalls, Rest) + ). + +quicksort([]) --> []. +quicksort([X|Xs]) --> + { partition(Xs, X, Smaller, Bigger) }, + quicksort(Smaller), [X], quicksort(Bigger). + +perfect(N) :- + between(1, inf, N), U is N // 2, + findall(D, (between(1,U,D), N mod D =:= 0), Ds), + sumlist(Ds, N). \ No newline at end of file diff --git a/demo/kitchen-sink/docs/rust.rs b/demo/kitchen-sink/docs/rust.rs new file mode 100644 index 00000000..7ab5418c --- /dev/null +++ b/demo/kitchen-sink/docs/rust.rs @@ -0,0 +1,20 @@ +use core::rand::RngUtil; + +fn main() { + for ["Alice", "Bob", "Carol"].each |&name| { + do spawn { + let v = rand::Rng().shuffle([1, 2, 3]); + for v.each |&num| { + print(fmt!("%s says: '%d'\n", name, num + 1)) + } + } + } +} + +fn map(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] { + let mut accumulator = ~[]; + for vec::each(vector) |element| { + accumulator.push(function(element)); + } + return accumulator; +} diff --git a/demo/kitchen-sink/modelist.js b/demo/kitchen-sink/modelist.js index 9c693f99..9ba4a13d 100644 --- a/demo/kitchen-sink/modelist.js +++ b/demo/kitchen-sink/modelist.js @@ -35,7 +35,6 @@ Mode.prototype.supportsFile = function(filename) { }; var modesByName = { - abap: ["ABAP" , "abap"], asciidoc: ["AsciiDoc" , "asciidoc"], c9search: ["C9Search" , "c9search_results"], coffee: ["CoffeeScript" , "^Cakefile|coffee|cf|cson"], @@ -100,12 +99,24 @@ var modesByName = { text: ["Text" , "txt"], textile: ["Textile" , "textile"], tmsnippet: ["tmSnippet" , "tmSnippet"], - toml: ["toml" , "toml"], + toml: ["Toml" , "toml"], typescript: ["Typescript" , "typescript|ts|str"], vbscript: ["VBScript" , "vbs"], xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"], xquery: ["XQuery" , "xq"], - yaml: ["YAML" , "yaml"] + yaml: ["YAML" , "yaml"], + + abap: ["ABAP" , "abap"], + actionscript: ["ActionScript" ,"as"], + erlang: ["Erlang" ,"erl|hrl"], + forth: ["Forth", ,"frt|fs|ldr"], + fortran_modern: ["Fortran - Modern", ,"f90|F90|f95|F95|f03|F03|f08|F08"], + haskell: ["Haskell", "hs"], + julia: ["Julia", "jl"], + prolog: ["Prolog", "plg|prolog"], + rust: ["Rust", "rs|rc"] + + }; for (var name in modesByName) { diff --git a/lib/ace/mode/rust_highlight_rules.js b/lib/ace/mode/rust_highlight_rules.js index 03312a45..817cb65e 100644 --- a/lib/ace/mode/rust_highlight_rules.js +++ b/lib/ace/mode/rust_highlight_rules.js @@ -63,17 +63,17 @@ var RustHighlightRules = function() { next: 'pop' }, { include: '#rust_escaped_character' }, { defaultToken: 'string.quoted.double.source.rust' } ] }, - { token: - [ 'keyword.source.rust', - 'meta.function.source.rust', - 'entity.name.function.source.rust', - 'meta.function.source.rust' ], + { token: [ 'keyword.source.rust', 'meta.function.source.rust', + 'entity.name.function.source.rust', 'meta.function.source.rust' ], regex: '\\b(fn)(\\s+)([a-zA-Z_][a-zA-Z0-9_][\\w\\:,+ \\\'<>]*)(\\s*\\()' }, + { token: 'support.constant', regex: '\\b[a-zA-Z_][\\w\\d]*::' }, { token: 'keyword.source.rust', regex: '\\b(?:as|assert|break|claim|const|copy|Copy|do|drop|else|extern|fail|for|if|impl|in|let|log|loop|match|mod|module|move|mut|Owned|priv|pub|pure|ref|return|unchecked|unsafe|use|while|mod|Send|static|trait|class|struct|enum|type)\\b' }, { token: 'storage.type.source.rust', regex: '\\b(?:Self|m32|m64|m128|f80|f16|f128|int|uint|float|char|bool|u8|u16|u32|u64|f32|f64|i8|i16|i32|i64|str|option|either|c_float|c_double|c_void|FILE|fpos_t|DIR|dirent|c_char|c_schar|c_uchar|c_short|c_ushort|c_int|c_uint|c_long|c_ulong|size_t|ptrdiff_t|clock_t|time_t|c_longlong|c_ulonglong|intptr_t|uintptr_t|off_t|dev_t|ino_t|pid_t|mode_t|ssize_t)\\b' }, { token: 'variable.language.source.rust', regex: '\\bself\\b' }, + { token: 'keyword.operator', + regex: '!|\\$|\\*|\\-\\-|\\-|\\+\\+|\\+|-->|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|/=|%=|\\+=|\\-=|&=|\\^=|,|;' }, { token: 'constant.language.source.rust', regex: '\\b(?:true|false|Some|None|Left|Right|Ok|Err)\\b' }, { token: 'support.constant.source.rust',