Skip to content
PinBenchPublic

About

pinbench_pdl — the Part Definition Language (.pdl) for PinBench, in pure Dart

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

pinbench_pdl

The Part Definition Language — .pdl, how PinBench describes a kind of part as data — as a plain Dart package: the reader, the expression language behaviour rules are written in, and the model a parsed part becomes.

import 'package:pinbench_pdl/pinbench_pdl.dart';

final result = PdlParser.parse(source, assetDirectory: 'parts/ldr');
for (final problem in result.diagnostics) print(problem);   // line + message
final part = result.definition;                              // null on errors
print('${part!.name}: ${part.pins.map((p) => p.id).join(', ')}');

It depends on nothing but meta — no Flutter, and nothing else of PinBench's. That is the point of it being a package of its own: a VS Code extension, a linter or a command-line validator can read .pdl exactly as the app does, report the same diagnostics on the same lines, and agree on where every pin is. test/architecture/layering_test.dart in the app fails if it stops being pure Dart.

lib/
  pinbench_pdl.dart         the API
  src/
    pdl_parser.dart         PdlParser, PdlParseResult, PdlDiagnostic
    part_definition.dart    PartDefinition and its sections — visual, pins,
                            properties, state, behaviour, SPICE model
    expression.dart         the expression language (`map(analog(a), 0, 5, …)`)
    behavior_evaluator.dart runs a part's BEHAVIOR rules for one frame
    pin.dart                PinDef, PortType
    geometry.dart           PdlPoint, PdlColor — plain values, not a UI's types
    units.dart              PdlUnits — the grid a part's coordinates are on
    resistance.dart         parseResistance — `4k7`, `1M`, `10 kΩ`
doc/
  PDL.md                    the format, with a worked example per section

Units are part of the format

Pin coordinates are canvas pixels on a lattice whose pitch is one breadboard hole (0.1" = 2.54 mm = 16 px), and every pin must sit on it or it cannot seat in a hole. PdlUnits holds those numbers; the app's grid is built on them rather than the other way round, so a tool using this package and the app cannot disagree about where a pin is. 12mm in a file is converted with the same scale.

Where it meets Flutter

Not here. pinbench_parts draws parts, holds the shipped catalog (assets/parts/), and turns these plain values into Flutter ones in pdl_flutter.dart.

The format

Specified in doc/PDL.md.

About

pinbench_pdl — the Part Definition Language (.pdl) for PinBench, in pure Dart

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages