Skip to content

JjScript Reference

JjScript is an imperative, command-based scripting language for direct metamodel manipulation. While JjEL evaluates expressions without side effects and JjTL produces new models declaratively, JjScript modifies the metamodel in place: it creates, renames, moves, and deletes elements as immediate operations.

Every JjScript statement begins with a verb followed by its arguments:

JjScript
create class Person
create attribute name in Person type EString [1]
rename class Person to Customer
delete attribute age

All value expressions inside commands are delegated to JjEL. The same expression syntax works across all Jjodel languages.

CommandSyntaxDescription
createcreate <type> <name> [in <parent>] [options]Create a metamodel element
deletedelete [<type>] <target> [cascade|force]Remove an element
renamerename [<type>] <target> to <name>Rename an element
setset <target>.<prop> [=|+=|-=] <value>Set a property
addadd <type> <name> to <target>Create with parent context
removeremove <target> from <parent>Remove from a collection
movemove <target> to <destination>Relocate an element
copycopy <target> to <dest> [as <name>] [deep]Duplicate an element
extends<Child> extends <Parent>Set inheritance

JjScript supports 15 element types: class, abstract class, interface, attribute, reference, containment, composition, operation, parameter, package, enum, literal, annotation, model, metamodel.

The create command accepts element-specific options:

JjScript
create class Person
create abstract class BaseEntity
create interface Nameable
create attribute name in Person type EString [1]
create attribute age in Person type EInt default 0
create reference friends in Person type Person [*]
create enum VisibilityKind
create literal PUBLIC in VisibilityKind

The set command supports three operators:

  • = replaces the value
  • += appends to a collection
  • -= removes from a collection
set Person.isAbstract = true
set Person.attributes += newAttr
CommandSyntaxDescription
listlist [<type>] [in <scope>]List elements
showshow <target> [brief|full|tree]Display element details
validatevalidate [<target>|all]Check model correctness
list class
show Person full
validate all
CommandSyntaxDescription
undo / redoundo [n] / redo [n]Undo/redo up to 20 actions
clearclear [history|console|selection]Reset state
helphelp [<topic>]Context-sensitive help

Evaluates a JjEL expression in the current metamodel context:

eval forall c in classes such that c.isAbstract: c.name
eval exists a in Person.attributes such that a.type == "EString"

If the input starts with a JjEL keyword (forall, exists, with), the eval prefix is optional.

Iterates over a collection and executes a command per element:

forall a in attributes such that a.type == "EString"
do set a.readonly = true

Binds values to variables, including interactive prompts:

let $name = prompt('New class name', EString) in
rename class Person to $name
let $ok = confirm('Delete all derived attributes?') in
forall a in attributes such that a.isDerived
do delete a

JjScript locates elements by qualified name using three strategies:

  1. Metamodel-scoped (preferred): searches within the target metamodel
  2. Project-wide: searches all metamodels in the project
  3. Name-only: case-insensitive lookup by last segment

Qualified names use :: for package paths (com::model::Person) and . for member access (Person.name).

JjScript provides context-sensitive suggestions as you type, combining:

  • Command names and keywords
  • Class and attribute names from the current metamodel
  • Primitive types and user-defined types

JjScript is the execution target for the Jjodie AI assistant. When you type a natural-language request in the chat (“add a name attribute of type String to Person”), Jjodie generates JjScript commands and executes them.

Building a metamodel from scratch:

JjScript
# Create types
create class Person
create abstract class BaseEntity
create interface Nameable
# Set inheritance
Person extends BaseEntity
Person extends Nameable
# Add features
create attribute name in Person type EString [1]
create attribute age in Person type EInt default 0
create reference friends in Person type Person [*]
# Create an enumeration
create enum VisibilityKind
create literal PUBLIC in VisibilityKind
create literal PRIVATE in VisibilityKind
create literal PROTECTED in VisibilityKind
# Create a package
create package com.example
move Person to com.example
# Validate
validate all
EBNF
Command = CreateCmd | DeleteCmd | RenameCmd | SetCmd
| AddCmd | RemoveCmd | MoveCmd | CopyCmd
| ExtendsCmd | ListCmd | ShowCmd | ValidateCmd
| HelpCmd | UndoCmd | RedoCmd | ClearCmd
| EvalCmd | LetCmd | ForallCmd
CreateCmd = 'create' ElementType IDENTIFIER
('in' QualifiedName)? CreateOptions*
DeleteCmd = 'delete' ElementType? QualifiedName
('cascade' | 'force')?
ForallCmd = 'forall' IDENT 'in' JjELExpr
('such' 'that' JjELExpr)?
'do' Command
LetCmd = 'let' '$' IDENT '=' Expr
(',' '$' IDENT '=' Expr)* 'in' Command