this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 3/* 4 * Main authors: 5 * Jip J. Dekker <jip.dekker@monash.edu> 6 */ 7 8/* This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 11 12%option noyywrap 13 14%option prefix="regex_yy" 15 16%{ 17#include <cstdlib> 18 19#define YY_DECL int yylex() 20 21#include <minizinc/support/regex.hh> 22 23%} 24 25%% 26 27[ \t\n] { /* ignore white space */ } 28[0-9]+ { regex_yylval.iValue = std::atoi(regex_yytext); return R_INTEGER; } 29"|" { return R_UNION; } 30"+" { return R_PLUS; } 31"*" { return R_STAR; } 32"(" { return R_GROUP_OPEN; } 33")" { return R_GROUP_CLOSE; } 34"?" { return R_OPTIONAL; } 35"{" { return R_QUANT_OPEN; } 36"}" { return R_QUANT_CLOSE; } 37"," { return R_COMMA; } 38"." { return R_ANY; } 39"[" { return R_CLASS_OPEN; } 40"]" { return R_CLASS_CLOSE; } 41"-" { return R_CLASS_RANGE; } 42"^" { return R_CLASS_NEG; } 43 44[A-Za-z][A-Za-z0-9_]* { regex_yylval.sValue = strdup(yytext); return R_IDENTIFIER; } 45"'"[^\\'\xa\xd\x0]*"'" { regex_yylval.sValue = strdup(yytext); return R_IDENTIFIER; } 46 47. { 48 /* Catch all */ 49 throw std::runtime_error("Illegal token in regular expression: '" + std::string(regex_yytext) + "'"); 50} 51 52%%