From 8254bcc3acece6bf46e7e969cbc4ae35e5cffa2e Mon Sep 17 00:00:00 2001 From: marc hoffman Date: Fri, 8 Mar 2013 12:13:56 +0100 Subject: [PATCH] Oxygene language detection --- lib/linguist/languages.yml | 7 ++ samples/Oxygene/Loops.oxygene | 55 +++++++++++++++ samples/Oxygene/Program.pas | 125 ++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 samples/Oxygene/Loops.oxygene create mode 100644 samples/Oxygene/Program.pas diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 7df5032d..9d994d0a 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -923,6 +923,13 @@ OpenEdge ABL: - abl primary_extension: .p +Oxygene: + type: programming + color: "#5a63a3" + primary_extension: .pas + extensions: + - .oxygene + PHP: type: programming ace_mode: php diff --git a/samples/Oxygene/Loops.oxygene b/samples/Oxygene/Loops.oxygene new file mode 100644 index 00000000..427d86f5 --- /dev/null +++ b/samples/Oxygene/Loops.oxygene @@ -0,0 +1,55 @@ + + + Loops + exe + Loops + False + False + False + Properties\App.ico + Release + {916BD89C-B610-4CEE-9CAF-C515D88E2C94} + + + DEBUG;TRACE; + .\bin\Debug + True + True + + + .\bin\Release + False + + + + + $(Framework)\mscorlib.dll + + + $(Framework)\System.dll + + + $(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll + True + + + $(Framework)\System.Data.dll + + + $(Framework)\System.Xml.dll + + + + + + + + ResXFileCodeGenerator + + + + SettingsSingleFileGenerator + + + + \ No newline at end of file diff --git a/samples/Oxygene/Program.pas b/samples/Oxygene/Program.pas new file mode 100644 index 00000000..d5b45e8d --- /dev/null +++ b/samples/Oxygene/Program.pas @@ -0,0 +1,125 @@ +namespace Loops; + +interface + +uses System.Linq; + +type + ConsoleApp = class + public + class method Main; + method loopsTesting; + method fillData : sequence of Country; + var + Countries : sequence of Country; + end; + +type + Country = public class + public + property Name : String; + property Capital : String; + + constructor (setName : String; setCapital : String); + end; +implementation + +class method ConsoleApp.Main; +begin + Console.WriteLine('Loops example'); + Console.WriteLine(); + + with myConsoleApp := new ConsoleApp() do + myConsoleApp.loopsTesting; +end; + +method ConsoleApp.loopsTesting; +begin + {---------------------------------} + {"for" loop, taking every 5th item} + for i : Int32 :=0 to 50 step 5 do + begin + Console.Write(i); Console.Write(' '); + end; + + Console.WriteLine(); Console.WriteLine(); + + {---------------------------------} + {"for" loop, going from high to low value} + for i : Int32 := 10 downto 1 do + begin + Console.Write(i); Console.Write(' '); + end; + + Console.WriteLine(); Console.WriteLine(); + + Countries := fillData; + + {---------------------------------} + {loop with defined "index" variable, which will count from 0 through the number of elements looped} + Console.WriteLine('Countries: '); + for each c in Countries index num do + Console.WriteLine(Convert.ToString(num + 1) + ') ' + c.Name); + + Console.WriteLine(); + + Console.WriteLine('Cities: '); + var ind : Integer :=0; + + {---------------------------------} + {simple "loop" construct that loops endlessly, until broken out of} + loop + begin + Console.WriteLine(Countries.ElementAt(ind).Capital); + Inc(ind); + if ind = Countries.Count then break; + end; + + Console.WriteLine(); + + {---------------------------------} + {the type of 'c' is inferred automatically} + for each c in Countries do + Console.WriteLine(c.Capital + ' is the capital of ' + c.Name); + + Console.WriteLine(); + + ind := 0; + Console.WriteLine('Cities: '); + + {"repeat ... until" loop} + repeat + Console.WriteLine(Countries.ElementAt(ind).Capital); + Inc(ind); + until ind = Countries.Count; + + Console.WriteLine(); + + ind := 0; + Console.WriteLine('Countries: '); + + {---------------------------------} + {"while ... do" loop} + while ind < Countries.Count do + begin + Console.WriteLine(Countries.ElementAt(ind).Name); + Inc(ind); + end; + + Console.ReadLine(); +end; + +method ConsoleApp.fillData: sequence of Country; +begin + result := [new Country('UK', 'London'), new Country('USA', 'Washington'), new Country('Germany', 'Berlin'), + new Country('Ukraine', 'Kyiv'), new Country('Russia', 'Moscow'), new Country('France', 'Paris')]; + +end; + +constructor Country (setName :String; setCapital: String); +begin + Name := setName; + Capital := setCapital; +end; + +end. \ No newline at end of file