using System; using Microsoft.Contracts; %% %line %char %namespace Microsoft.Singularity.Security.AccessControl %class AclParser %function NextToken %type AclToken %state GROUPNAME ANY=! ARC=[^./@\{()*+!\|]+|{ANY} GN=[^\}]+ LITERAL=[()|\*/\|@] ESCAPE=[\+\.] %% {ARC} { String! str = (!)yytext().Substring(0, yytext().Length); if (str.Equals("!")) { return (new AclToken(AclTokenType.Any, str, yychar, yychar + 1)); } else { return (new AclToken(AclTokenType.Arc, str, yychar, yychar + str.Length)); } } "{" {yybegin(GROUPNAME); return null;} {GN} { String! str = (!)yytext().Substring(0, yytext().Length); return (new AclToken(AclTokenType.GroupName, str, yychar, yychar + str.Length)); } "}" {yybegin(YYINITIAL); return null;} {LITERAL} { return (new AclToken(AclTokenType.Literal, yytext(), yychar, yychar+1)); } {ESCAPE} { return (new AclToken(AclTokenType.Escape, yytext(), yychar, yychar+1)); } {ANY} { return (new AclToken(AclTokenType.Any, yytext(), yychar, yychar+1)); } . { return (new AclToken(AclTokenType.Miscellaneous, yytext(), yychar, yychar+1)); } . { return (new AclToken(AclTokenType.Miscellaneous, yytext(), yychar, yychar+1)); }