Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,9 @@
[submodule "vendor/grammars/shaders-tmLanguage"]
path = vendor/grammars/shaders-tmLanguage
url = https://github.com/tgjones/shaders-tmLanguage
[submodule "vendor/grammars/simula-tmlanguage"]
path = vendor/grammars/simula-tmlanguage
url = https://github.com/RobertFlexx/simula-tmlanguage.git
[submodule "vendor/grammars/slang-vscode-extension"]
path = vendor/grammars/slang-vscode-extension
url = https://github.com/shader-slang/slang-vscode-extension.git
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,8 @@ vendor/grammars/selinux-policy-languages:
vendor/grammars/shaders-tmLanguage:
- source.hlsl
- source.shaderlab
vendor/grammars/simula-tmlanguage:
- source.simula
vendor/grammars/slang-vscode-extension:
- source.slang
vendor/grammars/slint-tmLanguage:
Expand Down
1 change: 1 addition & 0 deletions lib/linguist/generic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extensions:
- ".msg"
- ".network"
- ".resource"
- ".sim"
- ".sol"
- ".srv"
- ".stl"
Expand Down
29 changes: 29 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,35 @@ disambiguations:
- '\(#[\w-]+[!\?]'
- '(?:[\)\]]\s*[\*\+\?](?:\s|$))'
- '@[\w.-]+(?:\)\s|$)'
- extensions: ['.sim']
rules:
- language: Simula
pattern: '(?i)\b(?:simulation[ \t]+begin|(?:process|task)\s+class)\b'
- language: Simula
and:
- pattern: '(?i)\bprogram\s+[A-Za-z]\w*\s*;\s*begin\b'
- pattern: '(?i)\b(?:switch\s+[A-Za-z]\w*\s*:=|go\s+to\b|ref\s*\(|qua\b|outtext\b|outint\b|outimage\b|outchar\b|inint\b|inimage\b|inchar\b|intext\b|inspect\b|detach\b|passivate\b|reactivate\b|activate\b|virtual\s*:|:-|(?:integer|real|boolean|character|text)\s+(?:procedure|function)\b|array\s*\[[^\]\r\n]*:|for\s+[A-Za-z]\w*\s*:=[^\r\n;]{0,120}\bstep\b)'
- language: Simula
pattern: '(?i)\bclass\s+[A-Za-z]\w*(?:\s*\([^\)\r\n]*\))?\s*;[\s\S]{0,500}\bbegin\b'
- language: Simula
and:
- pattern: '(?i)\bref\s*\(\s*[A-Za-z]\w*\s*\)'
- pattern: '(?i)(?::-|\bqua\b|\bnew\s+[A-Za-z])'
- language: Simula
and:
- pattern: '(?i)\binspect\b'
- pattern: '(?i)\bwhen\b'
- pattern: '(?i)\botherwise\b'
- language: Simula
and:
- pattern: '(?i)\bactivate\b'
- pattern: '(?i)\b(?:hold\s*\(|passivate\b)'
- pattern: '(?i)\bnew\s+[A-Za-z]\w*'
- language: Simula
and:
- pattern: '(?i)\bbegin\b'
- pattern: '(?i)\bfor\s+[A-Za-z]\w*\s*:=[\s\S]{0,120}\bstep\b[\s\S]{0,120}\buntil\b[\s\S]{0,120}\bdo\b'
- pattern: '(?i)\bend\b\s*[.;]'
- extensions: ['.sol']
rules:
- language: Solidity
Expand Down
11 changes: 11 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7542,6 +7542,17 @@ Simple File Verification:
codemirror_mode: properties
codemirror_mime_type: text/x-properties
language_id: 735623761
Simula:
type: programming
color: "#4F78A8"
aliases:
- simula67
- simula-67
extensions:
- ".sim"
tm_scope: source.simula
ace_mode: text
language_id: 582204041
Singularity:
type: programming
color: "#64E6AD"
Expand Down
16 changes: 16 additions & 0 deletions samples/Simula/arrays.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
program Arrays;
begin
array[1:5] integer values;
integer index;
integer total;
total := 0;
for index := 1 step 1 until 5 do
begin
values[index] := index * index;
total := total + values[index];
end;
assert(total = 55);
outint(total);
outimage;
exit(0)
end;
29 changes: 29 additions & 0 deletions samples/Simula/classes.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Class Animal;
Virtual: Procedure Speak Is Procedure Speak;;
begin
Protected:
integer age;
Public:
Procedure Speak;
begin
outtext("animal")
end;
end;

Animal Class Dog;
begin
Public:
Procedure Speak;
begin
outtext("dog")
end;
end;

program Classes;
begin
Ref(Animal) subject;
subject :- new Dog();
subject.Speak();
outimage;
exit(0)
end;
70 changes: 70 additions & 0 deletions samples/Simula/ferry.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
! Ferry queue, a classic Simula 67 simulation;
! Modeled on the toll-bridge examples of the Simula 67
! Common Base Language report and of Simula Begin;
Simulation Begin
Ref(Head) Waiting;
Integer NArrivals, NServed;

Process Class Vehicle;
Begin
Boolean TollPaid;
Procedure Pay;
Begin
TollPaid := True
End;
Hold(10);
Inner;
Passivate
End;

Vehicle Class Car;
Begin
Integer Passengers
End;

Vehicle Class Lorry;
Begin
Integer CargoTons
End;

Process Class Arrivals;
Begin
Ref(Vehicle) V;
NewArrival:
If NArrivals < 6 Then
Begin
If Mod(NArrivals, 3) = 0 Then V:-New Lorry
Else V:-New Car;
V.Into(Waiting);
NArrivals := NArrivals + 1;
Hold(12);
Goto NewArrival
End;
Passivate
End;

