Plan 9 from Bell Labs’s /usr/web/sources/contrib/de0u/root/sys/src/cmd/divergefs/config.y

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


%{
#include <u.h>
#include <libc.h>
#include "common.h"
#include "debug.h"
#include "configyacclex.h"

yylex(void); /* matches lex output as of 2008-10-24 */

void yyerror(char *err);
int yywrap(void);

extern int yylineno;

#ifndef YYABORT
  #define YYABORT return 1
#endif

#define DEBUG_YACC false

int outfd = 2;

/**
 * @todo add ability to have comments
 */

%}

%token TOKEN_WORD TOKEN_SETTING TOKEN_PATH 
%token TOKEN_AND TOKEN_OR 
%token TOKEN_LPAREN TOKEN_RPAREN

%%

rules:
  /* empty */ 
  | rules rule
  ;

rule:
  path 
  {
    NOISE(DEBUG_YACC, "yyparse got path: %s", $1);
    config_set_currentpath($1);
  }
  complexsetting
  {
    NOISE(DEBUG_YACC, "yyparse completes setting");
    config_rule_end();
  }
  ;

complexsetting:
  simplesetting
  |
  complexsetting TOKEN_OR simplesetting
  {
    NOISE(DEBUG_YACC, "yyparse got || setting");
    config_or_setting();
  }

simplesetting:
  setting
  |
  simplesetting TOKEN_AND setting
  {
    NOISE(DEBUG_YACC, "yyparse got && setting");
    config_and_setting();
  }

setting:
  TOKEN_LPAREN complexsetting TOKEN_RPAREN
  {
    NOISE(DEBUG_YACC, "yyparse got parenthesized rule");
  }
  |
  TOKEN_WORD TOKEN_SETTING
  {
    NOISE(DEBUG_YACC, "yyparse got rule: %s setting: %s", $1, $2);
    config_push_setting($1, $2);
  }

path:
  TOKEN_WORD 
  |
  TOKEN_PATH
  ;
  
%%

void yyerror(char *err)
{
  ERROR(DEBUG_YACC, "yyparse %s on line %d", err, yylineno);
}

int yywrap(void)
{
  return 1;
}



Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].