Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove noTitle dialect #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export const ChordProLanguage = LRLanguage.define({
":": t.punctuation,
Separator: t.separator
})
],
dialect: "noTitle"
]
}),
languageData: {
commentTokens: {line: "#"}
Expand Down
5 changes: 0 additions & 5 deletions src/syntax.grammar
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
@dialects { noTitle }

@top Song {
(Title { titleText } eol (Author { authorText } eol)?)?
((Comment | Directive | LineDirective | Lyrics | blankLine | ChordLine | Section) (eol | eof))*
}

Expand All @@ -23,8 +20,6 @@ InlineChord { "[" Chord? "]" }
@external tokens line from "./tokens.js" {
Comment
blankLine
titleText
authorText
SectionName
chordLineStart
directiveLineStart
Expand Down
11 changes: 1 addition & 10 deletions src/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {titleText, authorText, chordLineStart, directiveLineStart, blankLine, Comment, SectionName, Chord,
Dialect_noTitle} from "./syntax.grammar.terms"
import {chordLineStart, directiveLineStart, blankLine, Comment, SectionName, Chord} from "./syntax.grammar.terms"
import {ExternalTokenizer, InputStream} from "@lezer/lr"

const enum Ch {
Expand Down Expand Up @@ -232,14 +231,6 @@ export const line = new ExternalTokenizer((input, stack) => {
return
} else if (hasDirectiveName(input)) {
input.acceptToken(directiveLineStart)
} else if (!stack.dialectEnabled(Dialect_noTitle) && stack.canShift(titleText) && wordChar(input.next)) {
skipLine(input)
input.acceptToken(titleText)
return
} else if (!stack.dialectEnabled(Dialect_noTitle) && stack.canShift(authorText) && wordChar(input.next)) {
skipLine(input)
input.acceptToken(authorText)
return
} else if (readChord(input)) {
// See if this is a chord-only line
for (;;) {
Expand Down
16 changes: 8 additions & 8 deletions test/chordpro-chords.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# Symbols {"dialect": "noTitle"}
# Symbols

[C2/E]
[Dbm7]
[/B]

==> Song(Lyrics(InlineChord(Chord)), Lyrics(InlineChord(Chord)), Lyrics(InlineChord(Chord)))

# Numeric - minor {"dialect": "noTitle"}
# Numeric - minor

[2m]

==> Song(Lyrics(InlineChord(Chord)))

# Numeric - accidentals {"dialect": "noTitle"}
# Numeric - accidentals

[#4m7]
[b7]

==> Song(Lyrics(InlineChord(Chord)), Lyrics(InlineChord(Chord)))

# Numeric - bass {"dialect": "noTitle"}
# Numeric - bass

[4/1]

==> Song(Lyrics(InlineChord(Chord)))

# Numeral {"dialect": "noTitle"}
# Numeral

[V13]

==> Song(Lyrics(InlineChord(Chord)))

# Numeral - accidentals {"dialect": "noTitle"}
# Numeral - accidentals

[bVII]
[#IV]

==> Song(Lyrics(InlineChord(Chord)), Lyrics(InlineChord(Chord)))

# Numeral - bass {"dialect": "noTitle"}
# Numeral - bass

[IV/I]

==> Song(Lyrics(InlineChord(Chord)))

# no chord {"dialect": "noTitle"}
# no chord

[]

Expand Down
12 changes: 6 additions & 6 deletions test/chordpro.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lyrics {"dialect": "noTitle"}
# Lyrics

My [Dm7]heart has always [C/E]longed for something[F] more

Expand All @@ -7,7 +7,7 @@ My [Dm7]heart has always [C/E]longed for something[F] more
Song(
Lyrics(Lyric,InlineChord(Chord),Lyric,InlineChord(Chord),Lyric,InlineChord(Chord),Lyric))

# Allows dangling ] {"dialect": "noTitle"}
# Allows dangling ]

Let it [Am]be
[C]Whisper wor]ds of [F]wis[G]dom
Expand All @@ -18,7 +18,7 @@ Song(
Lyrics(Lyric,InlineChord(Chord),Lyric),
Lyrics(InlineChord(Chord),Lyric,InlineChord(Chord),Lyric,InlineChord(Chord),Lyric))

# Allows dangling } {"dialect": "noTitle"}
# Allows dangling }

Let it [Am]be
[C]Whisper wor}ds of [F]wis[G]dom
Expand All @@ -29,7 +29,7 @@ Song(
Lyrics(Lyric,InlineChord(Chord),Lyric),
Lyrics(InlineChord(Chord),Lyric,InlineChord(Chord),Lyric,InlineChord(Chord),Lyric))

# Inline directives {"dialect": "noTitle"}
# Inline directives

{start_of_chorus}
{c:Chorus 1}
Expand All @@ -50,7 +50,7 @@ Song(
InlineChord(Chord)),
Directive(DirectiveName))

# Directive mid-verse {"dialect": "noTitle"}
# Directive mid-verse

{c:Chorus}
And [Bb]I,[F/A][Gm][Bbma7/D]\ I'm desperate [Eb]for You[Gm7][Fsus][F]
Expand All @@ -77,7 +77,7 @@ Song(
Separator,Lyric,InlineChord(Chord),Lyric,InlineChord(Chord),Lyric,InlineChord(Chord),Lyric,
InlineChord(Chord)))

# Meta with multiple sections {"dialect": "noTitle"}
# Meta with multiple sections

{t: Rattle}
{key: Eb}
Expand Down
14 changes: 7 additions & 7 deletions test/chords-over-words-chords.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# Symbols {"dialect": "noTitle"}
# Symbols

C2/E
Dbm7
/B

==> Song(ChordLine(Chord), ChordLine(Chord), ChordLine(Chord))

# Numeric - minor {"dialect": "noTitle"}
# Numeric - minor

2m

==> Song(ChordLine(Chord))

# Numeric - accidentals {"dialect": "noTitle"}
# Numeric - accidentals

#4m7

b7

==> Song(ChordLine(Chord), ChordLine(Chord))

# Numeric - bass {"dialect": "noTitle"}
# Numeric - bass

4/1

==> Song(ChordLine(Chord))

# Numeral {"dialect": "noTitle"}
# Numeral

V13

==> Song(ChordLine(Chord))

# Numeral - accidentals {"dialect": "noTitle"}
# Numeral - accidentals

bVII
IV

==> Song(ChordLine(Chord), ChordLine(Chord))

# Numeral - bass {"dialect": "noTitle"}
# Numeral - bass

iv/I

Expand Down
30 changes: 15 additions & 15 deletions test/chords-over-words.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Simple {"dialect": "noTitle"}
# Simple

Dm7 C/E F#
My heart has always longed for something more
Expand All @@ -7,7 +7,7 @@ My heart has always longed for something more

Song(ChordLine(Chord,Chord,Chord),Lyrics(Lyric))

# Simple - Numbers {"dialect": "noTitle"}
# Simple - Numbers

2m7 2/3 #4
My heart has always longed for something more
Expand All @@ -16,7 +16,7 @@ My heart has always longed for something more

Song(ChordLine(Chord,Chord,Chord),Lyrics(Lyric))

# Simple - Numerals {"dialect": "noTitle"}
# Simple - Numerals

ii7 II/III #IV
My heart has always longed for something more
Expand All @@ -25,7 +25,7 @@ My heart has always longed for something more

Song(ChordLine(Chord,Chord,Chord),Lyrics(Lyric))

# Backslash should have it's own token {"dialect": "noTitle"}
# Backslash should have it's own token

Dm7 C/E F
My heart has always \longed for something more
Expand All @@ -43,9 +43,9 @@ Intro (5x)
Eb(no3) / / / | / / / / |

Verse 1
Eb Ebsus Eb
Eb Ebsus Eb
Saturday was silent, surely it was through
Cm Bb Ab2 Eb/G Eb / / / /
Cm Bb Ab2 Eb/G Eb / / / /
But since when has im - possible\ ever stopped You

==>
Expand All @@ -67,9 +67,9 @@ Intro (5x)
Eb(no3) / / / | / / / / |

Verse 1
Eb Ebsus Eb
Eb Ebsus Eb
Saturday was silent, surely it was through
Cm Bb Ab2 Eb/G Eb / / / /
Cm Bb Ab2 Eb/G Eb / / / /
But since when has im - possible\ ever stopped You

==>
Expand All @@ -86,10 +86,10 @@ Song(
# Directive mid-section

Verse 1
Eb Ebsus Eb
Eb Ebsus Eb
Saturday was silent, surely it was through
transpose: 2
Cm Bb Ab2 Eb/G Eb / / / /
Cm Bb Ab2 Eb/G Eb / / / /
But since when has im - possible\ ever stopped You

==>
Expand All @@ -105,16 +105,16 @@ Song(
# Space Mid-Section

Chorus 1:
Eb5 /Bb - /Ab Eb5
Eb5 /Bb - /Ab Eb5
This is the sound\ of dry bones rattling
Eb5 /Bb - /Ab Eb5
Eb5 /Bb - /Ab Eb5
This is the praise\ make a dead man walk again

Cm Bb
Cm Bb
Open the grave, I'm coming out
Ab Eb
Ab Eb
I'm gonna live, gonna live a - gain
Eb5 Ab - Eb/G Eb5
Eb5 Ab - Eb/G Eb5
This is the sound\ of dry bones rattling
Ab - Eb/G Eb5 / | Ab - Eb/G Eb5 /

Expand Down
8 changes: 4 additions & 4 deletions test/directives.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# meta {"dialect": "chordpro"}
# meta
{capo: 2}
{artist: Maverick City Music}
==> Song(Directive(DirectiveName, DirectiveValue), Directive(DirectiveName, DirectiveValue))

# alias {"dialect": "chordpro"}
# alias
{t: Get Back}
==> Song(Directive(DirectiveName, DirectiveValue))

# escapes special characters {"dialect": "chordpro"}
# escapes special characters
{title: my \{title\}}
==> Song(Directive(DirectiveName, DirectiveValue))

# inline {"dialect": "chordpro"}
# inline
{start_of_verse}
==> Song(Directive("{", DirectiveName, "}"))

Expand Down