-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add language support for Simula #7025
base: main
Are you sure you want to change the base?
Changes from 4 commits
9596d2c
c72b594
8866963
9ad6c22
2f3e192
8695792
e7f3f44
395ca27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1635,6 +1635,7 @@ Dockerfile: | |
filenames: | ||
- Containerfile | ||
- Dockerfile | ||
- Dockerfile.sim | ||
ace_mode: dockerfile | ||
codemirror_mode: dockerfile | ||
codemirror_mime_type: text/x-dockerfile | ||
|
@@ -4204,6 +4205,7 @@ Makefile: | |
- Makefile.frag | ||
- Makefile.in | ||
- Makefile.inc | ||
- Makefile.sim | ||
- Makefile.wat | ||
- makefile | ||
- makefile.sco | ||
|
@@ -6821,6 +6823,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.simula | ||
eirslett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ace_mode: simula | ||
codemirror_mode: simula | ||
codemirror_mime_type: text/x-simula | ||
language_id: 582204041 | ||
Singularity: | ||
type: programming | ||
color: "#64E6AD" | ||
|
@@ -8245,6 +8259,7 @@ YAML: | |
- ".mir" | ||
- ".reek" | ||
- ".rviz" | ||
- ".sim" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a sample for this language if you're going to add this extension here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not 100 % what you meant - was this about the Simula language, or about the YAML fallback? I made 2 updates to the pull request:
It would be nice if linguist supported a "noop fallback" configuration, where - if we can't positively identify a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was referring to the YAML entry. You added it but didn't add a sample. I see you've now added samples but you've now also added samples that are too big. Please remove any that are suppressed in the diff and any that aren't real world uses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I removed the samples! |
||
- ".sublime-syntax" | ||
- ".syntax" | ||
- ".yaml" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need a test for this heuristic