blob: 97b69005b91de6b030e75e120a02d6265a9153db [file] [edit]
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "drbdadm_parser.h"
#include "drbdadm.h"
#include "drbdtool_common.h"
void long_string(char* text);
void long_dqstring(char* text);
void err_dqstring(char* text);
#if 0
#define DP printf("'%s' ",yytext)
#else
#define DP
#endif
#define CP yylval.txt = strdup(yytext);
#define YY_NO_INPUT 1
#define YY_NO_UNPUT 1
#ifndef YY_FLEX_SUBMINOR_VERSION
#define MAX_INCLUDE_DEPTH 10
YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
int include_stack_ptr = 0;
#endif
%}
%option noyywrap
%option nounput
NUM [0-9]{1,8}[MKGs]?
SNUMB [0-9]{1,3}
IPV4ADDR ({SNUMB}"."){3}{SNUMB}
HEX4 [0-9a-fA-F]{1,4}
IPV6ADDR ((({HEX4}":"){0,5}{HEX4})?":"{HEX4}?":"({HEX4}(":"{HEX4}){0,5})?("%"{STRING})?)|("::"[fF]{4}":"{IPV4ADDR})
WS [ \t\r]
OPCHAR [{};\[\]:]
DQSTRING \"([^\"\\\n]|\\[^\n]){0,255}\"
LONG_DQSTRING \"([^\"\\\n]|\\[^\n]){255}.
ERR_DQSTRING \"([^\"\\\n]|\\[^\n]){0,255}[\\\n]
STRING [a-zA-Z0-9/._-]{1,128}
LONG_STRING [a-zA-Z0-9/._-]{129}
%%
\n { line++; }
\#.* /* ignore comments */
{WS} /* ignore whitespaces */
{OPCHAR} { DP; return yytext[0]; }
on { DP; return TK_ON; }
stacked-on-top-of { DP; return TK_STACKED; }
floating { DP; return TK_FLOATING; }
no { DP; return TK_NO; }
net { DP; return TK_NET; }
yes { DP; return TK_YES; }
ask { DP; return TK_ASK; }
via { DP; return TK_VIA; }
skip { DP; return TK_SKIP; }
disk { DP; return TK_DISK; }
host { DP; return TK_HOST; }
hosts { DP; return TK_HOSTS; }
port { DP; return TK_PORT; }
proxy { DP; return TK_PROXY; }
minor { DP; return TK_MINOR; }
inside { DP; return TK_INSIDE; }
volume { DP; return TK_VOLUME; }
cmd-timeout-short { DP; return TK_CMD_TIMEOUT_SHORT; }
cmd-timeout-medium { DP; return TK_CMD_TIMEOUT_MEDIUM; }
cmd-timeout-long { DP; return TK_CMD_TIMEOUT_LONG; }
syncer { DP; return TK_SYNCER; }
device { DP; return TK_DEVICE; }
global { DP; return TK_GLOBAL; }
common { DP; return TK_COMMON; }
options { DP; return TK_OPTIONS; }
outside { DP; return TK_OUTSIDE; }
address { DP; return TK_ADDRESS; }
startup { DP; return TK_STARTUP; }
include { DP; return TK_INCLUDE; }
handlers { DP; return TK_HANDLER; }
connection { DP; return TK_CONNECTION; }
connection-mesh { DP; return TK_CONNECTION_MESH; }
minor-count { DP; return TK_MINOR_COUNT; }
disable-ip-verification { DP; return TK_DISABLE_IP_VERIFICATION;}
udev-always-use-vnr { DP; return TK_UDEV_ALWAYS_USE_VNR; }
dialog-refresh { DP; return TK_DIALOG_REFRESH; }
resource { DP; return TK_RESOURCE; }
meta-disk { DP; return TK_META_DISK; }
flexible-meta-disk { DP; return TK_FLEX_META_DISK; }
node-id { DP; return TK_NODE_ID; }
usage-count { DP; return TK_USAGE_COUNT; }
_this_host { DP; return TK__THIS_HOST; }
_remote_host { DP; return TK__REMOTE_HOST; }
_peer_node_id { DP; return TK__PEER_NODE_ID; }
_is_standalone { DP; return TK__IS_STANDALONE; }
template-file { DP; return TK_TEMPLATE_FILE; }
path { DP; return TK_PATH; }
sci { DP; CP; return TK_SCI; }
ssocks { DP; CP; return TK_SSOCKS; }
sdp { DP; CP; return TK_SDP; }
ipv4 { DP; CP; return TK_IPV4; }
ipv6 { DP; CP; return TK_IPV6; }
{IPV4ADDR} { DP; CP; return TK_IPADDR; }
{IPV6ADDR} { DP; CP; return TK_IPADDR6; }
{NUM} { DP; CP; return TK_INTEGER; }
{DQSTRING} { unescape(yytext); DP; CP; return TK_STRING; }
{STRING} { DP; CP; return TK_STRING; }
{LONG_STRING} { return TK_ERR_STRING_TOO_LONG; }
{LONG_DQSTRING} { return TK_ERR_DQSTRING_TOO_LONG; }
{ERR_DQSTRING} { return TK_ERR_DQSTRING; }
. { DP; return TK_ELSE; }
%%
/* Compatibility cruft for flex version 2.5.4a */
#ifndef YY_FLEX_SUBMINOR_VERSION
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*/
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
{
if (new_buffer == NULL)
return;
if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) {
fprintf( stderr, "Includes nested too deeply" );
exit( 1 );
}
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
yy_switch_to_buffer(new_buffer);
BEGIN(INITIAL);
}
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*/
void yypop_buffer_state (void)
{
if (!YY_CURRENT_BUFFER)
return;
if ( --include_stack_ptr < 0 ) {
fprintf( stderr, "error in flex compat code\n" );
exit( 1 );
}
yy_delete_buffer(YY_CURRENT_BUFFER );
yy_switch_to_buffer(include_stack[include_stack_ptr]);
}
#endif
void my_yypush_buffer_state(FILE *f)
{
/* Since we do not have YY_BUF_SIZE outside of the flex generated file.*/
yypush_buffer_state(yy_create_buffer(f, YY_BUF_SIZE));
}