1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.

123 lines
5.7 KiB
Plaintext

/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Jip J. Dekker <jip.dekker@monash.edu>
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
%option noyywrap
%option bison-bridge bison-locations
%option prefix="mza_yy"
%{
#include <cstdlib>
#include <minizinc/support/mza_parser.hh>
using namespace MiniZinc;
#define YY_USER_ACTION { yylloc->first_line = yylineno; }
%}
%%
\n { yylineno++; }
[ \t] { /* ignore white space */ }
%[^\xa]* { /* ignore comments */ }
"-"?[0-9]+ { yylval->iValue = std::atoi(yytext); return MZA_INT; }
[Rr][0-9]+ { yylval->iValue = std::atoi(yytext+1); return MZA_REG; }
":" { return MZA_COLON; }
[dD] { return MZA_DELAY; }
"GLOBAL" { return MZA_GLOBAL; }
"ADDI" { yylval->bValue = BytecodeStream::ADDI; return MZA_ADDI; }
"SUBI" { yylval->bValue = BytecodeStream::SUBI; return MZA_SUBI; }
"MULI" { yylval->bValue = BytecodeStream::MULI; return MZA_MULI; }
"DIVI" { yylval->bValue = BytecodeStream::DIVI; return MZA_DIVI; }
"MODI" { yylval->bValue = BytecodeStream::MODI; return MZA_MODI; }
"INCI" { yylval->bValue = BytecodeStream::INCI; return MZA_INCI; }
"DECI" { yylval->bValue = BytecodeStream::DECI; return MZA_DECI; }
"IMMI" { yylval->bValue = BytecodeStream::IMMI; return MZA_IMMI; }
"CLEAR" { yylval->bValue = BytecodeStream::CLEAR; return MZA_CLEAR; }
"LOAD_GLOBAL" { yylval->bValue = BytecodeStream::LOAD_GLOBAL; return MZA_LOAD_GLOBAL; }
"STORE_GLOBAL" { yylval->bValue = BytecodeStream::STORE_GLOBAL; return MZA_STORE_GLOBAL; }
"MOV" { yylval->bValue = BytecodeStream::MOV; return MZA_MOV; }
"JMP" { yylval->bValue = BytecodeStream::JMP; return MZA_JMP; }
"JMPIF" { yylval->bValue = BytecodeStream::JMPIF; return MZA_JMPIF; }
"JMPIFNOT" { yylval->bValue = BytecodeStream::JMPIFNOT; return MZA_JMPIFNOT; }
"EQI" { yylval->bValue = BytecodeStream::EQI; return MZA_EQI; }
"LTI" { yylval->bValue = BytecodeStream::LTI; return MZA_LTI; }
"LEI" { yylval->bValue = BytecodeStream::LEI; return MZA_LEI; }
"AND" { yylval->bValue = BytecodeStream::AND; return MZA_AND; }
"OR" { yylval->bValue = BytecodeStream::OR; return MZA_OR; }
"NOT" { yylval->bValue = BytecodeStream::NOT; return MZA_NOT; }
"XOR" { yylval->bValue = BytecodeStream::XOR; return MZA_XOR; }
"ISPAR" { yylval->bValue = BytecodeStream::ISPAR; return MZA_ISPAR; }
"ISEMPTY" { yylval->bValue = BytecodeStream::ISEMPTY; return MZA_ISEMPTY; }
"LENGTH" { yylval->bValue = BytecodeStream::LENGTH; return MZA_LENGTH; }
"GET_VEC" { yylval->bValue = BytecodeStream::GET_VEC; return MZA_GET_VEC; }
"GET_ARRAY" { yylval->bValue = BytecodeStream::GET_ARRAY; return MZA_GET_ARRAY; }
"LB" { yylval->bValue = BytecodeStream::LB; return MZA_LB; }
"UB" { yylval->bValue = BytecodeStream::UB; return MZA_UB; }
"DOM" { yylval->bValue = BytecodeStream::DOM; return MZA_DOM; }
"MAKE_SET" { yylval->bValue = BytecodeStream::MAKE_SET; return MZA_MAKE_SET; }
"DIFF" { yylval->bValue = BytecodeStream::DIFF; return MZA_DIFF; }
"INTERSECTION" { yylval->bValue = BytecodeStream::INTERSECTION; return MZA_INTERSECTION; }
"UNION" { yylval->bValue = BytecodeStream::UNION; return MZA_UNION; }
"INTERSECT_DOMAIN" { yylval->bValue = BytecodeStream::INTERSECT_DOMAIN; return MZA_INTERSECT_DOMAIN; }
"OPEN_AGGREGATION" { yylval->bValue = BytecodeStream::OPEN_AGGREGATION; return MZA_OPEN_AGGREGATION; }
"CLOSE_AGGREGATION" { yylval->bValue = BytecodeStream::CLOSE_AGGREGATION; return MZA_CLOSE_AGGREGATION; }
"SIMPLIFY_LIN" { yylval->bValue = BytecodeStream::SIMPLIFY_LIN; return MZA_SIMPLIFY_LIN; }
"PUSH" { yylval->bValue = BytecodeStream::PUSH; return MZA_PUSH; }
"POP" { yylval->bValue = BytecodeStream::POP; return MZA_POP; }
"POST" { yylval->bValue = BytecodeStream::POST; return MZA_POST; }
"RET" { yylval->bValue = BytecodeStream::RET; return MZA_RET; }
"CALL" { yylval->bValue = BytecodeStream::CALL; return MZA_CALL; }
"BUILTIN" { yylval->bValue = BytecodeStream::BUILTIN; return MZA_BUILTIN; }
"TCALL" { yylval->bValue = BytecodeStream::TCALL; return MZA_TCALL; }
"ITER_ARRAY" { yylval->bValue = BytecodeStream::ITER_ARRAY; return MZA_ITER_ARRAY; }
"ITER_VEC" { yylval->bValue = BytecodeStream::ITER_VEC; return MZA_ITER_VEC; }
"ITER_RANGE" { yylval->bValue = BytecodeStream::ITER_RANGE; return MZA_ITER_RANGE; }
"ITER_NEXT" { yylval->bValue = BytecodeStream::ITER_NEXT; return MZA_ITER_NEXT; }
"ITER_BREAK" { yylval->bValue = BytecodeStream::ITER_BREAK; return MZA_ITER_BREAK; }
"TRACE" { yylval->bValue = BytecodeStream::TRACE; return MZA_TRACE; }
"ABORT" { yylval->bValue = BytecodeStream::ABORT; return MZA_ABORT; }
"VEC" { yylval->iValue = AggregationCtx::VCTX_VEC; return MZA_CTX; }
"OTHER" { yylval->iValue = AggregationCtx::VCTX_OTHER; return MZA_CTX; }
"ROOT" { yylval->iValue = BytecodeProc::ROOT; return MZA_MODE; }
"ROOT_NEG" { yylval->iValue = BytecodeProc::ROOT_NEG; return MZA_MODE; }
"FUN" { yylval->iValue = BytecodeProc::FUN; return MZA_MODE; }
"FUN_NEG" { yylval->iValue = BytecodeProc::FUN_NEG; return MZA_MODE; }
"IMP" { yylval->iValue = BytecodeProc::IMP; return MZA_MODE; }
"IMP_NEG" { yylval->iValue = BytecodeProc::IMP_NEG; return MZA_MODE; }
[A-Za-z][A-Za-z0-9_]* { yylval->sValue = strdup(yytext); return MZA_ID; }
"'"[^\\'\xa\xd\x0]*"'" { yylval->sValue = strdup(yytext); return MZA_ID; }
. {
/* Catch all */
throw std::runtime_error("Illegal token in regular expression: '" + std::string(yytext) + "'");
}
%%