Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f7ef9a0
update submodule and packages
tonitrus888 Apr 2, 2025
bc67073
update packages and remove unused typir package
tonitrus888 Apr 3, 2025
956f3f1
add typir minimal setup
tonitrus888 Apr 3, 2025
2c2aec4
install typir dependency
tonitrus888 Apr 3, 2025
ece8c4d
Update recipe submodule
lou1306 Apr 11, 2025
7f0c98a
Merge branch 'master' into type-checking
lou1306 Apr 11, 2025
13a4175
add primitive types bool, int, location
tonitrus888 Apr 26, 2025
e115daa
add user defined enum types (not working)
tonitrus888 May 5, 2025
c2279f3
add debugging messages and try checking for duplicate primitives
tonitrus888 May 6, 2025
c4e96c0
fix enum definitions and update equality/inequality operator to work …
tonitrus888 May 7, 2025
70f4ef0
add inference rules for chan and * keywords, type-check relabels, and…
tonitrus888 May 8, 2025
458984b
updates to enums and initial agent definition
tonitrus888 May 15, 2025
507ccab
prevent document-scoped names from leaking into global scope and add …
tonitrus888 May 15, 2025
790c9f1
add guard parameter validation and return type
tonitrus888 May 16, 2025
a61d6ec
add automaton-state and process names as agent members
tonitrus888 May 16, 2025
605c813
add rudimentary range type and type conversions between (agent -> loc…
tonitrus888 May 16, 2025
7e15430
update language feature names to simplify unary operator definitions …
tonitrus888 May 17, 2025
c43fffe
add unary and binary operators, add validation rule for 'Ltol', and f…
tonitrus888 May 17, 2025
2dab65f
remove subtype relations, simplify code, add remaining obs operators
tonitrus888 May 22, 2025
857ac79
add inference rule for LtolQuant
tonitrus888 May 24, 2025
590eee9
Merge branch 'master' into type-checking
tonitrus888 May 29, 2025
068d574
add range type, update operators for range and int, add custom range …
tonitrus888 May 29, 2025
6a48d0c
add IntRange class and use in custom comparison validation
tonitrus888 May 30, 2025
34503ac
fix language server crashing for duplicates
tonitrus888 May 31, 2025
108e897
add range check to assignments, update existing range checks
tonitrus888 May 31, 2025
e6797fa
add validation rules to agent and commands (process)
tonitrus888 Jun 2, 2025
4739c74
fix example files
tonitrus888 Jun 4, 2025
7e6ba3d
move utility functions and classes to separate file
tonitrus888 Jun 4, 2025
aff163f
Merge branch 'master' into type-checking
tonitrus888 Jun 5, 2025
5277625
fix langium version
tonitrus888 Jun 5, 2025
5069bc4
update Makefile to prevent package-lock.json conflicts and build erro…
tonitrus888 Jun 5, 2025
88db7b0
add validation to guard body and update validation rule for GET
tonitrus888 Jun 5, 2025
b10419d
Add vsce dev dependency, fix Makefile
lou1306 Jun 18, 2025
aca7126
various fixes, add empty type checking examples
tonitrus888 Jun 22, 2025
468f8db
Update recipe submodule
lou1306 Jun 26, 2025
8bfd9e9
Merge remote-tracking branch 'origin/type-checking' into type-checking
lou1306 Jun 26, 2025
3f63854
reformat type checker file
tonitrus888 Jun 28, 2025
594fb13
remove todos
tonitrus888 Jul 2, 2025
bbc3ee7
add range arithmetics to all comparison operators
tonitrus888 Jul 5, 2025
a5e65e4
Merge branch 'master' into type-checking
tonitrus888 Jul 5, 2025
261d4d0
Merge branch 'master' into type-checking
lou1306 Jul 11, 2025
5cef417
GetterObs nodes type to bool
lou1306 Jul 11, 2025
1cbbabb
Merge branch 'master' into type-checking
lou1306 Aug 18, 2025
3e041e2
Fix Typir dependency
lou1306 Aug 18, 2025
f63c1bf
Organise imports
lou1306 Aug 18, 2025
a91eeeb
Split Assign into UpdateAssign, MessageAssign
lou1306 Aug 19, 2025
4d7e33d
Remove Local from primitive type creation
lou1306 Aug 19, 2025
095f92d
refactor validateAssignment()
lou1306 Aug 18, 2025
0f0180c
Fix type inference of local variables
lou1306 Aug 19, 2025
ca36c06
Fix resolution of custom enums
lou1306 Aug 20, 2025
3f9c5a5
Remove eslint dependency
lou1306 Aug 20, 2025
202a6f8
Update package.json
lou1306 Aug 20, 2025
eeca420
Update package.json
lou1306 Aug 21, 2025
a13f28e
Restore support for process labels in LTOL
lou1306 Aug 21, 2025
a77f63b
Update recipe submodule
lou1306 Aug 21, 2025
2273b38
Update package-lock.json
lou1306 Sep 25, 2025
a173fb1
Merge branch 'master' into type-checking
lou1306 Sep 25, 2025
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
13 changes: 0 additions & 13 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/bigger-example.rcp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ agent Line
)

