文档

语言参考

从编译器注册表生成的语句、属性和端口清单。

这一页直接读取编译器的 authoring contract,不另行维护一份关键字清单。新增或修改 DSL 语句后,参考内容会随构建自动更新。

通用结构

一份源码描述一个具名场景,后面依次是实体、关系、展示请求和运动请求:

scene example

support O orientation=horizontal
load A 1kg

A <-> O

show A.forces

标识符区分大小写。字符串使用双引号;物理量写成数值和单位,例如 2kg、30deg、9.8m/s^2。

共享数值参数

let name = 6V 定义场景内的数值参数,属性或简写中用 $name 引用, let other = $name 定义别名。引用可以先于定义;重名、未知引用、循环引用或量纲不匹配都会报错。 只支持数值与别名,不支持表达式或字符串替换。完整示例见 DSL 基础。

绳路

大多数滑轮绳路会根据实体和附着关系自动推导。需要选择某根绳的观测、显式描述拓扑,或给不同绳段单独着色时,可声明具名绳并按顺序列出路径:

rope R #gray
R: ceiling -[#red]-> M -> F -[#blue]-> R.free

R.free 是绳子 R 自带的自由端,不是另一个需要声明的实体。

实体

point
语法
point <id> [properties] [#color]
属性
x: 物理量(length)y: 物理量(length)label: 文本
support
语法
support <id> [properties] [#color]
属性
x: 物理量(length)y: 物理量(length)shape: 枚举(beam | wall | ceiling)orientation: 枚举(horizontal | vertical | angled)angle: 物理量(angle)length: 物理量(length)label: 文本
anchor
语法
anchor <id> [properties] [#color]
属性
x: 物理量(length)y: 物理量(length)role: 枚举(fixed | movable)label: 文本
body
语法
body <id> [value] [properties] [#color]
属性
mass: 物理量(mass)inertia_factor: 无单位数字shape: 枚举(block | sphere | hollow_sphere | cylinder | hoop | point | disk)radius: 物理量(length)width: 物理量(length)material: 文本area: 物理量(area)volume: 物理量(volume)x: 物理量(length)y: 物理量(length)velocity: 物理量(velocity)acceleration: 物理量(acceleration)direction: 标识符label: 文本
load
语法
load <id> [value] [properties] [#color]
属性
mass: 物理量(mass)shape: 枚举(block | sphere | point)x: 物理量(length)y: 物理量(length)label: 文本
surface
语法
surface <id> [value] [properties] [#color]
属性
x: 物理量(length)y: 物理量(length)orientation: 枚举(horizontal | vertical | incline)angle: 物理量(angle)length: 物理量(length)friction: 枚举(smooth | static | kinetic | rough)mu: 无单位数字mu_static: 无单位数字mu_kinetic: 无单位数字material: 文本
detector
语法
detector <id> [properties] [#color]
属性
type: 标识符observable: 标识符reading: 文本x: 物理量(length)y: 物理量(length)label: 文本
rail
语法
rail <id> [properties] [#color]
属性
length: 物理量(length) · 必填separation: 物理量(length) · 必填
drum
语法
drum <id> [value] [properties] [#color]
属性
radius: 物理量(length) · 必填brake: 枚举(ratchet) · 必填x: 物理量(length)y: 物理量(length)
pulley
语法
pulley <id> [value] [properties] [#color]
属性
radius: 物理量(length)mass: 物理量(mass)x: 物理量(length)y: 物理量(length)
rope
语法
rope <id> [value] [properties] [#color]
属性
length: 物理量(length)mass: 物理量(mass)elasticity: 枚举(ideal | elastic)
pendulum
语法
pendulum <id> [value] [properties] [#color]
属性
mass: 物理量(mass)length: 物理量(length) · 必填angle: 物理量(angle)gravity: 物理量(acceleration)subject: 标识符x: 物理量(length)y: 物理量(length)
spring
语法
spring <id> [value] [properties] [#color]
属性
stiffness: 物理量(stiffness) · 必填rest_length: 物理量(length)extension: 物理量(length)displacement: 物理量(length)modulation_depth: 无单位数字modulation_frequency: 物理量(frequency)modulation_phase: 物理量(angle)x: 物理量(length)y: 物理量(length)
damper
语法
damper <id> [value] [properties] [#color]
属性
coefficient: 物理量(damping) · 必填x: 物理量(length)y: 物理量(length)
rod
语法
rod <id> [value] [properties] [#color]
属性
length: 物理量(length) · 必填mass: 物理量(mass)velocity: 物理量(velocity)angle: 物理量(angle)x: 物理量(length)y: 物理量(length)
fiber
语法
fiber <id> [value] [properties] [#color]
属性
stiffness: 物理量(stiffness) | 符号length: 物理量(length)x: 物理量(length)y: 物理量(length)
force
语法
force <id> [value] [properties] [#color]
属性
magnitude: 物理量(force) | 符号direction: 标识符angle: 物理量(angle)frequency: 物理量(frequency)
torque
语法
torque <id> [value] [properties] [#color]
属性
magnitude: 物理量(torque) · 必填direction: 枚举(clockwise | counterclockwise)
motor
语法
motor <id> [value] [properties] [#color]
属性
resistance: 物理量(resistance) · 必填rated_voltage: 物理量(voltage) · 必填no_load_speed: 物理量(angular_velocity) · 必填x: 物理量(length)y: 物理量(length)
circuit
语法
circuit <id> [properties] [#color]
属性
x: 物理量(length)y: 物理量(length)
resistor
语法
resistor <id> [value] [properties] [#color]
属性
resistance: 物理量(resistance) · 必填x: 物理量(length)y: 物理量(length)
rheostat
语法
rheostat <id> [value] [properties] [#color]
属性
max_resistance: 物理量(resistance) · 必填position: 物理量(ratio) · 必填x: 物理量(length)y: 物理量(length)
capacitor
语法
capacitor <id> [value] [properties] [#color]
属性
capacitance: 物理量(capacitance) · 必填charge: 物理量(charge)voltage: 物理量(voltage)x: 物理量(length)y: 物理量(length)
inductor
语法
inductor <id> [value] [properties] [#color]
属性
inductance: 物理量(inductance) · 必填current: 物理量(current)x: 物理量(length)y: 物理量(length)
source
语法
source <id> [value] [properties] [#color]
属性
type: 枚举(voltage | current | ac | signal)voltage: 物理量(voltage)rms_voltage: 物理量(voltage)current: 物理量(current)frequency: 物理量(frequency)phase: 物理量(angle)x: 物理量(length)y: 物理量(length)
switch
语法
switch <id> [value] [properties] [#color]
属性
state: 枚举(open | closed) · 必填x: 物理量(length)y: 物理量(length)
lamp
语法
lamp <id> [value] [properties] [#color]
属性
rated_voltage: 物理量(voltage) · 必填rated_power: 物理量(power) · 必填x: 物理量(length)y: 物理量(length)
charge
语法
charge <id> [value] [properties] [#color]
属性
value: 物理量(charge) · 必填role: 枚举(source | test)x: 物理量(length)y: 物理量(length)
field
语法
field <id> [value] [properties] [#color]
属性
type: 枚举(electric | magnetic | gravitational | electromagnetic)strength: 物理量(field_strength)electric_strength: 物理量(electric_field)magnetic_strength: 物理量(magnetic_field)x_min: 物理量(length)x_max: 物理量(length)direction: 标识符frequency: 物理量(frequency)phase: 物理量(angle)sources: 标识符
coil
语法
coil <id> [value] [properties] [#color]
属性
turns: 无单位数字radius: 物理量(length)resistance: 物理量(resistance)inductance: 物理量(inductance)x: 物理量(length)y: 物理量(length)
magnet
语法
magnet <id> [value] [properties] [#color]
属性
dipole_moment: 物理量(magnetic_dipole_moment)strength: 物理量(magnetic_field)direction: 标识符x: 物理量(length)y: 物理量(length)
medium
语法
medium <id> [value] [properties] [#color]
属性
refractive_index: 无单位数字density: 物理量(density)material: 文本x: 物理量(length)y: 物理量(length)
light
语法
light <id> [value] [properties] [#color]
属性
role: 枚举(source | ray | beam | photon)wavelength: 物理量(wavelength)frequency: 物理量(frequency)color: 标识符direction: 标识符x: 物理量(length)y: 物理量(length)
object
语法
object <id> [value] [properties] [#color]
属性
height: 物理量(length)subject: 标识符x: 物理量(length)y: 物理量(length)
mirror
语法
mirror <id> [value] [properties] [#color]
属性
shape: 枚举(plane | concave | convex)focal_length: 物理量(length)angle: 物理量(angle)x: 物理量(length)y: 物理量(length)
lens
语法
lens <id> [value] [properties] [#color]
属性
type: 枚举(converging | diverging)focal_length: 物理量(length) · 必填x: 物理量(length)y: 物理量(length)
prism
语法
prism <id> [value] [properties] [#color]
属性
apex_angle: 物理量(angle)refractive_index: 无单位数字x: 物理量(length)y: 物理量(length)
screen
语法
screen <id> [properties] [#color]
属性
width: 物理量(length)height: 物理量(length)x: 物理量(length)y: 物理量(length)
beam_splitter
语法
beam_splitter <id> [value] [properties] [#color]
属性
ratio: 无单位数字angle: 物理量(angle)x: 物理量(length)y: 物理量(length)
wave
语法
wave <id> [value] [properties] [#color]
属性
type: 枚举(mechanical | sound | electromagnetic | matter)amplitude: 无单位数字frequency: 物理量(frequency)wavelength: 物理量(wavelength) | 符号velocity: 物理量(velocity)phase: 物理量(angle)field: 标识符x: 物理量(length)y: 物理量(length)
reservoir
语法
reservoir <id> [value] [properties] [#color]
属性
temperature: 物理量(temperature)energy: 物理量(energy)medium: 文本x: 物理量(length)y: 物理量(length)
engine
语法
engine <id> [value] [properties] [#color]
属性
efficiency: 无单位数字power: 物理量(power)x: 物理量(length)y: 物理量(length)
ensemble
语法
ensemble <id> [value] [properties] [#color]
属性
particles: 无单位数字microstates: 无单位数字entropy: 物理量(entropy)x: 物理量(length)y: 物理量(length)
fluid
语法
fluid <id> [value] [properties] [#color]
属性
density: 物理量(density) · 必填pressure: 物理量(pressure)gravity: 物理量(acceleration)type: 枚举(ideal | viscous | incompressible)x: 物理量(length)y: 物理量(length)
particle
语法
particle <id> [value] [properties] [#color]
属性
type: 标识符mass: 物理量(mass) | 符号charge: 物理量(charge) | 符号energy: 物理量(energy) | 符号momentum: 物理量(momentum) | 符号velocity: 物理量(velocity) | 符号wavelength: 物理量(wavelength) | 符号frequency: 物理量(frequency) | 符号spin: 标识符direction: 标识符x: 物理量(length)y: 物理量(length)level: 标识符state: 标识符
atom
语法
atom <id> [properties] [#color]
属性
element: 文本model: 标识符x: 物理量(length)y: 物理量(length)
nucleus
语法
nucleus <id> [value] [properties] [#color]
属性
isotope: 文本protons: 无单位数字neutrons: 无单位数字mass: 物理量(mass) | 符号x: 物理量(length)y: 物理量(length)
energy_level
语法
energy_level <id> [value] [properties] [#color]
属性
energy: 物理量(energy) | 符号 · 必填n: 无单位数字label: 文本x: 物理量(length)y: 物理量(length)
wavefunction
语法
wavefunction <id> [value] [properties] [#color]
属性
state: 标识符energy: 物理量(energy) | 符号position_spread: 物理量(length) | 符号momentum_spread: 物理量(momentum) | 符号x: 物理量(length)y: 物理量(length)
aperture
语法
aperture <id> [value] [properties] [#color]
属性
type: 枚举(single_slit | double_slit | grating | crystal)width: 物理量(length) | 符号spacing: 物理量(length) | 符号x: 物理量(length)y: 物理量(length)
sample
语法
sample <id> [value] [properties] [#color]
属性
material: 文本activity: 物理量(activity) | 符号mass: 物理量(mass) | 符号x: 物理量(length)y: 物理量(length)
reactor
语法
reactor <id> [value] [properties] [#color]
属性
multiplication: 无单位数字moderator: 文本power: 物理量(power) | 符号x: 物理量(length)y: 物理量(length)
reference_frame
语法
reference_frame <id> [value] [properties] [#color]
属性
velocity: 物理量(velocity) | 符号direction: 标识符x: 物理量(length)y: 物理量(length)
event
语法
event <id> [value] [properties] [#color]
属性
x: 物理量(length) | 符号time: 物理量(time) | 符号 · 必填label: 文本

连接

series
语法
<entity> <-> <entity>
属性
无
parallel
语法
<entity> <=> <entity>
属性
无

物理关系

trajectory
语法
trajectory <name> body=<entity> stages=(<entity>, ...) [properties]
属性
body: 标识符 · 必填stages: 标识符 · 必填transition: 枚举(lossless) · 必填
shaft
语法
shaft <name> source=<entity> target=<entity> [properties]
属性
source: 标识符 · 必填target: 标识符 · 必填
winding
语法
winding <name> drum=<entity> load=<entity> [properties]
属性
drum: 标识符 · 必填load: 标识符 · 必填
contact
语法
contact <name> body=<entity> support=<entity> [properties]<body> on <support> [properties]
属性
body: 标识符 · 必填support: 标识符 · 必填contact: 枚举(fixed | sliding | rolling)
attachment
语法
attachment <name> subject=<entity> target=<entity> [properties]
属性
subject: 标识符 · 必填target: 标识符 · 必填at: 标识符
pivot
语法
pivot <name> body=<entity> support=<entity> [properties]
属性
body: 标识符 · 必填support: 标识符 · 必填position: 物理量(length)
rolling
语法
rolling <name> body=<entity> surface=<entity> [properties]
属性
body: 标识符 · 必填surface: 标识符 · 必填mode: 枚举(without_slipping | with_slipping)
orbit
语法
orbit <name> body=<entity> center=<entity> [properties]
属性
body: 标识符 · 必填center: 标识符 · 必填radius: 物理量(length)semi_major_axis: 物理量(length)eccentricity: 无单位数字observation_radius: 物理量(length)direction: 枚举(clockwise | counterclockwise)start: 枚举(apoapsis | periapsis)speed: 物理量(velocity)period: 物理量(time)phase: 物理量(angle)
launch
语法
launch <name> body=<entity> origin=<entity> [properties]
属性
body: 标识符 · 必填origin: 标识符 · 必填speed: 物理量(velocity) · 必填angle: 物理量(angle) · 必填height: 物理量(length)gravity: 物理量(acceleration)
collision
语法
collision <name> projectile=<entity> target=<entity> [properties]
属性
projectile: 标识符 · 必填target: 标识符 · 必填restitution: 无单位数字axis: 标识符
application
语法
application <name> force=<entity> body=<entity> [properties]<force> on <body> [properties]
属性
force: 标识符 · 必填body: 标识符 · 必填position: 物理量(length)at: 标识符
attraction
语法
attraction <name> subject=<entity> target=<entity> [properties]
属性
subject: 标识符 · 必填target: 标识符 · 必填law: 标识符magnitude: 物理量(force)
field_source
语法
field_source <name> field=<entity> sources=(<entity>, ...) [properties]
属性
field: 标识符 · 必填sources: 标识符 · 必填
exposure
语法
exposure <name> body=<entity> regions=(<entity>, ...) [properties]<body> in <regions>, ... [properties]
属性
body: 标识符 · 必填regions: 标识符 · 必填velocity: 物理量(velocity)direction: 标识符length: 物理量(length)
induction
语法
induction <name> source=<entity> target=<entity> [properties]
属性
source: 标识符 · 必填target: 标识符 · 必填motion: 标识符distance: 物理量(length)axis: 标识符
measurement
语法
measurement <name> subject=<entity> detector=<entity> [properties]
属性
subject: 标识符 · 必填detector: 标识符 · 必填observable: 标识符reading: 标识符
propagation
语法
propagation <name> source=<entity> target=<entity> [properties]<source> -> <target> [properties]
属性
source: 标识符 · 必填target: 标识符 · 必填distance: 物理量(length)velocity: 物理量(velocity)
refraction
语法
refraction <name> incident=<entity> from=<entity> to=<entity> [properties]<incident> -> <from> -> <to> [properties]
属性
incident: 标识符 · 必填from: 标识符 · 必填to: 标识符 · 必填incidence_angle: 物理量(angle) · 必填
reflection
语法
reflection <name> incident=<entity> surface=<entity> [properties]<incident> -> <surface> [properties]
属性
incident: 标识符 · 必填surface: 标识符 · 必填incidence_angle: 物理量(angle)
dispersion
语法
dispersion <name> source=<entity> prism=<entity> detector=<entity> [properties]<source> -> <prism> -> <detector> [properties]
属性
source: 标识符 · 必填prism: 标识符 · 必填detector: 标识符 · 必填
imaging
语法
imaging <name> object=<entity> optic=<entity> [properties]<object> -> <optic> [properties]
属性
object: 标识符 · 必填optic: 标识符 · 必填object_distance: 物理量(length) · 必填
interference
语法
interference <name> first=<entity> second=<entity> detector=<entity> [properties]
属性
first: 标识符 · 必填second: 标识符 · 必填detector: 标识符 · 必填
deflection
语法
deflection <name> incident=<entity> mass=<entity> observer=<entity> [properties]
属性
incident: 标识符 · 必填mass: 标识符 · 必填observer: 标识符 · 必填angle: 物理量(angle) · 必填
transmission
语法
transmission <name> incident=<entity> material=<entity> detector=<entity> [properties]
属性
incident: 标识符 · 必填material: 标识符 · 必填detector: 标识符 · 必填
transfer
语法
transfer <name> source=<entity> target=<entity> [properties]
属性
source: 标识符 · 必填target: 标识符 · 必填amount: 物理量(energy)form: 枚举(heat | work | radiation | electrical | mechanical_to_thermal | electrical_to_thermal)duration: 物理量(time)label: 文本
cycle
语法
cycle <name> engine=<entity> hot=<entity> cold=<entity> [properties]
属性
engine: 标识符 · 必填hot: 标识符 · 必填cold: 标识符 · 必填heat_in: 物理量(energy)heat_out: 物理量(energy)work: 物理量(energy)schedule: 标识符
equilibrium
语法
equilibrium <name> body=<entity> fluid=<entity> [properties]
属性
body: 标识符 · 必填fluid: 标识符 · 必填submerged_fraction: 无单位数字initial_displacement: 物理量(length)
occupation
语法
occupation <name> particle=<entity> level=<entity> [properties]
属性
particle: 标识符 · 必填level: 标识符 · 必填
state
语法
state <name> particle=<entity> wavefunction=<entity> [properties]
属性
particle: 标识符 · 必填wavefunction: 标识符 · 必填
transition
语法
transition <name> particle=<entity> from=<entity> to=<entity> [properties]
属性
particle: 标识符 · 必填from: 标识符 · 必填to: 标识符 · 必填photon: 物理量(energy) | 符号direction: 枚举(absorption | emission)
diffraction
语法
diffraction <name> incident=<entity> aperture=<entity> detector=<entity> [properties]<incident> -> <aperture> -> <detector> [properties]
属性
incident: 标识符 · 必填aperture: 标识符 · 必填detector: 标识符 · 必填
scattering
语法
scattering <name> incident=<entity> target=<entity> detector=<entity> [properties]
属性
incident: 标识符 · 必填target: 标识符 · 必填detector: 标识符 · 必填angle: 物理量(angle) | 符号energy: 物理量(energy) | 符号
photoelectric
语法
photoelectric <name> incident=<entity> material=<entity> emitted=<entity> [properties]
属性
incident: 标识符 · 必填material: 标识符 · 必填emitted: 标识符 · 必填work_function: 物理量(energy) · 必填angle: 物理量(angle)incident_distance: 物理量(length)
signal
语法
signal <name> carrier=<entity> from=<entity> to=<entity> frame=<entity> [properties]
属性
carrier: 标识符 · 必填from: 标识符 · 必填to: 标识符 · 必填frame: 标识符 · 必填
pair
语法
pair <name> particle=<entity> antiparticle=<entity> [properties]
属性
particle: 标识符 · 必填antiparticle: 标识符 · 必填
decay
语法
decay <name> parent=<entity> products=(<entity>, ...) [properties]
属性
parent: 标识符 · 必填products: 标识符 · 必填half_life: 物理量(time) | 符号energy: 物理量(energy) | 符号
reaction
语法
reaction <name> projectile=<entity> target=<entity> products=(<entity>, ...) [properties]
属性
projectile: 标识符 · 必填target: 标识符 · 必填products: 标识符 · 必填energy: 物理量(energy) | 符号
fission
语法
fission <name> nucleus=<entity> projectile=<entity> fragment_a=<entity> fragment_b=<entity> [properties]
属性
nucleus: 标识符 · 必填projectile: 标识符 · 必填fragment_a: 标识符 · 必填fragment_b: 标识符 · 必填energy: 物理量(energy) | 符号neutrons: 无单位数字
chain
语法
chain <name> reactor=<entity> fuel=<entity> [properties]
属性
reactor: 标识符 · 必填fuel: 标识符 · 必填generations: 无单位数字

动作

animate
语法
animate [target] [properties]
属性
duration: 物理量(time)speed: 无单位数字distance: 物理量(length)displacement: 物理量(length)angle: 物理量(angle)amplitude: 物理量(length)incidence_angle: 物理量(angle)object_distance: 物理量(length)direction: 标识符
set
语法
set <target> [value] [properties]
属性
value: 任意值
place
语法
place <target> [properties]
属性
x: 无单位数字y: 无单位数字variant: 枚举(compact | standard | wide | print | poster)

展示

show
语法
show <entity> [entity...]show <entity>.all | show <entity>.<feature> [entity.feature...]
属性
motion: 文本path: 文本motion_track: 文本odd_intervals: 文本distance: 文本displacement: 文本time: 文本velocity: 文本acceleration: 文本apex: 文本range: 文本gravity: 文本forces: 文本force_diagram: 文本tension: 文本torque: 文本inertia: 文本angular_acceleration: 文本mechanical_advantage: 文本equilibrium: 文本period: 文本energy: 文本momentum: 文本angular_momentum: 文本current: 文本voltage: 文本power: 文本charge: 文本electric_field: 文本magnetic_field: 文本flux: 文本induction: 文本wave: 文本phase: 文本wavelength: 文本interference: 文本rays: 文本normal: 文本angles: 文本critical_angle: 文本image: 文本principal_rays: 文本image_distance: 文本magnification: 文本heat: 文本work: 文本efficiency: 文本pressure: 文本buoyancy: 文本waterline: 文本states: 文本levels: 文本probability: 文本uncertainty: 文本events: 文本worldline: 文本activity: 文本decay: 文本reaction: 文本

颜色

#red
语法
<entity or path segment> #red
属性
无
#orange
语法
<entity or path segment> #orange
属性
无
#gold
语法
<entity or path segment> #gold
属性
无
#green
语法
<entity or path segment> #green
属性
无
#blue
语法
<entity or path segment> #blue
属性
无
#purple
语法
<entity or path segment> #purple
属性
无
#gray
语法
<entity or path segment> #gray
属性
无
#black
语法
<entity or path segment> #black
属性
无
#white
语法
<entity or path segment> #white
属性
无