[apparmor] [PATCH 7/9] Rework how the lexer identifies hat names following a ^

John Johansen john.johansen at canonical.com
Wed Dec 28 03:01:50 UTC 2011


Reworking this code is a step to getting rid of the SUB_NAME2 start
condition.
---
 parser/parser_lex.l  |    9 ++++-----
 parser/parser_yacc.y |    4 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/parser/parser_lex.l b/parser/parser_lex.l
index 64b6a2e..1d59f43 100644
--- a/parser/parser_lex.l
+++ b/parser/parser_lex.l
@@ -168,13 +168,12 @@ void include_filename(char *filename, int search)
 
 %}
 
-UP		"^"
+CARET		"^"
 OPEN_BRACE 	\{
 CLOSE_BRACE 	\}
 SLASH		\/
 COLON		:
 END_OF_RULE	[,]
-SEPARATOR 	{UP}
 RANGE		-
 MODE_CHARS 	([RrWwaLlMmkXx])|(([Pp]|[Cc])[Xx])|(([Pp]|[Cc])?([IiUu])[Xx])
 MODES		{MODE_CHARS}+
@@ -447,11 +446,11 @@ LT_EQUAL	<=
 
 {END_OF_RULE}		{ DUMP_PREPROCESS; return TOK_END_OF_RULE; }
 
-{SEPARATOR}		{
+{CARET}			{
 			DUMP_PREPROCESS;
-			PDEBUG("Matched a separator\n");
+			PDEBUG("Matched hat ^\n");
 			yy_push_state(SUB_NAME);
-			return TOK_SEP;
+			return TOK_CARET;
 			}
 {ARROW}			{
 			DUMP_PREPROCESS;
diff --git a/parser/parser_yacc.y b/parser/parser_yacc.y
index b76c69e..1b169f0 100644
--- a/parser/parser_yacc.y
+++ b/parser/parser_yacc.y
@@ -78,7 +78,7 @@ void add_local_entry(struct codomain *cod);
 %}
 
 %token TOK_ID
-%token TOK_SEP
+%token TOK_CARET
 %token TOK_OPEN
 %token TOK_CLOSE
 %token TOK_MODE
@@ -1009,7 +1009,7 @@ network_rule: TOK_NETWORK TOK_ID TOK_ID TOK_END_OF_RULE
 		$$ = entry;
 	}
 
-hat_start: TOK_SEP {}
+hat_start: TOK_CARET {}
 	| TOK_HAT {}
 
 file_mode: TOK_MODE
-- 
1.7.7.3




More information about the AppArmor mailing list