Add /deps.sh, in /linapple remove full-screen mode to make it run properly on recent...
[applesoft_basic.git] / applesoft_basic.l
1 /*
2  * Copyright (C) 2022 Nick Downing <nick@ndcode.org>
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; version 2.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 %{
20   import element
21   import t_def
22   import y_tab
23 %}
24
25 %option nodefault
26 %start DATA REM
27
28 %%
29
30 <INITIAL,DATA>{
31   " "
32 }
33 <INITIAL>{
34   \x83 {
35     BEGIN(DATA)
36     return ord(yytext)
37   }
38   \xb2 {
39     BEGIN(REM)
40     return ord(yytext)
41   }
42   (?E{t_def.IntLiteral}(?E{t_def.Text.Char}[0-9])(\ *(?E{t_def.Text.Char}[0-9]))*) {
43     return y_tab.INT_LITERAL
44   }
45   (?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}[$%]))?) {
46     return y_tab.VARIABLE_NAME
47   }
48   (?E{t_def.IntLiteral}(?E{t_def.Text.Char}[0-9])(\ *(?E{t_def.Text.Char}[0-9]))*) {
49     return y_tab.INT_LITERAL
50   }
51   (?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]))*))?) {
52     return y_tab.FLOAT_LITERAL
53   }
54 }
55 <INITIAL,DATA>{
56   \"(?E{t_def.StrLiteral}[^"\n]*)\" {
57     return y_tab.STR_LITERAL
58   }
59   \"(?E{t_def.StrLiteral}[^"\n]*)$ {
60     return y_tab.STR_LITERAL
61   }
62 }
63 <INITIAL>{
64   \xcf\ *\xd0|\xd0\ *\xcf {
65     return y_tab.OPERATOR_GE
66   }
67   \xd1\ *\xd0|\xd0\ *\xd1 {
68     return y_tab.OPERATOR_LE
69   }
70   \xd1\ *\xcf|\xcf\ *\xd1 {
71     return y_tab.OPERATOR_NE
72   }
73 }
74 <DATA>{
75   (?E{t_def.DataText}[^\n ",:][^\n,:]*) {
76     return y_tab.DATA_TEXT
77   }
78   :|\n {
79     BEGIN(INITIAL)
80     return ord(yytext[0])
81   }
82 }
83 <INITIAL,DATA>{
84   .|\n {
85     return ord(yytext[0])
86   }
87 }
88
89 <REM>{
90   (?E{t_def.RemText}.*) {
91     return y_tab.REM_TEXT
92   }
93   \n {
94     BEGIN(INITIAL)
95     return ord(yytext[0])
96   }
97 }