mirror of
https://github.com/ksherlock/mpw.git
synced 2024-06-08 18:29:28 +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.
|
# this exits with cs == lexer_en_error.
|
||||||
error := any* ${ fbreak; };
|
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 := |*
|
main := |*
|
||||||
|
|
||||||
[ \t\r\n]+;
|
[ \t\r\n]+;
|
||||||
|
@ -136,8 +157,14 @@ namespace {
|
||||||
'>' { Parse(parser, tkGT, 0, command); };
|
'>' { Parse(parser, tkGT, 0, command); };
|
||||||
|
|
||||||
':' { Parse(parser, tkCOLON, 0, command); };
|
':' { Parse(parser, tkCOLON, 0, command); };
|
||||||
|
|
||||||
'@' { Parse(parser, tkAT, 0, command); };
|
'@' { Parse(parser, tkAT, 0, command); };
|
||||||
|
|
||||||
|
';' {
|
||||||
|
Parse(parser, tkSEMI, 0, command);
|
||||||
|
fgoto semi;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
'$' xdigit + {
|
'$' xdigit + {
|
||||||
uint32_t value = scan16(ts + 1, te);
|
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
|
# generic identifier
|
||||||
# since % is a valid character, should drop %/modulo operator.
|
# since % is a valid character, should drop %/modulo operator.
|
||||||
[%_A-Za-z][%_.A-Za-z0-9]* {
|
[%_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);
|
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);
|
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);
|
Debug::Dump(a.intValue, b.intValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stmt ::= expr(a) SEMII EOL.
|
stmt ::= expr(a) SEMI SEMII EOL.
|
||||||
{
|
{
|
||||||
MM::Native::MemoryInfo(a.intValue);
|
MM::Native::MemoryInfo(a.intValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stmt ::= expr(a) SEMIL EOL.
|
stmt ::= expr(a) SEMI SEMIL EOL.
|
||||||
{
|
{
|
||||||
Debug::List(a.intValue);
|
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);
|
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);
|
Debug::List(a.intValue, b.intValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user