mirror of
https://github.com/ksherlock/mpw.git
synced 2025-02-09 13:30:51 +00:00
move semi-colon commands to their own state
This commit is contained in:
parent
05317be1e1
commit
e2700665d0
43
bin/lexer.rl
43
bin/lexer.rl
@ -105,6 +105,27 @@ namespace {
|
||||
# this exits with cs == lexer_en_error.
|
||||
error := any* ${ fbreak; };
|
||||
|
||||
# semi-colon commands.
|
||||
semi := |*
|
||||
|
||||
[ \t\r\n]+;
|
||||
|
||||
'h'i | 'hd'i | 'hexdump'i {
|
||||
Parse(parser, tkSEMIH, 0, command);
|
||||
};
|
||||
|
||||
'i'i | 'info'i {
|
||||
Parse(parser, tkSEMII, 0, command);
|
||||
};
|
||||
|
||||
'l'i | 'list'i {
|
||||
Parse(parser, tkSEMIL, 0, command);
|
||||
};
|
||||
|
||||
|
||||
|
||||
*|;
|
||||
|
||||
main := |*
|
||||
|
||||
[ \t\r\n]+;
|
||||
@ -136,8 +157,14 @@ namespace {
|
||||
'>' { Parse(parser, tkGT, 0, command); };
|
||||
|
||||
':' { Parse(parser, tkCOLON, 0, command); };
|
||||
|
||||
'@' { Parse(parser, tkAT, 0, command); };
|
||||
|
||||
';' {
|
||||
Parse(parser, tkSEMI, 0, command);
|
||||
fgoto semi;
|
||||
};
|
||||
|
||||
|
||||
'$' xdigit + {
|
||||
uint32_t value = scan16(ts + 1, te);
|
||||
@ -261,22 +288,6 @@ namespace {
|
||||
};
|
||||
|
||||
|
||||
# TODO - split the ; commands into two parts.
|
||||
# struct Token {std::string sValue; uint32_t intValue; enum Command { dump, list, ... }};
|
||||
';h'i | ';hd'i | ';hexdump'i {
|
||||
Parse(parser, tkSEMIH, 0, command);
|
||||
};
|
||||
|
||||
';i'i | ';info'i {
|
||||
Parse(parser, tkSEMII, 0, command);
|
||||
};
|
||||
|
||||
';l'i | ';list'i {
|
||||
Parse(parser, tkSEMIL, 0, command);
|
||||
};
|
||||
|
||||
|
||||
|
||||
# generic identifier
|
||||
# since % is a valid character, should drop %/modulo operator.
|
||||
[%_A-Za-z][%_.A-Za-z0-9]* {
|
||||
|
@ -158,39 +158,39 @@ stmt ::= LIST expr(a) EOL.
|
||||
}
|
||||
|
||||
|
||||
stmt ::= expr(a) SEMIH EOL.
|
||||
stmt ::= expr(a) SEMI SEMIH EOL.
|
||||
{
|
||||
Debug::Dump(a.intValue);
|
||||
}
|
||||
|
||||
stmt ::= expr(a) COLON expr(b) SEMIH EOL.
|
||||
stmt ::= expr(a) COLON expr(b) SEMI SEMIH EOL.
|
||||
{
|
||||
Debug::Dump(a.intValue, b.intValue - a.intValue);
|
||||
}
|
||||
|
||||
stmt ::= expr(a) AT expr(b) SEMIH EOL.
|
||||
stmt ::= expr(a) AT expr(b) SEMI SEMIH EOL.
|
||||
{
|
||||
Debug::Dump(a.intValue, b.intValue);
|
||||
}
|
||||
|
||||
|
||||
stmt ::= expr(a) SEMII EOL.
|
||||
stmt ::= expr(a) SEMI SEMII EOL.
|
||||
{
|
||||
MM::Native::MemoryInfo(a.intValue);
|
||||
}
|
||||
|
||||
|
||||
stmt ::= expr(a) SEMIL EOL.
|
||||
stmt ::= expr(a) SEMI SEMIL EOL.
|
||||
{
|
||||
Debug::List(a.intValue);
|
||||
}
|
||||
|
||||
stmt ::= expr(a) AT expr(b) SEMIL EOL.
|
||||
stmt ::= expr(a) AT expr(b) SEMI SEMIL EOL.
|
||||
{
|
||||
Debug::List(a.intValue, (int)b.intValue);
|
||||
}
|
||||
|
||||
stmt ::= expr(a) COLON expr(b) SEMIL EOL.
|
||||
stmt ::= expr(a) COLON expr(b) SEMI SEMIL EOL.
|
||||
{
|
||||
Debug::List(a.intValue, b.intValue);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user