agent Robot
local: btype : int, lnk : channel, basgn : bool, brdy : 0..2, no : int
local: btype : 0..3, lnk : channel, basgn : bool, brdy : 0..2, no : int
init: btype == 1 & lnk == empty & basgn == false & brdy == 0 & no == 0
relabel:
type <- btype
Expand Down
13 changes: 13 additions & 0 deletions examples/errors/typing-errors.rcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
enum channel {radio, speaker}

property-variables: friendly : bool

agent Droid
local: status : int, mood : bool
init: true
relabel:
friendly <- mood
receive-guard: true
repeat: {true} *? [mood := true]

system = Droid(R2D2, true) || Droid(C3PO, true)
2 changes: 1 addition & 1 deletion examples/get-supply.rcp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ agent Client
repeat: (
splyAtSelf: {true} SUPPLY@(myself)()[]
+
getAtX: {true} GET@(x)[]
getAtX: {true} GET@(x)()[]
+
bcastSend: {true} *! true(MSG := myself)[x := myself]
+
Expand Down
13 changes: 13 additions & 0 deletions examples/warnings/typing-warnings.rcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
enum channel {radio, speaker}

property-variables: friendly : bool

agent Droid
local: status : int, mood : bool
init: true
relabel:
friendly <- mood
receive-guard: true
repeat: {true} *? [mood := true]

system = Droid(R2D2, true) || Droid(C3PO, true)
2,987 changes: 1,215 additions & 1,772 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
"scripts": {
"build": "tsc -b tsconfig.src.json && node esbuild.mjs",
"watch": "concurrently -n tsc,esbuild -c blue,yellow \"tsc -b tsconfig.src.json --watch\" \"node esbuild.mjs --watch\"",
"lint": "eslint src --ext ts",
"langium:generate": "langium generate",
"langium:watch": "langium generate --watch",
"vscode:prepublish": "npm run esbuild-base -- --minify && npm run lint",
"vscode:prepublish": "npm run esbuild-base -- --minify",
"esbuild-base": "esbuild ./src/extension/main.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
"build:web": "npm run build",
"bundle": "vite build",
Expand All @@ -45,28 +44,26 @@
"test": "vitest run"
},
"dependencies": {
"chalk": "~5.3.0",
"chalk": "~5.6.0",
"commander": "~11.0.0",
"langium": "~3.4.0",
"monaco-languageclient": "~8.1.1",
"langium": "~3.5.0",
"monaco-languageclient": "~9.11.0",
"typir": "~0.2.2",
"typir-langium": "~0.2.2",
"vscode-languageclient": "~9.0.1",
"vscode-languageserver": "~9.0.1"
},
"devDependencies": {
"@codingame/esbuild-import-meta-url-plugin": "~1.0.2",
"@types/node": "^18.0.0",
"@types/node": "^24.0.0",
"@types/vscode": "~1.94.0",
"@typescript-eslint/eslint-plugin": "~7.3.1",
"@typescript-eslint/parser": "~7.3.1",
"concurrently": "~8.2.1",
"concurrently": "~9.2.0",
"esbuild": "^0.25.5",
"eslint": "~8.57.0",
"http-server": "~14.1.1",
"langium-cli": "~3.4.0",
"typescript": "~5.1.6",
"vite": "^6.3.6",
"langium-cli": "~3.5.0",
"typescript": "~5.9.2",
"vite": "^7.0.0",
"vitest": "^3.2.0",
"vscode": "npm:@codingame/monaco-vscode-api@~3.2.3",
"@vscode/vsce": "^3.4.0"
},
"volta": {
Expand Down
47 changes: 28 additions & 19 deletions src/language/r-check-module.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import type { AstNode, AstNodeDescription, LangiumDocument, Module, PrecomputedScopes, ReferenceInfo, Scope } from 'langium';
import type { AstNode, AstNodeDescription, LangiumDocument, LangiumSharedCoreServices, Module, PrecomputedScopes, ReferenceInfo, Scope } from 'langium';
import { AstUtils, DefaultScopeComputation, DefaultScopeProvider, inject } from 'langium';
import { CancellationToken } from 'vscode-languageserver';
import { Enum, Model, QualifiedRef, isEnum, isQualifiedRef, isPropVar, isCommand, Command} from './generated/ast.js';
import { Model, QualifiedRef, isEnum, isQualifiedRef, isPropVar, isCommand, Command, RCheckAstType, reflection} from './generated/ast.js';
import { RCheckGeneratedModule, RCheckGeneratedSharedModule } from './generated/module.js';
import { RCheckValidator, registerValidationChecks } from './r-check-validator.js';
import { createDefaultModule, createDefaultSharedModule, DefaultSharedModuleContext, LangiumServices, LangiumSharedServices, PartialLangiumServices } from 'langium/lsp';
import { createTypirLangiumServices, initializeLangiumTypirServices, TypirLangiumServices } from 'typir-langium';
import { RCheckTypeSystem } from './r-check-type-checking.js';


export class RCheckScopeProvider extends DefaultScopeProvider {
override getScope(context: ReferenceInfo): Scope {
const superScope: Scope = super.getScope(context);
const globalDescriptions: AstNodeDescription[] = superScope.getAllElements().toArray();
const document: LangiumDocument = AstUtils.getDocument(context.container);
const superScope = super.getScope(context); // This is the GLOBAL scope
const document = AstUtils.getDocument(context.container);

const documentDescriptions: AstNodeDescription[] = [];
for (const childNode of AstUtils.streamAllContents(document.parseResult.value)) {
// Export enum cases globally (but limited to current file)
if (isEnum(childNode)) {
const enumNode: Enum = childNode as Enum;
for(const caseNode of enumNode.cases){
globalDescriptions.push(this.descriptions.createDescription(caseNode, caseNode.name, document));
for(const caseNode of childNode.cases){
documentDescriptions.push(this.descriptions.createDescription(caseNode, caseNode.name, document));
}
}
// Export @-prefixed names for property variables
if (isPropVar(childNode)) {
globalDescriptions.push(this.descriptions.createDescription(childNode, "@" + childNode.name, document))
documentDescriptions.push(this.descriptions.createDescription(childNode, "@" + childNode.name, document))
}
}
return this.createScope(globalDescriptions);

// Add local names visible only in this document, layered above global scope.
return this.createScope(documentDescriptions, superScope);
}
}

Expand Down Expand Up @@ -127,7 +131,8 @@ export class RCheckScopeComputation extends DefaultScopeComputation {
export type RCheckAddedServices = {
validation: {
RCheckValidator: RCheckValidator
}
},
typir: TypirLangiumServices<RCheckAstType>,
}

/**
Expand All @@ -141,13 +146,16 @@ export type RCheckServices = LangiumServices & RCheckAddedServices
* declared custom services. The Langium defaults can be partially specified to override only
* selected services, while the custom services must be fully specified.
*/
export const RCheckModule: Module<RCheckServices, PartialLangiumServices & RCheckAddedServices> = {
validation: {
RCheckValidator: () => new RCheckValidator()
},
references : {
ScopeComputation : (services) => new RCheckScopeComputation(services),
ScopeProvider: (services) => new RCheckScopeProvider(services)
export function createRCheckModule(shared: LangiumSharedCoreServices): Module<RCheckServices, PartialLangiumServices & RCheckAddedServices> {
return {
validation: {
RCheckValidator: () => new RCheckValidator(),
},
typir: () => createTypirLangiumServices(shared, reflection, new RCheckTypeSystem(), { /* customize Typir services here */ }),
references: {
ScopeComputation: (services) => new RCheckScopeComputation(services),
ScopeProvider: (services) => new RCheckScopeProvider(services),
},
}
};

Expand Down Expand Up @@ -177,9 +185,10 @@ export function createRCheckServices(context: DefaultSharedModuleContext): {
const RCheck = inject(
createDefaultModule({ shared }),
RCheckGeneratedModule,
RCheckModule
createRCheckModule(shared),
);
shared.ServiceRegistry.register(RCheck);
initializeLangiumTypirServices(RCheck, RCheck.typir);
registerValidationChecks(RCheck);
return { shared, RCheck };
}
Loading