cuishuang
1da234df24
Formatting code with gofmt
...
Signed-off-by: cuishuang <imcusg@gmail.com >
2024-09-25 16:06:14 +08:00
Dave Yarwood
20897e5ff6
Address staticcheck warnings
2024-01-26 21:21:14 -05:00
ginglis13
29216814a0
refactor: remove io/ioutil
...
io/ioutil has been deprecated since Go 1.16
https://pkg.go.dev/io/ioutil
Signed-off-by: ginglis13 <ginglis05@gmail.com >
2023-10-13 15:21:14 -07:00
David Lu
cea51273cb
Introduce NoteLengthSeconds to distinguish between 's' and 'ms' note lengths
...
Add NoteLengthSeconds scanner token, ASTNode, and ScoreUpdate.
NoteLengthSeconds is the seconds equivalent of NoteLengthMs.
2023-04-02 22:26:39 -04:00
David Lu
fbc637572c
Introduce Alda formatter to output idiomatic source code from AST
...
Primary purpose of formatter is to support MusicXML import and code gen.
Formatter supports configurable indent text and line wrap length.
Comments are currently dropped while scanning, so are ignored by the formatter.
The `alda format` command remains hidden for now due to this remaining TODO.
2023-04-02 18:12:41 -04:00
David Lu
6904922c05
Introduce ScoreUpdate to ASTNode generation and generalize parser testing
2023-04-02 17:58:17 -04:00
Dave Yarwood
5acb0d5e6a
Fix staticcheck warnings
2022-02-22 23:06:28 -05:00
Dave Yarwood
8d102f619f
Represent repetition ranges in AST as separate nodes, instead of as map literals
2021-12-29 16:18:51 -05:00
Dave Yarwood
8989d2b8ba
Represent note length in AST as DenominatorNode and DotsChildren, instead of as a map literal
2021-12-29 16:01:07 -05:00
Dave Yarwood
86b5bbefc9
Cleanup/improvement: don't need to use reflect package here
2021-12-29 15:04:24 -05:00
Dave Yarwood
3442616826
Add alda parse -o {ast,ast-pretty} ... and :score ast functionality
2021-12-29 00:09:09 -05:00
Dave Yarwood
ab1a65e257
Refactor: Parse functions return AST
2021-12-28 20:07:43 -05:00
Dave Yarwood
a88d5cf350
Refactor parser to produce an AST instead of skipping from tokens to ScoreUpdates
2021-12-27 20:04:52 -05:00
Dave Yarwood
9d2b5e537a
Aesthetic adjustments
2021-12-27 19:45:58 -05:00
Dave Yarwood
75080b0b12
Fix copy-paste fail in the name of a variable test case
2021-12-27 19:40:49 -05:00
Dave Yarwood
4bce8c5042
Add chord test case
2021-12-27 19:40:18 -05:00
Dave Yarwood
d766a75b5c
Fix a bug where a duration in seconds at the end of an event sequence was causing a parse error
2021-07-31 23:29:58 -04:00
Dave Yarwood
ecb5aae370
Hack to work around aurora not supporting NO_COLOR
2021-06-28 11:04:48 -04:00
David Lu
c8afe42062
Added tests
2021-06-06 21:03:48 -04:00
Dave Yarwood
6bd3c3c0fb
Gracefully handle "file not found" error when playing a score file
2021-06-06 20:41:10 -04:00
David Lu
6795bc6bf0
Set up preliminary musicxml importer
2021-05-01 20:01:46 -04:00
Dave Yarwood
b3956dde60
scaffolding for better user-facing error messages
2021-01-16 15:27:22 -05:00
Dave Yarwood
51e4fb4f2e
improve description of unexpected characters in error message
2020-11-14 20:59:29 -05:00
Dave Yarwood
228c81171c
fix an edge case where "ab =" wasn't throwing an error
...
Input like "ab =" should result in an error because it's a variable definition
with no content.
2020-11-14 20:35:45 -05:00
Dave Yarwood
e0d11b1ec2
include source context EVERYWHERE
...
This provides filename/line/column context for any error I could possibly find.
To achieve this, I made it so that all ScoreUpdates have source context, so when
updating the score results in an error, we can print out the line and column
number corresponding to the error.
It's a bit more complicated than that, because score updates are nestable (e.g.
event sequences can contain cram expressions can contain chords, etc.), which
essentially gives us a stacktrace whenever a score update results in an error. I
punted on giving the user the full stacktrace, in favor of doing something
simpler and just showing the bottom-most error, because that's probably going to
be the line and column number that's the most helpful.
2020-11-14 20:34:04 -05:00
Dave Yarwood
f961abfd3c
reorganize source context stuff a bit
2020-10-29 20:42:46 -04:00
Dave Yarwood
3bec60084b
refactor / create an error type that wraps an error to provide alda source code context
2020-10-29 20:19:03 -04:00
Dave Yarwood
3a9a36e6b1
better string versions of token types (visible in user-facing error messages)
2020-10-29 20:18:01 -04:00
Dave Yarwood
709d669d9c
improvements to line/column information in scan/parse error messages
...
1. Added column to parse error messages.
2. It turns out that we weren't even keeping track of the line and column where
a token starts, let alone including it in the error message. Added
`startLine` and `startColumn` fields to the scanner struct, made it so that
they get updated in sync with the `start` (i.e. start index) field, and made
it so that we're using the start line and column in error messages, instead
of the _current_ line and column, which was less helpful.
2020-10-22 20:28:42 -04:00
Dave Yarwood
77d85bdf72
fixes an obscure parser bug where consumeWhile can sometimes try to consume past EOF
2020-07-31 08:32:37 -04:00
Dave Yarwood
7c9fd98fc9
use reachedEOF for readability
2020-07-31 08:26:02 -04:00
Dave Yarwood
b629e4c4c8
use eofIsNext helper function here for readability
2020-07-31 08:23:28 -04:00
Dave Yarwood
2679477d36
attempt to handle \r better
2020-05-10 21:32:06 -04:00
Dave Yarwood
86f1d6178f
quick hack to avoid printing control characters weirdly (e.g. \r jumping to the beginning of the line)
2020-05-10 21:30:57 -04:00
Dave Yarwood
3d86b5d6c4
CRAM => cram
2020-04-25 16:18:16 -04:00
Dave Yarwood
4dd0fd4954
add parser test for V0: (voice group end marker)
2020-04-21 22:15:00 -04:00
Dave Yarwood
0144be5cb5
fix: a a repeat can be immediately followed by ] or }
2020-04-21 21:46:50 -04:00
Dave Yarwood
a5100b0f43
fix: " is not a valid lisp symbol char
2020-04-21 21:43:53 -04:00
Dave Yarwood
ed570636b0
use float64 everywhere to fix inaccuracies caused by converting float32 <=> float64
2020-04-18 21:02:35 -04:00
Dave Yarwood
e23f70e16f
make log message more accurate
2020-02-23 21:21:38 -05:00
Dave Yarwood
6e2b33bbe1
alda doctor command
2020-02-03 08:08:17 -05:00
Dave Yarwood
86fa3810fc
fix bug in scanner where lisp numbers can't be parsed if they're negative
2019-11-16 22:55:21 -05:00
Dave Yarwood
01f4382542
cap line length at 80 chars where possible
2019-11-10 07:45:47 -05:00
Dave Yarwood
a6aa4e560a
rename OnIterations => OnRepetitions
2019-11-09 22:06:13 -05:00
Dave Yarwood
12603a2829
rm stray comment
2019-11-04 21:00:43 -05:00
Dave Yarwood
3588fd4689
make PitchIdentifier an interface instead of implicitly using certain fields of Note in certain situations
...
In accordance with the "don't make invalid data representable" principle.
This also allows us to create a LispPitch type in alda.lisp, which will just
wrap PitchIdentifier.
2019-11-04 09:32:51 -05:00
Dave Yarwood
67e6931abe
consider "slur" to be an attribute of note only, not duration
...
i.e. a duration cannot be "slurred" anymore, but a note can be slurred
2019-10-30 23:01:16 -04:00
Dave Yarwood
cb09882fef
use p.match(this, that) instead of p.match(this) || p.match(that)
2019-10-30 22:58:36 -04:00
Dave Yarwood
1416f7514d
allow p.check to accept a variable number of token types
2019-10-30 22:57:44 -04:00
Dave Yarwood
e1b991448f
adjust wording in comment
2019-10-29 22:35:26 -04:00