GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 5 / 0 / 5
Functions: 100.0% 1 / 0 / 1
Branches: 100.0% 2 / 0 / 2

core/parser/scriptparser.h
Line Branch Exec Source
1 // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al.
2 // http://avisynth.nl
3
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
17 // http://www.gnu.org/copyleft/gpl.html .
18 //
19 // Linking Avisynth statically or dynamically with other modules is making a
20 // combined work based on Avisynth. Thus, the terms and conditions of the GNU
21 // General Public License cover the whole combination.
22 //
23 // As a special exception, the copyright holders of Avisynth give you
24 // permission to link Avisynth with independent modules that communicate with
25 // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
26 // terms of these independent modules, and to copy and distribute the
27 // resulting combined work under terms of your choice, provided that
28 // every copy of the combined work is accompanied by a complete copy of
29 // the source code of Avisynth (the version of Avisynth used to produce the
30 // combined work), being distributed under the terms of the GNU General
31 // Public License plus this exception. An independent module is a module
32 // which is not derived from or based on Avisynth, such as 3rd-party filters,
33 // import and export plugins, or graphical user interfaces.
34
35 #ifndef __ScriptParser_H__
36 #define __ScriptParser_H__
37
38 #include <avisynth.h>
39 #include "expression.h"
40 #include "tokenizer.h"
41 #include "script.h"
42
43
44 /********************************************************************
45 ********************************************************************/
46
47
48
49 class ScriptParser
50 /**
51 * Insert intelligent comment here
52 **/
53 {
54 public:
55 ScriptParser(IScriptEnvironment* _env, const char* _code, const char* _filename);
56
57 PExpression Parse(void);
58
59 enum {max_args=1024};
60 // fixme: consider using vectors
61
62 private:
63 IScriptEnvironment2* const env;
64 Tokenizer tokenizer;
65 const char* const code;
66 const char* const filename;
67 int loopDepth; // how many loops are we in during parsing
68
69 void Expect(int op, const char* msg);
70
71 PExpression ParseFunctionDefinition(void);
72
73 PExpression ParseBlock(bool braced, bool *empty);
74 PExpression ParseStatement(bool* stop);
75 PExpression ParseAssignment(void);
76 PExpression ParseAssignmentWithRet(void);
77 PExpression ParseConditional(void);
78 PExpression ParseOr(void);
79 PExpression ParseAnd(void);
80 PExpression ParseComparison(void);
81 PExpression ParseAddition(bool negationOnHold);
82 PExpression ParseMultiplication(bool negationOnHold);
83 PExpression ParseUnary(void);
84 PExpression ParseOOP(void);
85 PExpression ParseArray(PExpression context);
86 PExpression ParseFunction(PExpression context);
87 PExpression ParseCall(PExpression left, PExpression context, bool isArraySpecifier);
88 PExpression ParseAtom(void);
89
90 PExpression ParseIf(void);
91 PExpression ParseWhile(void);
92 PExpression ParseFor(void);
93
94 // helper for ParseComparison
95 int GetTokenAsComparisonOperator();
96 };
97
98 // The following allows us to write multi-character tokens as string literals.
99 // Originally, non-conformant multi-character characters were used.
100 // For example: int('012') == 0x303132. Hence, the rightmost character
101 // is placed at the least significant byte.
102 24 static constexpr int operator ""_i(const char s[], const size_t len) {
103 24 int acc = 0;
104
2/2
✓ Branch 4 → 3 taken 48 times.
✓ Branch 4 → 5 taken 24 times.
72 for (size_t i = 0; i < len; ++i)
105 48 acc = (acc << 8) + (unsigned char) s[i];
106 24 return acc;
107 }
108
109
110 #endif // __ScriptParser_H__
111