mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-12-27 18:30:39 +00:00
token support for regular expression strings /.../ and \...\. Also tokenizer support for =~ and !~ operators.
This commit is contained in:
parent
6f2b59c4d6
commit
fdf33c69b7
17
error.h
17
error.h
@ -67,6 +67,21 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
class fsstring_error: public mpw_error {
|
||||
public:
|
||||
fsstring_error(int status = -3) :
|
||||
mpw_error(status, "MPW Shell - /s must occur in pairs.")
|
||||
{}
|
||||
};
|
||||
|
||||
class bsstring_error: public mpw_error {
|
||||
public:
|
||||
bsstring_error(int status = -3) :
|
||||
mpw_error(status, "MPW Shell - \\s must occur in pairs.")
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
these are used for flow-control.
|
||||
they do not inherit from std::exception to prevent being caught
|
||||
@ -78,4 +93,4 @@ struct continue_command_t {};
|
||||
struct exit_command_t { int value = 0; };
|
||||
struct quit_command_t {};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -37,6 +37,13 @@
|
||||
dchar = escape_seq | (any - escape - ["]);
|
||||
dstring = ["] dchar** ["] $err{ throw dstring_error(); } ;
|
||||
|
||||
# search-forward string
|
||||
fschar = escape_seq | (any - escape - [/]);
|
||||
fsstring = [/] fschar** [/] $err{ throw fsstring_error(); } ;
|
||||
|
||||
# search-backward string
|
||||
bschar = escape_seq | (any - escape - [\\]);
|
||||
bsstring = [\\] bschar** [\\] $err{ throw bsstring_error(); } ;
|
||||
|
||||
action eval { eval }
|
||||
|
||||
@ -127,9 +134,16 @@
|
||||
'-=' when eval
|
||||
%push_token => { tokens.emplace_back("-=", '-='); };
|
||||
|
||||
'=~' when eval
|
||||
%push_token => { tokens.emplace_back("=~", '=~'); };
|
||||
|
||||
'!~' when eval
|
||||
%push_token => { tokens.emplace_back("!~", '!~'); };
|
||||
|
||||
sstring => push_string;
|
||||
dstring => push_string;
|
||||
fsstring => push_string;
|
||||
bsstring => push_string;
|
||||
escape_seq => push_string;
|
||||
|
||||
char => push;
|
||||
|
Loading…
Reference in New Issue
Block a user