Generate ASM, ENDASM and SCRIPT, ENDSCRIPT asm comments in output
This commit is contained in:
parent
6085bccad3
commit
d09a039697
1 changed files with 29 additions and 0 deletions
|
|
@ -34,8 +34,28 @@ func (c *Compiler) Registry() *CommandRegistry {
|
|||
// Compile processes preprocessed lines and generates assembly output
|
||||
func (c *Compiler) Compile(lines []preproc.Line) ([]string, error) {
|
||||
var codeOutput []string
|
||||
var lastKind = preproc.Source
|
||||
|
||||
for _, line := range lines {
|
||||
// Detect kind transitions and emit markers
|
||||
if line.Kind != lastKind {
|
||||
// Close previous block
|
||||
if lastKind == preproc.Assembler {
|
||||
codeOutput = append(codeOutput, "; ENDASM")
|
||||
} else if lastKind == preproc.Script {
|
||||
codeOutput = append(codeOutput, "; ENDSCRIPT")
|
||||
}
|
||||
|
||||
// Open new block
|
||||
if line.Kind == preproc.Assembler {
|
||||
codeOutput = append(codeOutput, "; ASM")
|
||||
} else if line.Kind == preproc.Script {
|
||||
codeOutput = append(codeOutput, "; SCRIPT")
|
||||
}
|
||||
|
||||
lastKind = line.Kind
|
||||
}
|
||||
|
||||
// Skip non-source lines (assembler and script handled differently)
|
||||
if line.Kind != preproc.Source {
|
||||
if line.Kind == preproc.Assembler {
|
||||
|
|
@ -88,6 +108,15 @@ func (c *Compiler) Compile(lines []preproc.Line) ([]string, error) {
|
|||
codeOutput = append(codeOutput, asmLines...)
|
||||
}
|
||||
|
||||
// Close any open block
|
||||
if lastKind == preproc.Assembler {
|
||||
//codeOutput = append(codeOutput, "; ENDASM")
|
||||
return nil, fmt.Errorf("Unclosed ASM block.")
|
||||
} else if lastKind == preproc.Script {
|
||||
//codeOutput = append(codeOutput, "; ENDSCRIPT")
|
||||
return nil, fmt.Errorf("Unclosed SCRIPT block.")
|
||||
}
|
||||
|
||||
// Assemble final output with headers and footers
|
||||
return c.assembleOutput(codeOutput), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue