Scrap preprocessor, add .include directive instead

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-02-27 15:52:17 -05:00
parent 0eb394ddf5
commit 4b96902831
12 changed files with 234 additions and 279 deletions

View File

@@ -1,20 +1,21 @@
%start SectionDefs
%start Top
%%
SectionDefs -> Vec<SectionDef>:
SectionDefs SectionDef { $1.push($2); $1 }
| { Vec::new() }
Top -> Vec<Directive>:
Top Directive { $1.push($2); $1 }
| { Vec::new() }
;
SectionDef -> SectionDef:
'DIR_META' MetaBlock { SectionDef::Meta(MetaSection { lines: $2 }) }
Directive -> Directive:
'DIR_META' MetaBlock { Directive::Meta(MetaSection { lines: $2 }) }
| 'DIR_SECTION' Name SectionOrg DataBlock {
SectionDef::Data(DataSection {
Directive::Data(DataSection {
name: $2,
org: $3,
lines: $4,
})
}
| 'DIR_INCLUDE' String { Directive::Include($2) }
;
MetaBlock -> Vec<MetaLine>: 'LBRACE' MetaLines 'RBRACE' { $2 };
@@ -158,7 +159,7 @@ use crate::vm::{
fn parse_string(input: &str) -> String {
let mut s = String::new();
let input = &input[1..input.bytes().len() - 2];
let input = &input[1..input.bytes().len() - 1];
let mut chars = input.chars();
while let Some(c) = chars.next() {
if c == '\\' {