Process Class Ferryman;
Begin
Ref(Vehicle) V;
While Not Waiting.Empty Do
Begin
V:-Waiting.First;
V.Out;
V.Pay;
Inspect V
When Car Do OutText("car")
Otherwise OutText("lorry");
OutImage;
NServed := NServed + 1;
Hold(5)
End;
Passivate
End;

comment Initially the queue is empty, so only the
generator process is active when the
simulation run starts.;
Waiting:-New Head;
Activate New Arrivals At Time + 1;
Activate New Ferryman Delay 1
End
19 changes: 19 additions & 0 deletions samples/Simula/inspect.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class Animal;
begin
integer age;
end;

Animal Class Dog;
begin
integer barkCount;
end;

program ClassicInspect;
begin
Ref(Animal) subject;
subject :- new Dog();
inspect subject
when Dog do begin outtext("dog") end
when Animal do begin outtext("animal") end
otherwise begin outtext("none") end
end;
11 changes: 11 additions & 0 deletions samples/Simula/labels.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
label Start, Finished;
switch Dispatch := Start, Finished;

program ClassicLabels;
begin
integer value;
value := 0;
go to Start;
Finished: value := value + 1;
Start: if value = 0 then go to Finished
end;
24 changes: 24 additions & 0 deletions samples/Simula/modern.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Task Class PipelineStage;
Virtual: Procedure Run Is Procedure Run;;
begin
Public:
channel(integer) input_values;
channel(integer) output_values;
Procedure Run;
begin
integer value;
value := receive(input_values);
send(output_values, value + 1)
end;
end;

program TaskPipeline;
begin
Ref(PipelineStage) stage;
integer result;
stage :- new PipelineStage();
send(stage.input_values, 41);
join spawn stage.Run();
result := receive(stage.output_values);
assert(result = 42)
end;
19 changes: 19 additions & 0 deletions samples/Simula/prefixing.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class PrefixPart;
begin
outtext("A");
inner;
outtext("C")
end;

PrefixPart Class CompletePart;
begin
outtext("B")
end;

program PrefixInner;
begin
Ref(CompletePart) item;
item :- new CompletePart();
outimage;
exit(0)
end;
14 changes: 14 additions & 0 deletions samples/Simula/procedures.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
integer procedure Accumulate(seed, amount);
value amount;
integer seed, amount;
begin
seed := seed + amount;
Accumulate := seed
end;

program ProcedureParameterModes;
begin
integer total;
total := 40;
total := Accumulate(total, 2)
end;
94 changes: 94 additions & 0 deletions samples/Simula/simset.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
! simset.sim from GNU CIM 5.1, lib/simset.sim;
! Copyright (C) 1994 Sverre Hvammen Johansen,
! Department of Informatics, University of Oslo;
! Licensed under the GNU General Public License version 2;
CLASS SIMSET;
BEGIN

CLASS LINKAGE;
BEGIN REF(LINKAGE)zzsuc,zzpred;

REF(LINK) PROCEDURE SUC;
SUC:- IF zzsuc IN LINK THEN zzsuc ELSE NONE;

REF(LINK) PROCEDURE PRED;
PRED:- IF zzpred IN LINK THEN zzpred ELSE NONE;

REF(LINKAGE) PROCEDURE PREV; PREV:-zzpred;

END LINKAGE;


LINKAGE CLASS LINK;
BEGIN

PROCEDURE OUT;
IF zzsuc=/=NONE THEN BEGIN
zzsuc.zzpred:-zzpred;
zzpred.zzsuc:-zzsuc;
zzsuc:-zzpred:-NONE;
END OUT;

PROCEDURE FOLLOW(PTR); REF(LINKAGE)PTR;
BEGIN OUT;
IF PTR=/=NONE AND THEN PTR.zzsuc=/=NONE THEN BEGIN
zzpred:-PTR;
zzsuc:-PTR.zzsuc;
zzsuc.zzpred:-PTR.zzsuc:-THIS LINKAGE END
END FOLLOW;

PROCEDURE PRECEDE(PTR); REF(LINKAGE)PTR;
BEGIN OUT;
IF PTR=/=NONE AND THEN PTR.zzpred=/=NONE THEN BEGIN
zzsuc:-PTR;
zzpred:-PTR.zzpred;
zzpred.zzsuc:-PTR.zzpred:-THIS LINKAGE END
END PRECEDE;

PROCEDURE INTO(S); REF(HEAD)S; PRECEDE(S);

END LINK;


LINKAGE CLASS HEAD;
BEGIN

REF(LINK) PROCEDURE FIRST;
!FIRST:-SUC;
FIRST:- IF zzsuc IN LINK THEN zzsuc ELSE NONE;

REF(LINK) PROCEDURE LAST;
!LAST:-PRED;
LAST:- IF zzpred IN LINK THEN zzpred ELSE NONE;

BOOLEAN PROCEDURE EMPTY; EMPTY:= zzsuc==THIS LINKAGE;

INTEGER PROCEDURE CARDINAL;
BEGIN INTEGER I;
REF(LINKAGE) PTR;
PTR:-zzsuc;
WHILE PTR =/= THIS LINKAGE DO BEGIN
I:=I+1;
PTR:-PTR.zzsuc;
END WHILE;

CARDINAL:=I
END CARDINAL;

PROCEDURE CLEAR;
BEGIN
REF(LINKAGE) PTR,PTRSUC;
PTR:-zzsuc;
WHILE PTR =/= THIS LINKAGE DO
BEGIN
PTRSUC:-PTR.zzsuc;
PTR.zzsuc:-PTR.zzpred:-NONE;
PTR:-PTRSUC;
END;
zzsuc:-zzpred:-THIS LINKAGE
END;

zzsuc:-zzpred:-THIS LINKAGE
END HEAD;

END SIMSET;
Loading