/* * Copyright (C) 2022 Nick Downing * SPDX-License-Identifier: GPL-2.0-only * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; version 2. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ %{ import element import t_def import y_tab %} %option nodefault %start DATA REM %% { " " } { \x83 { BEGIN(DATA) return ord(yytext) } \xb2 { BEGIN(REM) return ord(yytext) } (?E{t_def.IntLiteral}(?E{t_def.Text.Char}[0-9])(\ *(?E{t_def.Text.Char}[0-9]))*) { return y_tab.INT_LITERAL } (?E{t_def.VariableName}(?E{t_def.Text.Char}[A-Z])(\ *(?E{t_def.Text.Char}[A-Z0-9])(\ *[A-Z0-9])*)?(\ *(?E{t_def.Text.Char}[$%]))?) { return y_tab.VARIABLE_NAME } (?E{t_def.IntLiteral}(?E{t_def.Text.Char}[0-9])(\ *(?E{t_def.Text.Char}[0-9]))*) { return y_tab.INT_LITERAL } (?E{t_def.FloatLiteral}((?E{t_def.FloatLiteral.Integer}(?E{t_def.Text.Char}[0-9])(\ *(?E{t_def.Text.Char}[0-9]))*)(?E{t_def.FloatLiteral.Fraction}"")|(?E{t_def.FloatLiteral.Integer}((?E{t_def.Text.Char}[0-9])\ *)*)(?E{t_def.FloatLiteral.Fraction}\.(\ *(?E{t_def.Text.Char}[0-9]))*))(?E{t_def.FloatLiteral.Exponent}\ *E(?E{t_def.FloatLiteral.Sign}(\ *(?E{t_def.Text.Char}[+-]))?)\ *(?E{t_def.FloatLiteral.Integer}(?E{t_def.Text.Char}[0-9])(\ *(?E{t_def.Text.Char}[0-9]))*))?) { return y_tab.FLOAT_LITERAL } } { \"(?E{t_def.StrLiteral}[^"\n]*)\" { return y_tab.STR_LITERAL } \"(?E{t_def.StrLiteral}[^"\n]*)$ { return y_tab.STR_LITERAL } } { \xcf\ *\xd0|\xd0\ *\xcf { return y_tab.OPERATOR_GE } \xd1\ *\xd0|\xd0\ *\xd1 { return y_tab.OPERATOR_LE } \xd1\ *\xcf|\xcf\ *\xd1 { return y_tab.OPERATOR_NE } } { (?E{t_def.DataText}[^\n ",:][^\n,:]*) { return y_tab.DATA_TEXT } :|\n { BEGIN(INITIAL) return ord(yytext[0]) } } { .|\n { return ord(yytext[0]) } } { (?E{t_def.RemText}.*) { return y_tab.REM_TEXT } \n { BEGIN(INITIAL) return ord(yytext[0]) } }