diff --git a/.gitmodules b/.gitmodules index 65d5ef54e..703422cc0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1392,6 +1392,9 @@ [submodule "vendor/grammars/vscode-scala-syntax"] path = vendor/grammars/vscode-scala-syntax url = https://github.com/scala/vscode-scala-syntax +[submodule "vendor/grammars/vscode-simula"] + path = vendor/grammars/vscode-simula + url = https://github.com/eirslett/vscode-simula.git [submodule "vendor/grammars/vscode-singularity"] path = vendor/grammars/vscode-singularity url = https://github.com/onnovalkering/vscode-singularity diff --git a/grammars.yml b/grammars.yml index 219734dcf..b2e18507b 100644 --- a/grammars.yml +++ b/grammars.yml @@ -1253,6 +1253,8 @@ vendor/grammars/vscode-ron: - source.ron vendor/grammars/vscode-scala-syntax: - source.scala +vendor/grammars/vscode-simula: +- source.sim vendor/grammars/vscode-singularity: - source.singularity vendor/grammars/vscode-slice: diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index 923303e6d..6e7dfe770 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -709,6 +709,12 @@ disambiguations: - language: Markdown # Markdown syntax for scdoc pattern: '^#+\s+(NAME|SYNOPSIS|DESCRIPTION)' +- extensions: ['.sim'] + rules: + - language: Simula + pattern: '(?i)\bbegin\b.*?\bend\b' + - language: YAML + pattern: '^[\{\[]' - extensions: ['.sol'] rules: - language: Solidity diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index b5eebfe28..d80ddd9e5 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1636,6 +1636,7 @@ Dockerfile: filenames: - Containerfile - Dockerfile + - Dockerfile.sim ace_mode: dockerfile codemirror_mode: dockerfile codemirror_mime_type: text/x-dockerfile @@ -4218,6 +4219,7 @@ Makefile: - Makefile.frag - Makefile.in - Makefile.inc + - Makefile.sim - Makefile.wat - makefile - makefile.sco @@ -6864,6 +6866,18 @@ Simple File Verification: codemirror_mode: properties codemirror_mime_type: text/x-properties language_id: 735623761 +Simula: + type: programming + color: "#B22F2F" + extensions: + - ".sim" + aliases: + - sim + tm_scope: source.sim + ace_mode: simula + codemirror_mode: simula + codemirror_mime_type: text/x-simula + language_id: 582204041 Singularity: type: programming color: "#64E6AD" @@ -8317,6 +8331,7 @@ YAML: - ".mir" - ".reek" - ".rviz" + - ".sim" - ".sublime-syntax" - ".syntax" - ".yaml" diff --git a/samples/Simula/BottlesOfBeer.sim b/samples/Simula/BottlesOfBeer.sim new file mode 100644 index 000000000..13d15325f --- /dev/null +++ b/samples/Simula/BottlesOfBeer.sim @@ -0,0 +1,17 @@ +! License: MIT; +begin + integer i; + for i := 99 step -1 until 1 do + begin + outint(i, 2); + outtext(" bottles of beer on the wall, "); + outint(i, 2); + outtext(" bottles of beer."); + outimage; + outtext("Take one down and pass it around, "); + outint(i - 1, 2); + outtext(" bottles of beer on the wall."); + outimage; + end; + outtext("No more bottles of beer on the wall, no more bottles of beer."); +end-let's-drink; diff --git a/samples/Simula/TicTacToe.sim b/samples/Simula/TicTacToe.sim new file mode 100644 index 000000000..6de5d0b67 --- /dev/null +++ b/samples/Simula/TicTacToe.sim @@ -0,0 +1,108 @@ +! A simple Tic-Tac-Toe game. License: MIT; +begin + ref(TicTacToe) game; + character player; + + class TicTacToe; + begin + character array board(1:9); + + procedure placeMark(mark, position); + value mark, position; + character mark; integer position; + begin + board(position) := mark; + end-of-place-mark; + + boolean procedure checkWinner(player); + value player; + character player; + begin + integer position; + comment + There are 8 possible ways to win: 3 rows, 3 columns, and 2 diagonals. + For reasons of laziness, we just AI-generate them: + ; + if board(1) = player and board(2) = player and board(3) = player then + checkWinner := true + else if board(4) = player and board(5) = player and board(6) = player then + checkWinner := true + else if board(7) = player and board(8) = player and board(9) = player then + checkWinner := true + else if board(1) = player and board(4) = player and board(7) = player then + checkWinner := true + else if board(2) = player and board(5) = player and board(8) = player then + checkWinner := true + else if board(3) = player and board(6) = player and board(9) = player then + checkWinner := true + else if board(1) = player and board(5) = player and board(9) = player then + checkWinner := true + else if board(3) = player and board(5) = player and board(7) = player then + checkWinner := true + else + checkWinner := false; + end-of-checkWinner; + + character procedure winner; + begin + if checkWinner('X') then winner := 'X' + else if checkWinner('O') then winner := 'O' + else winner := ' '; + end-of-winner; + + procedure DrawTopBottom; begin + OutText("+---+---+---+"); + OutImage; + end; + + procedure draw; + begin + integer row; + OutImage; + DrawTopBottom; + for row := 0 step 1 until 2 do begin + OutText("| " ); + OutChar(board(row * 3 + 1)); + OutText(" | " ); + OutChar(board(row * 3 + 2)); + OutText(" | " ); + OutChar(board(row * 3 + 3)); + OutText(" |"); + OutImage; + DrawTopBottom; + end + end-of-draw; + + !populate the board with number placeholders; + board(1) := '1'; + board(2) := '2'; + board(3) := '3'; + board(4) := '4'; + board(5) := '5'; + board(6) := '6'; + board(7) := '7'; + board(8) := '8'; + board(9) := '9'; + end-of-TicTacToe; + + + game :- new TicTacToe; + player := 'X'; + + while game.winner <> 'X' and game.winner <> 'O' do + begin + game.draw; + OutText("Player "); + OutChar(player); + OutText(" enter position: "); + OutImage; + game.placeMark(player, InInt); + if player = 'X' then player := 'O' else player := 'X'; + end; + + game.draw; + + OutText("The winner is: player "); + OutChar(game.winner); + OutImage; +end-of-program diff --git a/samples/Simula/klant1.sim b/samples/Simula/klant1.sim new file mode 100644 index 000000000..029519bfc --- /dev/null +++ b/samples/Simula/klant1.sim @@ -0,0 +1,29 @@ +comment License: program borrowed from S-PORT https://github.com/portablesimula/S-PORT; +begin +! klant 1 +beschrijving van een winkel +copyright H.G.Sol; + +external class Demos; + +Demos begin + Entity class Klant; + begin + Bediendes.Acquire(1); + Hold(5); + Bediendes.Release(1); + Kassieres.Acquire(1); + Hold(2); + Kassieres.Release(1); + end; + ref(Res) Bediendes,Kassieres; + Bediendes:- new Res("bediendes",2); + Kassieres:- new Res("kassieres",1); + Trace; + new Klant("klant").Schedule(1); + new Klant("klant").Schedule(2); + new Klant("klant").Schedule(5); + new Klant("klant").Schedule(6); + Hold(40); +end; +end; \ No newline at end of file diff --git a/samples/Simula/klant4.sim b/samples/Simula/klant4.sim new file mode 100644 index 000000000..a2a31acdb --- /dev/null +++ b/samples/Simula/klant4.sim @@ -0,0 +1,67 @@ +comment License: program borrowed from S-PORT https://github.com/portablesimula/S-PORT; +begin +external class demos; +! klant 4 +zelfbediening en artikelvoorraad +copyright H.G.Sol; +Demos begin + Entity class Klant; + begin + Karren.Acquire(1); + Bier.Take(Hoevelheid.Sample); + Hold(Paktijd.Sample); + if Vragen.Sample then + begin + Bediendes.Acquire(1); + Hold(Helptijd.Sample); + Bediendes.Release(1); + end; + Kassieres.Acquire(1); + Hold(Betaaltijd.Sample); + Kassieres.Release(1); + Karren.Release(1); + end; + + Entity class Bierleverantie(Frequentie); + real Frequentie; + begin + if Bier.Avail < 100 then + Bier.Give(300); + Hold(1/Frequentie); + Repeat; + end; + + Entity class Klantengenerator(Tussentijd); + ref(Rdist)Tussentijd; + begin + new Klant("klant").Schedule(0); + Hold(Tussentijd.Sample); + Repeat; + end; + + ref(Res) Karren,Bediendes,Kassieres; + ref(Bin) Bier; + ref(Rdist) Paktijd,Helptijd, Betaaltijd, Tussentijd; + ref(Idist) Hoevelheid; + ref(Bdist) Vragen; + + trace; + + Karren:- new Res("karren",10); + Bediendes:- new Res("bediendes",2); + Kassieres:- new Res("kassieres",2); + Bier:- new Bin("bier",150); + Tussentijd:- new Negexp("tt",.5); + Paktijd:- new Normal("pt",5,.5); + Helptijd:- new Normal("ht",2,.5); + Betaaltijd:- new Negexp("bt",.5); + Hoevelheid:- new Randint("hv",1,12); + Vragen:- new Draw("vr",.3); + + Hold(9*60); + Reset; + new Bierleverantie("bl",1/40).Schedule(30); + new Klantengenerator("kg",Tussentijd).Schedule(0); + Hold(18*60 - 9*60); +end; +end; diff --git a/samples/Simula/powers.sim b/samples/Simula/powers.sim new file mode 100644 index 000000000..bcbc95ee7 --- /dev/null +++ b/samples/Simula/powers.sim @@ -0,0 +1,91 @@ +comment License: program borrowed from S-PORT https://github.com/portablesimula/S-PORT; +begin +comment this program computes the "best" powers of ten re U1100; +integer lower, upper, minlim, ee, pp; + +procedure outpower(exp_param,power_param); name exp_param; +integer exp_param,power_param; +begin + integer exp, power; + integer array digits(lower:upper); + integer max,min,digit; + +procedure divide(exp); integer exp; +begin integer i, rem; +while exp>0 do begin + exp := exp-1; rem := 0; + i := max+1; + while i>min do begin + i := i-1; + digit := digits(i)//2; + if digits(i)-2*digit>0 then digits(i-1):=digits(i-1)+10; + digits(i):=digit; + end; + if digits(min-1)>0 then begin + min := min-1; digits(min) := 5; + end; + if digits(max)=0 then max:=max-1; +end while; +if max<>0 then begin exp_param:=exp_param+1; goto RETRY end; +end divide; + +procedure output; +begin integer i, j, first, last, carry, borrow; +! the number to be output is in digits(min:max); + last := min; + first := max+1; + while first>min do begin + first := first-1; + carry:=borrow:=0; + i := last-1; + while i10 then begin carry:=1; digit:=digit-10 end + else carry:=0; + digit:=digits(i-1)-digit-borrow; + if digit<0 then begin borrow:=1; digit:=digit+10 end + else borrow:=0; + digits(i-1):=digit; + end; + digits(first) := digits(first)-borrow-carry; + if digits(last)<>0 then last:=last-1; + end first; + if digits(0)<4 then begin exp_param:=exp_param-1; goto RETRY end; + if digits(-20)=7 + then begin + outint(exp_param,4); outint(power_param,4); outchar(':'); + for i:= -20 step -1 until -22 do outchar(char(rank('0')+digits(i))); + outimage; + end + else if digits(-20)=0 + then begin + outint(exp_param,4); outint(power_param,4); outchar(':'); + for i:= -20 step -1 until -22 do outchar(char(rank('0')+digits(i))); + outimage; + end if; +end output; + +RETRY: ! here when the exponent has been corrected; + exp := exp_param; power := power_param; + max:= power+1; !one sign. digit only; + min:= max; !one sign. digit only; + digits(max):=1; + divide(exp); + output; +end outpower; + +!outtext("51634306575354226427"); ! outimage; +!outpower(665,200); +!outpower(608,183); ! 75 - denne er best; +!outtext("44446551131230337166"); ! outimage; +!outpower(326,098); ! 74 - denne er best; +!outtext("42154166127714446321"); outimage; +!outpower(167,050); ! 76 - denne er best; + +ee := 1026; pp := 308; +while pp>0 do +begin upper := pp; lower := -3.4*upper; + ee := ee-3; pp := pp-1; outpower(ee,pp) end; + +end; \ No newline at end of file diff --git a/samples/YAML/filenames/something.sim b/samples/YAML/filenames/something.sim new file mode 100644 index 000000000..484709f20 --- /dev/null +++ b/samples/YAML/filenames/something.sim @@ -0,0 +1,218 @@ +{ + "version": "1.8.1", + "globalBitSize": 1, + "clockSpeed": 1, + "circuits": [ + { + "name": "xor", + "components": [ + { + "name": "com.ra4king.circuitsim.gui.peers.gates.NotGatePeer", + "x": 23, + "y": 9, + "properties": { + "Label location": "NORTH", + "Negate 0": "No", + "Label": "", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.gates.NotGatePeer", + "x": 23, + "y": 18, + "properties": { + "Label location": "NORTH", + "Negate 0": "No", + "Label": "", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.gates.AndGatePeer", + "x": 26, + "y": 9, + "properties": { + "Negate 1": "No", + "Label location": "NORTH", + "Negate 0": "No", + "Number of Inputs": "2", + "Label": "", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.gates.AndGatePeer", + "x": 26, + "y": 16, + "properties": { + "Negate 1": "No", + "Label location": "NORTH", + "Negate 0": "No", + "Number of Inputs": "2", + "Label": "", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.gates.OrGatePeer", + "x": 34, + "y": 12, + "properties": { + "Negate 1": "No", + "Label location": "NORTH", + "Negate 0": "No", + "Number of Inputs": "2", + "Label": "", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.wiring.PinPeer", + "x": 13, + "y": 10, + "properties": { + "Label location": "WEST", + "Label": "a", + "Is input?": "Yes", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.wiring.PinPeer", + "x": 13, + "y": 17, + "properties": { + "Label location": "WEST", + "Label": "b", + "Is input?": "Yes", + "Direction": "EAST", + "Bitsize": "1" + } + }, + { + "name": "com.ra4king.circuitsim.gui.peers.wiring.PinPeer", + "x": 44, + "y": 13, + "properties": { + "Label location": "EAST", + "Label": "c", + "Is input?": "No", + "Direction": "WEST", + "Bitsize": "1" + } + } + ], + "wires": [ + { + "x": 15, + "y": 11, + "length": 2, + "isHorizontal": true + }, + { + "x": 15, + "y": 18, + "length": 3, + "isHorizontal": true + }, + { + "x": 17, + "y": 10, + "length": 1, + "isHorizontal": false + }, + { + "x": 17, + "y": 10, + "length": 6, + "isHorizontal": true + }, + { + "x": 17, + "y": 11, + "length": 6, + "isHorizontal": false + }, + { + "x": 17, + "y": 17, + "length": 9, + "isHorizontal": true + }, + { + "x": 18, + "y": 12, + "length": 6, + "isHorizontal": false + }, + { + "x": 18, + "y": 12, + "length": 8, + "isHorizontal": true + }, + { + "x": 18, + "y": 18, + "length": 1, + "isHorizontal": false + }, + { + "x": 18, + "y": 19, + "length": 5, + "isHorizontal": true + }, + { + "x": 30, + "y": 11, + "length": 1, + "isHorizontal": true + }, + { + "x": 30, + "y": 18, + "length": 1, + "isHorizontal": true + }, + { + "x": 31, + "y": 11, + "length": 2, + "isHorizontal": false + }, + { + "x": 31, + "y": 13, + "length": 3, + "isHorizontal": true + }, + { + "x": 31, + "y": 15, + "length": 3, + "isHorizontal": true + }, + { + "x": 31, + "y": 15, + "length": 3, + "isHorizontal": false + }, + { + "x": 38, + "y": 14, + "length": 6, + "isHorizontal": true + } + ] + } + ] +} \ No newline at end of file diff --git a/vendor/grammars/vscode-simula b/vendor/grammars/vscode-simula new file mode 160000 index 000000000..3e5aa76da --- /dev/null +++ b/vendor/grammars/vscode-simula @@ -0,0 +1 @@ +Subproject commit 3e5aa76da7f6c4145b665fa7497249b2353ea087 diff --git a/vendor/licenses/git_submodule/vscode-simula.dep.yml b/vendor/licenses/git_submodule/vscode-simula.dep.yml new file mode 100644 index 000000000..47342717c --- /dev/null +++ b/vendor/licenses/git_submodule/vscode-simula.dep.yml @@ -0,0 +1,17 @@ +--- +name: vscode-simula +version: 3e5aa76da7f6c4145b665fa7497249b2353ea087 +type: git_submodule +homepage: https://github.com/eirslett/vscode-simula.git +license: mit +licenses: +- sources: LICENSE.md + text: | + Copyright 2024 Project contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +notices: []