diff --git a/.gitmodules b/.gitmodules index 860d03542a..ee7dad9366 100644 --- a/.gitmodules +++ b/.gitmodules @@ -561,3 +561,21 @@ [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 diff --git a/grammars.yml b/grammars.yml index 85d0612999..e9eddd7931 100644 --- a/grammars.yml +++ b/grammars.yml @@ -26,15 +26,21 @@ 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: @@ -42,6 +48,8 @@ vendor/grammars/IDL-Syntax: 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: @@ -408,6 +416,8 @@ vendor/grammars/standard-ml.tmbundle: - 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: @@ -419,6 +429,8 @@ vendor/grammars/sublime-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: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 4cbad8e846..c492ed3641 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -54,7 +54,7 @@ APL: extensions: - .apl - .dyalog - tm_scope: none + tm_scope: source.apl ace_mode: text ASP: @@ -414,7 +414,7 @@ CLIPS: type: programming extensions: - .clp - tm_scope: none + tm_scope: source.clips ace_mode: text CMake: @@ -623,7 +623,7 @@ Creole: wrap: true extensions: - .creole - tm_scope: none + tm_scope: text.html.creole ace_mode: text Crystal: @@ -976,7 +976,7 @@ GDScript: type: programming extensions: - .gd - tm_scope: none + tm_scope: source.gdscript ace_mode: text GLSL: @@ -1074,7 +1074,7 @@ Golo: color: "#f6a51f" extensions: - .golo - tm_scope: none + tm_scope: source.golo ace_mode: text Gosu: @@ -1376,7 +1376,7 @@ J: type: programming extensions: - .ijs - tm_scope: none + tm_scope: source.j ace_mode: text JSON: diff --git a/samples/CLIPS/demo.clp b/samples/CLIPS/demo.clp new file mode 100644 index 0000000000..45cb4828f2 --- /dev/null +++ b/samples/CLIPS/demo.clp @@ -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 "."))) diff --git a/samples/CLIPS/sudoku.clp b/samples/CLIPS/sudoku.clp new file mode 100644 index 0000000000..cbdbb92d9e --- /dev/null +++ b/samples/CLIPS/sudoku.clp @@ -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))) + + + + + + + + + + + + + + diff --git a/samples/J/stwij.ijs b/samples/J/stwij.ijs new file mode 100644 index 0000000000..453af90b50 --- /dev/null +++ b/samples/J/stwij.ijs @@ -0,0 +1,73 @@ +NB. From "Continuing to write in J". +NB. See http://www.jsoftware.com/help/jforc/continuing_to_write_in_j.htm + +empno=: 316 317 319 320 +payrate=: 60 42 44 54 +billrate=: 120 90 90 108 +clientlist=: 10011 10012 10025 +emp_client=: 10012 10025 10012 10025 +hoursworked=: 4 31 $ 8 0 3 10 9 8 8 9 4 0 8 7 10 10 12 9 0 6 8 9 9 9 0 0 10 11 9 7 10 2 0 8 0 0 9 9 8 9 10 0 0 8 8 10 7 10 0 0 7 8 9 8 9 0 4 9 8 9 8 9 0 0 5 0 0 8 9 9 9 9 0 0 8 7 0 0 9 0 2 10 10 9 11 8 0 0 8 9 10 8 9 0 0 9 0 0 9 10 8 6 6 8 0 9 8 10 6 9 7 0 6 8 8 8 9 0 5 8 9 8 8 12 0 0 + +NB. Finds the number of hours each employee worked in the given month. +emphours=: 3 : '+/"1 hoursworked' + +NB. Determines the wages earned by each employee in the given month. +empearnings=: 3 : 'payrate * +/"1 hoursworked' + +NB. Determines the profit brought in by each employee. +empprofit=: 3 : 0 +(billrate - payrate) * +/"1 hoursworked +) + +NB. Returns the amount to bill a given client. +billclient=: 3 : 0 +mask=. emp_client = y ++/ (mask # billrate) * +/"1 mask # hoursworked +) + +NB. Finds for each day of the month the employee who billed the most hours. +dailydrudge=: 3 : 0 +((|: hoursworked) i."1 0 >./ hoursworked) { empno +) + +NB. Returns the employees, in descending order of the profit brought in by each. +producers=: 3 : 'empno \: empprofit 0' + +NB. Returns the clients, in descending order of the profit generated by each. +custbyprofit=: 3 : 0 +clientlist \: +/ (clientlist ="1 0 emp_client) * empprofit 0 +) + +NB. Calculates withholding tax on each employee's earnings. +renderuntocaesar=: 3 : 0 +bktmin=. 0 6000 10000 20000 NB. Four brackets, 0..6000..10000..20000.._ +bktrate=. 0.05 0.10 0.20 0.30 +bktearns=. 0 >. ((1 |.!._ bktmin) <."1 0 empearnings'') -"1 bktmin ++/"1 bktrate *"1 bktearns +) + +NB. Main + +echo 'Problem 1' +echo emphours'' + +echo 'Problem 2' +echo empearnings'' + +echo 'Problem 3' +echo empprofit'' + +echo 'Problem 4' +echo billclient 10025 + +echo 'Problem 5' +echo dailydrudge'' + +echo 'Problem 6' +echo producers'' + +echo 'Problem 7' +echo custbyprofit'' + +echo 'Problem 8' +echo 0j2 ": renderuntocaesar'' diff --git a/vendor/grammars/CLIPS-sublime b/vendor/grammars/CLIPS-sublime new file mode 160000 index 0000000000..f6904baa78 --- /dev/null +++ b/vendor/grammars/CLIPS-sublime @@ -0,0 +1 @@ +Subproject commit f6904baa78b8b918a7815f4f467fe0ab51c38972 diff --git a/vendor/grammars/Creole b/vendor/grammars/Creole new file mode 160000 index 0000000000..bac4656c8d --- /dev/null +++ b/vendor/grammars/Creole @@ -0,0 +1 @@ +Subproject commit bac4656c8d2a000d6c5940a3d3798a856e44396f diff --git a/vendor/grammars/GDScript-sublime b/vendor/grammars/GDScript-sublime new file mode 160000 index 0000000000..99a0d51224 --- /dev/null +++ b/vendor/grammars/GDScript-sublime @@ -0,0 +1 @@ +Subproject commit 99a0d512248fb85741b00d9d702cf97797de9a4c diff --git a/vendor/grammars/JSyntax b/vendor/grammars/JSyntax new file mode 160000 index 0000000000..74971149b5 --- /dev/null +++ b/vendor/grammars/JSyntax @@ -0,0 +1 @@ +Subproject commit 74971149b5926f800b8eb157925a1670a57846b4 diff --git a/vendor/grammars/sublime-apl b/vendor/grammars/sublime-apl new file mode 160000 index 0000000000..a8c36775d5 --- /dev/null +++ b/vendor/grammars/sublime-apl @@ -0,0 +1 @@ +Subproject commit a8c36775d58c9a80f3b7f572cb4fac5976a6af99 diff --git a/vendor/grammars/sublime-golo b/vendor/grammars/sublime-golo new file mode 160000 index 0000000000..2c0707bd4f --- /dev/null +++ b/vendor/grammars/sublime-golo @@ -0,0 +1 @@ +Subproject commit 2c0707bd4fb11ec354d552bfbc6c8c5febdfd1ad