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%option bison-bridge bison-locations 14 15%option prefix="mza_yy" 16 17%{ 18#include <cstdlib> 19#include <minizinc/support/mza_parser.hh> 20 21using namespace MiniZinc; 22 23#define YY_USER_ACTION { yylloc->first_line = yylineno; } 24%} 25 26%% 27 28\n { yylineno++; } 29[ \t] { /* ignore white space */ } 30%[^\xa]* { /* ignore comments */ } 31"-"?[0-9]+ { yylval->iValue = std::atoi(yytext); return MZA_INT; } 32[Rr][0-9]+ { yylval->iValue = std::atoi(yytext+1); return MZA_REG; } 33":" { return MZA_COLON; } 34[dD] { return MZA_DELAY; } 35 36"GLOBAL" { return MZA_GLOBAL; } 37 38"ADDI" { yylval->bValue = BytecodeStream::ADDI; return MZA_ADDI; } 39"SUBI" { yylval->bValue = BytecodeStream::SUBI; return MZA_SUBI; } 40"MULI" { yylval->bValue = BytecodeStream::MULI; return MZA_MULI; } 41"DIVI" { yylval->bValue = BytecodeStream::DIVI; return MZA_DIVI; } 42"MODI" { yylval->bValue = BytecodeStream::MODI; return MZA_MODI; } 43"INCI" { yylval->bValue = BytecodeStream::INCI; return MZA_INCI; } 44"DECI" { yylval->bValue = BytecodeStream::DECI; return MZA_DECI; } 45 46"IMMI" { yylval->bValue = BytecodeStream::IMMI; return MZA_IMMI; } 47"CLEAR" { yylval->bValue = BytecodeStream::CLEAR; return MZA_CLEAR; } 48"LOAD_GLOBAL" { yylval->bValue = BytecodeStream::LOAD_GLOBAL; return MZA_LOAD_GLOBAL; } 49"STORE_GLOBAL" { yylval->bValue = BytecodeStream::STORE_GLOBAL; return MZA_STORE_GLOBAL; } 50"MOV" { yylval->bValue = BytecodeStream::MOV; return MZA_MOV; } 51 52"JMP" { yylval->bValue = BytecodeStream::JMP; return MZA_JMP; } 53"JMPIF" { yylval->bValue = BytecodeStream::JMPIF; return MZA_JMPIF; } 54"JMPIFNOT" { yylval->bValue = BytecodeStream::JMPIFNOT; return MZA_JMPIFNOT; } 55 56"EQI" { yylval->bValue = BytecodeStream::EQI; return MZA_EQI; } 57"LTI" { yylval->bValue = BytecodeStream::LTI; return MZA_LTI; } 58"LEI" { yylval->bValue = BytecodeStream::LEI; return MZA_LEI; } 59 60"AND" { yylval->bValue = BytecodeStream::AND; return MZA_AND; } 61"OR" { yylval->bValue = BytecodeStream::OR; return MZA_OR; } 62"NOT" { yylval->bValue = BytecodeStream::NOT; return MZA_NOT; } 63"XOR" { yylval->bValue = BytecodeStream::XOR; return MZA_XOR; } 64 65"ISPAR" { yylval->bValue = BytecodeStream::ISPAR; return MZA_ISPAR; } 66"ISEMPTY" { yylval->bValue = BytecodeStream::ISEMPTY; return MZA_ISEMPTY; } 67"LENGTH" { yylval->bValue = BytecodeStream::LENGTH; return MZA_LENGTH; } 68"GET_VEC" { yylval->bValue = BytecodeStream::GET_VEC; return MZA_GET_VEC; } 69"GET_ARRAY" { yylval->bValue = BytecodeStream::GET_ARRAY; return MZA_GET_ARRAY; } 70 71"LB" { yylval->bValue = BytecodeStream::LB; return MZA_LB; } 72"UB" { yylval->bValue = BytecodeStream::UB; return MZA_UB; } 73"DOM" { yylval->bValue = BytecodeStream::DOM; return MZA_DOM; } 74 75"MAKE_SET" { yylval->bValue = BytecodeStream::MAKE_SET; return MZA_MAKE_SET; } 76"DIFF" { yylval->bValue = BytecodeStream::DIFF; return MZA_DIFF; } 77"INTERSECTION" { yylval->bValue = BytecodeStream::INTERSECTION; return MZA_INTERSECTION; } 78"UNION" { yylval->bValue = BytecodeStream::UNION; return MZA_UNION; } 79 80"INTERSECT_DOMAIN" { yylval->bValue = BytecodeStream::INTERSECT_DOMAIN; return MZA_INTERSECT_DOMAIN; } 81 82"OPEN_AGGREGATION" { yylval->bValue = BytecodeStream::OPEN_AGGREGATION; return MZA_OPEN_AGGREGATION; } 83"CLOSE_AGGREGATION" { yylval->bValue = BytecodeStream::CLOSE_AGGREGATION; return MZA_CLOSE_AGGREGATION; } 84"SIMPLIFY_LIN" { yylval->bValue = BytecodeStream::SIMPLIFY_LIN; return MZA_SIMPLIFY_LIN; } 85 86"PUSH" { yylval->bValue = BytecodeStream::PUSH; return MZA_PUSH; } 87"POP" { yylval->bValue = BytecodeStream::POP; return MZA_POP; } 88"POST" { yylval->bValue = BytecodeStream::POST; return MZA_POST; } 89 90"RET" { yylval->bValue = BytecodeStream::RET; return MZA_RET; } 91"CALL" { yylval->bValue = BytecodeStream::CALL; return MZA_CALL; } 92"BUILTIN" { yylval->bValue = BytecodeStream::BUILTIN; return MZA_BUILTIN; } 93"TCALL" { yylval->bValue = BytecodeStream::TCALL; return MZA_TCALL; } 94 95"ITER_ARRAY" { yylval->bValue = BytecodeStream::ITER_ARRAY; return MZA_ITER_ARRAY; } 96"ITER_VEC" { yylval->bValue = BytecodeStream::ITER_VEC; return MZA_ITER_VEC; } 97"ITER_RANGE" { yylval->bValue = BytecodeStream::ITER_RANGE; return MZA_ITER_RANGE; } 98"ITER_NEXT" { yylval->bValue = BytecodeStream::ITER_NEXT; return MZA_ITER_NEXT; } 99"ITER_BREAK" { yylval->bValue = BytecodeStream::ITER_BREAK; return MZA_ITER_BREAK; } 100"TRACE" { yylval->bValue = BytecodeStream::TRACE; return MZA_TRACE; } 101"ABORT" { yylval->bValue = BytecodeStream::ABORT; return MZA_ABORT; } 102 103"VEC" { yylval->iValue = AggregationCtx::VCTX_VEC; return MZA_CTX; } 104"OTHER" { yylval->iValue = AggregationCtx::VCTX_OTHER; return MZA_CTX; } 105 106"ROOT" { yylval->iValue = BytecodeProc::ROOT; return MZA_MODE; } 107"ROOT_NEG" { yylval->iValue = BytecodeProc::ROOT_NEG; return MZA_MODE; } 108"FUN" { yylval->iValue = BytecodeProc::FUN; return MZA_MODE; } 109"FUN_NEG" { yylval->iValue = BytecodeProc::FUN_NEG; return MZA_MODE; } 110"IMP" { yylval->iValue = BytecodeProc::IMP; return MZA_MODE; } 111"IMP_NEG" { yylval->iValue = BytecodeProc::IMP_NEG; return MZA_MODE; } 112 113 114[A-Za-z][A-Za-z0-9_]* { yylval->sValue = strdup(yytext); return MZA_ID; } 115"'"[^\\'\xa\xd\x0]*"'" { yylval->sValue = strdup(yytext); return MZA_ID; } 116 117. { 118 /* Catch all */ 119 throw std::runtime_error("Illegal token in regular expression: '" + std::string(yytext) + "'"); 120} 121 122%%