1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-08 08:55:38 +00:00

Parser: audio statements (play / start_music / stop_music)

The \`play\`, \`start_music\`, and \`stop_music\` keywords were lexed
but not parsed. Programs using them failed with a generic "unexpected
token" error. Now:

- \`Statement::Play(sfx_name, span)\`
- \`Statement::StartMusic(track_name, span)\`
- \`Statement::StopMusic(span)\`

parse successfully and flow through analyzer / IR lowering / codegen
as no-ops. Semantics match the spec but produce no output — no audio
driver exists yet. Users who need sound can still wire in custom
code via \`asm { ... }\` blocks.

https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
Claude 2026-04-12 16:38:59 +00:00
parent 59970a4a45
commit e16b765959
No known key found for this signature in database
6 changed files with 67 additions and 2 deletions

View file

@ -899,6 +899,23 @@ impl Parser {
Ok(Statement::Scroll(x, y, span))
}
TokenKind::KwDebug => self.parse_debug_statement(),
TokenKind::KwPlay => {
let span = self.current_span();
self.advance();
let (name, _) = self.expect_ident()?;
Ok(Statement::Play(name, span))
}
TokenKind::KwStartMusic => {
let span = self.current_span();
self.advance();
let (name, _) = self.expect_ident()?;
Ok(Statement::StartMusic(name, span))
}
TokenKind::KwStopMusic => {
let span = self.current_span();
self.advance();
Ok(Statement::StopMusic(span))
}
TokenKind::KwAsm => {
let span = self.current_span();
self.advance(); // KwAsm