mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-29 13:28:19 +00:00
Enable the parser to pass the next token to be returned to the lexer
Currently the parser can not directly influence the lexer output. This limits the grammar and also how the parser can be invoked. Allow the parser to pass the next TOKEN that the lexer will return. This is has two uses: It allows us to trick the bison parser into having multiple start symbols, allowing us to say invoke the parser on an individual network or file rule. It also allows the semantic analysis of the parser to change the language recognized. This can be leveraged to overcome some of the limitation of bison's LALR parse generator. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Kees Cook <kees@ubuntu.com>
This commit is contained in:
parent
8a3edd677c
commit
18c87e98bf
@ -25,6 +25,11 @@
|
||||
#include "libapparmor_re/apparmor_re.h"
|
||||
#include "libapparmor_re/aare_rules.h"
|
||||
|
||||
/* Global variable to pass token to lexer. Will be replaced by parameter
|
||||
* when lexer and parser are made reentrant
|
||||
*/
|
||||
extern int parser_token;
|
||||
|
||||
typedef enum pattern_t pattern_t;
|
||||
|
||||
struct flagval {
|
||||
|
@ -222,6 +222,15 @@ LT_EQUAL <=
|
||||
|
||||
%%
|
||||
|
||||
%{
|
||||
/* Copied directly into yylex function */
|
||||
if (parser_token) {
|
||||
int t = parser_token;
|
||||
parser_token = 0;
|
||||
return t;
|
||||
}
|
||||
%}
|
||||
|
||||
<INCLUDE>{
|
||||
{WS}+ { /* Eat whitespace */ }
|
||||
\<([^\> \t\n]+)\> { /* <filename> */
|
||||
|
@ -69,6 +69,8 @@ struct value_list {
|
||||
struct value_list *next;
|
||||
};
|
||||
|
||||
int parser_token = 0;
|
||||
|
||||
void free_value_list(struct value_list *list);
|
||||
struct cod_entry *do_file_rule(char *namespace, char *id, int mode,
|
||||
char *link_id, char *nt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user