1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /* yacc file for parsing PKCS #11 module installation instructions */ 6 /*------------------------ Definition Section ---------------------------*/ 7 8 %{ 9 #define yyparse Pk11Install_yyparse 10 #define yylex Pk11Install_yylex 11 #define yyerror Pk11Install_yyerror 12 #define yychar Pk11Install_yychar 13 #define yyval Pk11Install_yyval 14 #define yylval Pk11Install_yylval 15 #define yydebug Pk11Install_yydebug 16 #define yynerrs Pk11Install_yynerrs 17 #define yyerrflag Pk11Install_yyerrflag 18 #define yyss Pk11Install_yyss 19 #define yyssp Pk11Install_yyssp 20 #define yyvs Pk11Install_yyvs 21 #define yyvsp Pk11Install_yyvsp 22 #define yylhs Pk11Install_yylhs 23 #define yylen Pk11Install_yylen 24 #define yydefred Pk11Install_yydefred 25 #define yydgoto Pk11Install_yydgoto 26 #define yysindex Pk11Install_yysindex 27 #define yyrindex Pk11Install_yyrindex 28 #define yygindex Pk11Install_yygindex 29 #define yytable Pk11Install_yytable 30 #define yycheck Pk11Install_yycheck 31 #define yyname Pk11Install_yyname 32 #define yyrule Pk11Install_yyrule 33 34 /* C Stuff */ 35 #include "install-ds.h" 36 #include <prprf.h> 37 38 #define YYSTYPE Pk11Install_Pointer 39 extern char *Pk11Install_yytext; 40 char *Pk11Install_yyerrstr=NULL; 41 42 %} 43 44 /* Tokens */ 45 %token OPENBRACE 46 %token CLOSEBRACE 47 %token STRING 48 %start toplist 49 50 %% 51 52 /*--------------------------- Productions -------------------------------*/ 53 54 toplist : valuelist 55 { 56 Pk11Install_valueList = $1.list; 57 } 58 59 valuelist : value valuelist 60 { 61 Pk11Install_ValueList_AddItem($2.list,$1.value); 62 $$.list = $2.list; 63 } 64 | 65 { 66 $$.list = Pk11Install_ValueList_new(); 67 }; 68 69 value : key_value_pair 70 { 71 $$.value= Pk11Install_Value_new(PAIR_VALUE,$1); 72 } 73 | STRING 74 { 75 $$.value= Pk11Install_Value_new(STRING_VALUE, $1); 76 }; 77 78 key_value_pair : key OPENBRACE valuelist CLOSEBRACE 79 { 80 $$.pair = Pk11Install_Pair_new($1.string,$3.list); 81 }; 82 83 key : STRING 84 { 85 $$.string = $1.string; 86 }; 87 88 %% 89 /*----------------------- Program Section --------------------------------*/ 90 91 /*************************************************************************/ 92 void 93 Pk11Install_yyerror(char *message) 94 { 95 char *tmp; 96 if(Pk11Install_yyerrstr) { 97 tmp=PR_smprintf("%sline %d: %s\n", Pk11Install_yyerrstr, 98 Pk11Install_yylinenum, message); 99 PR_smprintf_free(Pk11Install_yyerrstr); 100 } else { 101 tmp = PR_smprintf("line %d: %s\n", Pk11Install_yylinenum, message); 102 } 103 Pk11Install_yyerrstr=tmp; 104 } 105