# File syntax

A complete file contains a version header, a score, optional settings, and
music. This example is two bars for flute: four quarter notes, then a half
note and a half rest.

```scorescript
scorescript 0.3
score "First melody" {
  composer "A. Writer"
  arranger "A. Arranger"
  meter 4/4
  key C
  tempo 96
  parts { flute }
  flute { m1-2 { 4C5 D E F | 2G 2r } }
}
```

## File components

`scorescript 0.3` identifies the language version. `score "First melody"`
names the work; its braces contain the settings and music. `composer` and
`arranger` are optional printed credits. Quote names containing spaces.

`meter 4/4` gives each measure four quarter-note beats. `key C` sets the key
signature. `tempo 96` sets a quarter-note metronome speed of 96.
`parts { flute }` declares the instrument. `flute { ... }` contains its music;
`m1-2 { ... }` addresses measures 1–2, and `|` separates the two bars.

Read `4C5` as three pieces: `4` is a quarter note, `C` is the pitch, and `5`
is the octave. `D E F` retain the quarter-note duration. They choose nearby
pitches in the same melodic line. `2G` is a half note; `2r` is a half rest.
The opening octave anchors the phrase; later notes follow relative contour.

## Marks and bare music

Parenthesized marks attach to a note. A musical fragment can omit the file
wrapper when no instrument or non-default setting is needed:

```scorescript
4C5(p) D E F | 2G(mf) 2r
```

`(p)` is piano and `(mf)` is mezzo-forte. The barline separates two measures.
This shorter example is a fragment with the default 4/4 meter.

## Comments

Comments start with `//` and continue to the end of that physical line.
They explain the source without adding music or printed performance text.
Use a [quoted musical text mark](marks.md) when the player should see words.

```scorescript
// This comment is not printed on the staff.
4C5 D E F
```

## File operations

To use the complete example, save it as `first-melody.scorescript` and open it
in a ScoreScript editor, or use the [CLI](integration.md):

```text
scorescript check first-melody.scorescript
scorescript format first-melody.scorescript --write
scorescript pdf first-melody.scorescript -o first-melody.pdf
```

Formatting may replace explicit measure lines with compact measure ranges.
See [parts and measures](structure.md), [pitch](pitch.md), and [rhythm](rhythm.md)
for the individual rules. Copying or downloading source is optional; the
example and its notation describe the result directly.
