[Swfdec-commits] 8 commits - configure.ac vivified/code
Benjamin Otte
company at kemper.freedesktop.org
Fri Apr 25 09:27:26 PDT 2008
configure.ac | 2
dev/null |binary
vivified/code/test/Makefile.am | 45 -
vivified/code/test/and-or.as | 16
vivified/code/test/and-or.swf.expect | 18
vivified/code/test/compiler/Makefile.am | 17
vivified/code/test/decompiler/Makefile.am | 44 +
vivified/code/test/decompiler/and-or.as | 16
vivified/code/test/decompiler/and-or.swf |binary
vivified/code/test/decompiler/and-or.swf.expect | 18
vivified/code/test/decompiler/function-calls.as | 6
vivified/code/test/decompiler/function-calls.swf |binary
vivified/code/test/decompiler/function-calls.swf.expect | 10
vivified/code/test/decompiler/hello-world.as | 5
vivified/code/test/decompiler/hello-world.swf |binary
vivified/code/test/decompiler/hello-world.swf.expect | 8
vivified/code/test/decompiler/if-nested.as | 15
vivified/code/test/decompiler/if-nested.swf |binary
vivified/code/test/decompiler/if-nested.swf.expect | 17
vivified/code/test/decompiler/if.as | 17
vivified/code/test/decompiler/if.swf |binary
vivified/code/test/decompiler/if.swf.expect | 15
vivified/code/test/decompiler/loop-empty.swf |binary
vivified/code/test/decompiler/loop-empty.swf.expect | 8
vivified/code/test/decompiler/loop-empty.xml | 18
vivified/code/test/decompiler/loop-infinite.swf |binary
vivified/code/test/decompiler/loop-infinite.swf.expect | 8
vivified/code/test/decompiler/loop-infinite.xml | 19
vivified/code/test/decompiler/loop-nested.as | 5
vivified/code/test/decompiler/loop-nested.swf |binary
vivified/code/test/decompiler/loop-nested.swf.expect | 9
vivified/code/test/decompiler/simple-loop.as | 5
vivified/code/test/decompiler/simple-loop.swf |binary
vivified/code/test/decompiler/simple-loop.swf.expect | 8
vivified/code/test/function-calls.as | 6
vivified/code/test/function-calls.swf.expect | 10
vivified/code/test/hello-world.as | 5
vivified/code/test/hello-world.swf.expect | 8
vivified/code/test/if-nested.as | 15
vivified/code/test/if-nested.swf.expect | 17
vivified/code/test/if.as | 17
vivified/code/test/if.swf.expect | 15
vivified/code/test/loop-empty.swf.expect | 8
vivified/code/test/loop-empty.xml | 18
vivified/code/test/loop-infinite.swf.expect | 8
vivified/code/test/loop-infinite.xml | 19
vivified/code/test/loop-nested.as | 5
vivified/code/test/loop-nested.swf.expect | 9
vivified/code/test/simple-loop.as | 5
vivified/code/test/simple-loop.swf.expect | 8
vivified/code/vivi_parser.c | 21
vivified/code/vivi_parser_scanner.c | 57 --
vivified/code/vivi_parser_scanner.h | 13
vivified/code/vivi_parser_scanner_lex.l | 367 ++++++----------
54 files changed, 450 insertions(+), 530 deletions(-)
New commits:
commit d4e221fa3f141d1c4d88b02027d8e925f1000946
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 18:26:08 2008 +0200
make scanner work properly again
- make get_next_value pop and not advance (d'oh)
- push a "start" token to the stack, so peeking works as expected
diff --git a/vivified/code/vivi_parser_scanner.c b/vivified/code/vivi_parser_scanner.c
index 10fea61..d8fd5f7 100644
--- a/vivified/code/vivi_parser_scanner.c
+++ b/vivified/code/vivi_parser_scanner.c
@@ -260,6 +260,7 @@ ViviParserScanner *
vivi_parser_scanner_new (FILE *file)
{
ViviParserScanner *scanner;
+ ViviParserValue *value;
g_return_val_if_fail (file != NULL, NULL);
@@ -267,6 +268,10 @@ vivi_parser_scanner_new (FILE *file)
scanner->file = file;
vivi_parser_scanner_restart (file, scanner->scanner);
+ value = swfdec_ring_buffer_push (scanner->values);
+ value->token = TOKEN_UNKNOWN;
+ value->line_number = value->column = 0;
+ value->position = 0;
return scanner;
}
@@ -284,7 +289,7 @@ vivi_parser_scanner_get_next_token (ViviParserScanner *scanner)
{
g_return_val_if_fail (VIVI_IS_PARSER_SCANNER (scanner), TOKEN_NONE);
- vivi_parser_scanner_advance (scanner);
+ vivi_parser_scanner_pop (scanner);
return vivi_parser_scanner_get_value (scanner, 0)->token;
}
commit 5b89e6a25bd4eaadd06926ade8f5ba88d303adcc
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 18:16:49 2008 +0200
make infrastructure work again
diff --git a/configure.ac b/configure.ac
index 4711f1d..4437d73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -349,6 +349,8 @@ tools/Makefile
vivified/Makefile
vivified/code/Makefile
vivified/code/test/Makefile
+vivified/code/test/compiler/Makefile
+vivified/code/test/decompiler/Makefile
vivified/core/Makefile
vivified/dock/Makefile
vivified/ui/Makefile
diff --git a/vivified/code/test/Makefile.am b/vivified/code/test/Makefile.am
new file mode 100644
index 0000000..85a2423
--- /dev/null
+++ b/vivified/code/test/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = compiler decompiler
diff --git a/vivified/code/test/compiler/Makefile.am b/vivified/code/test/compiler/Makefile.am
new file mode 100644
index 0000000..7f7036f
--- /dev/null
+++ b/vivified/code/test/compiler/Makefile.am
@@ -0,0 +1,17 @@
+check-local: $(top_builddir)/vivified/code/vivi-compile
+ RESULT=""; \
+ for file in $(srcdir)/*.swf; do \
+ echo "$$file ..." && $(top_builddir)/vivified/code/vivi-compile $$file | diff -u $$file.expect - || RESULT="$$RESULT $$file"; \
+ done; \
+ if test "x$$RESULT" == "x"; then \
+ echo "OK"; \
+ else \
+ echo "FAILED:"; \
+ for fail in $$RESULT; do \
+ echo " $$fail"; \
+ done; \
+ exit 1; \
+ fi
+
+EXTRA_DIST =
+
diff --git a/vivified/code/test/decompiler/Makefile.am b/vivified/code/test/decompiler/Makefile.am
index a9f5c2d..4d5d133 100644
--- a/vivified/code/test/decompiler/Makefile.am
+++ b/vivified/code/test/decompiler/Makefile.am
@@ -1,7 +1,7 @@
-check-local: ../vivi-decompile
+check-local: $(top_builddir)/vivified/code/vivi-decompile
RESULT=""; \
for file in $(srcdir)/*.swf; do \
- echo "$$file ..." && ../vivi-decompile $$file | diff -u $$file.expect - || RESULT="$$RESULT $$file"; \
+ echo "$$file ..." && $(top_builddir)/vivified/code/vivi-decompile $$file | diff -u $$file.expect - || RESULT="$$RESULT $$file"; \
done; \
if test "x$$RESULT" == "x"; then \
echo "OK"; \
commit 43ee0df33260c6e9f5439f5d81cfcfc3bc2d3170
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 18:11:11 2008 +0200
move decompiler tests into their own dir
diff --git a/vivified/code/test/Makefile.am b/vivified/code/test/Makefile.am
deleted file mode 100644
index a9f5c2d..0000000
--- a/vivified/code/test/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-check-local: ../vivi-decompile
- RESULT=""; \
- for file in $(srcdir)/*.swf; do \
- echo "$$file ..." && ../vivi-decompile $$file | diff -u $$file.expect - || RESULT="$$RESULT $$file"; \
- done; \
- if test "x$$RESULT" == "x"; then \
- echo "OK"; \
- else \
- echo "FAILED:"; \
- for fail in $$RESULT; do \
- echo " $$fail"; \
- done; \
- exit 1; \
- fi
-
-EXTRA_DIST = \
- and-or.as \
- and-or.swf \
- and-or.swf.expect \
- function-calls.as \
- function-calls.swf \
- function-calls.swf.expect \
- hello-world.as \
- hello-world.swf \
- hello-world.swf.expect \
- if.as \
- if.swf \
- if.swf.expect \
- if-nested.as \
- if-nested.swf \
- if-nested.swf.expect \
- loop-empty.swf \
- loop-empty.swf.expect \
- loop-empty.xml \
- loop-infinite.swf \
- loop-infinite.swf.expect \
- loop-infinite.xml \
- loop-nested.as \
- loop-nested.swf \
- loop-nested.swf.expect \
- simple-loop.as \
- simple-loop.swf \
- simple-loop.swf.expect
-
diff --git a/vivified/code/test/and-or.as b/vivified/code/test/and-or.as
deleted file mode 100644
index 0cbecce..0000000
--- a/vivified/code/test/and-or.as
+++ /dev/null
@@ -1,16 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o and-or.swf and-or.as
-
-if (1 && 2)
- trace (3);
-if (1 || 2)
- trace (3);
-
-if (1 && 2 && 3)
- trace (4);
-if (1 || 2 || 3)
- trace (4);
-
-if ((1 && 2) || 3)
- trace (4);
-if ((1 || 2) && 3)
- trace (4);
diff --git a/vivified/code/test/and-or.swf b/vivified/code/test/and-or.swf
deleted file mode 100644
index a7802e6..0000000
Binary files a/vivified/code/test/and-or.swf and /dev/null differ
diff --git a/vivified/code/test/and-or.swf.expect b/vivified/code/test/and-or.swf.expect
deleted file mode 100644
index 93440ba..0000000
--- a/vivified/code/test/and-or.swf.expect
+++ /dev/null
@@ -1,18 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- if (1 && 2)
- trace (3);
- if (1 || 2)
- trace (3);
- if (1 && 2 && 3)
- trace (4);
- if (1 || 2 || 3)
- trace (4);
- if (1 && 2 || 3)
- trace (4);
- if ((1 || 2) && 3)
- trace (4);
-}
-
diff --git a/vivified/code/test/decompiler/Makefile.am b/vivified/code/test/decompiler/Makefile.am
new file mode 100644
index 0000000..a9f5c2d
--- /dev/null
+++ b/vivified/code/test/decompiler/Makefile.am
@@ -0,0 +1,44 @@
+check-local: ../vivi-decompile
+ RESULT=""; \
+ for file in $(srcdir)/*.swf; do \
+ echo "$$file ..." && ../vivi-decompile $$file | diff -u $$file.expect - || RESULT="$$RESULT $$file"; \
+ done; \
+ if test "x$$RESULT" == "x"; then \
+ echo "OK"; \
+ else \
+ echo "FAILED:"; \
+ for fail in $$RESULT; do \
+ echo " $$fail"; \
+ done; \
+ exit 1; \
+ fi
+
+EXTRA_DIST = \
+ and-or.as \
+ and-or.swf \
+ and-or.swf.expect \
+ function-calls.as \
+ function-calls.swf \
+ function-calls.swf.expect \
+ hello-world.as \
+ hello-world.swf \
+ hello-world.swf.expect \
+ if.as \
+ if.swf \
+ if.swf.expect \
+ if-nested.as \
+ if-nested.swf \
+ if-nested.swf.expect \
+ loop-empty.swf \
+ loop-empty.swf.expect \
+ loop-empty.xml \
+ loop-infinite.swf \
+ loop-infinite.swf.expect \
+ loop-infinite.xml \
+ loop-nested.as \
+ loop-nested.swf \
+ loop-nested.swf.expect \
+ simple-loop.as \
+ simple-loop.swf \
+ simple-loop.swf.expect
+
diff --git a/vivified/code/test/decompiler/and-or.as b/vivified/code/test/decompiler/and-or.as
new file mode 100644
index 0000000..0cbecce
--- /dev/null
+++ b/vivified/code/test/decompiler/and-or.as
@@ -0,0 +1,16 @@
+// makeswf -v 7 -s 200x150 -r 1 -o and-or.swf and-or.as
+
+if (1 && 2)
+ trace (3);
+if (1 || 2)
+ trace (3);
+
+if (1 && 2 && 3)
+ trace (4);
+if (1 || 2 || 3)
+ trace (4);
+
+if ((1 && 2) || 3)
+ trace (4);
+if ((1 || 2) && 3)
+ trace (4);
diff --git a/vivified/code/test/decompiler/and-or.swf b/vivified/code/test/decompiler/and-or.swf
new file mode 100644
index 0000000..a7802e6
Binary files /dev/null and b/vivified/code/test/decompiler/and-or.swf differ
diff --git a/vivified/code/test/decompiler/and-or.swf.expect b/vivified/code/test/decompiler/and-or.swf.expect
new file mode 100644
index 0000000..93440ba
--- /dev/null
+++ b/vivified/code/test/decompiler/and-or.swf.expect
@@ -0,0 +1,18 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ if (1 && 2)
+ trace (3);
+ if (1 || 2)
+ trace (3);
+ if (1 && 2 && 3)
+ trace (4);
+ if (1 || 2 || 3)
+ trace (4);
+ if (1 && 2 || 3)
+ trace (4);
+ if ((1 || 2) && 3)
+ trace (4);
+}
+
diff --git a/vivified/code/test/decompiler/function-calls.as b/vivified/code/test/decompiler/function-calls.as
new file mode 100644
index 0000000..3efa898
--- /dev/null
+++ b/vivified/code/test/decompiler/function-calls.as
@@ -0,0 +1,6 @@
+// makeswf -v 7 -s 200x150 -r 1 -o function-calls.swf function-calls.as
+
+foo ();
+bar (baz);
+this.foo (1, 2, 3);
+bar.baz ();
diff --git a/vivified/code/test/decompiler/function-calls.swf b/vivified/code/test/decompiler/function-calls.swf
new file mode 100644
index 0000000..dfa5349
Binary files /dev/null and b/vivified/code/test/decompiler/function-calls.swf differ
diff --git a/vivified/code/test/decompiler/function-calls.swf.expect b/vivified/code/test/decompiler/function-calls.swf.expect
new file mode 100644
index 0000000..176d2aa
--- /dev/null
+++ b/vivified/code/test/decompiler/function-calls.swf.expect
@@ -0,0 +1,10 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ foo ();
+ bar (baz);
+ this.foo (1, 2, 3);
+ bar.baz ();
+}
+
diff --git a/vivified/code/test/decompiler/hello-world.as b/vivified/code/test/decompiler/hello-world.as
new file mode 100644
index 0000000..27c08da
--- /dev/null
+++ b/vivified/code/test/decompiler/hello-world.as
@@ -0,0 +1,5 @@
+// makeswf -v 7 -s 200x150 -r 1 -o hello-world.swf hello-world.as
+
+trace ("Hello World!");
+
+loadMovie ("fscommand:quit", "");
diff --git a/vivified/code/test/decompiler/hello-world.swf b/vivified/code/test/decompiler/hello-world.swf
new file mode 100644
index 0000000..18039af
Binary files /dev/null and b/vivified/code/test/decompiler/hello-world.swf differ
diff --git a/vivified/code/test/decompiler/hello-world.swf.expect b/vivified/code/test/decompiler/hello-world.swf.expect
new file mode 100644
index 0000000..aa94505
--- /dev/null
+++ b/vivified/code/test/decompiler/hello-world.swf.expect
@@ -0,0 +1,8 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ trace ("Hello World!");
+ loadMovie ("fscommand:quit", "");
+}
+
diff --git a/vivified/code/test/decompiler/if-nested.as b/vivified/code/test/decompiler/if-nested.as
new file mode 100644
index 0000000..13fe78c
--- /dev/null
+++ b/vivified/code/test/decompiler/if-nested.as
@@ -0,0 +1,15 @@
+// makeswf -v 7 -s 200x150 -r 1 -o if-nested.swf if-nested.as
+
+if (1) {
+ if (2) {
+ trace ("one");
+ } else {
+ trace ("two");
+ }
+} else {
+ if (3) {
+ trace ("three");
+ } else {
+ trace ("four");
+ }
+}
diff --git a/vivified/code/test/decompiler/if-nested.swf b/vivified/code/test/decompiler/if-nested.swf
new file mode 100644
index 0000000..b5bd6db
Binary files /dev/null and b/vivified/code/test/decompiler/if-nested.swf differ
diff --git a/vivified/code/test/decompiler/if-nested.swf.expect b/vivified/code/test/decompiler/if-nested.swf.expect
new file mode 100644
index 0000000..a4b332a
--- /dev/null
+++ b/vivified/code/test/decompiler/if-nested.swf.expect
@@ -0,0 +1,17 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ if (1) {
+ if (2)
+ trace ("one");
+ else
+ trace ("two");
+ } else {
+ if (3)
+ trace ("three");
+ else
+ trace ("four");
+ }
+}
+
diff --git a/vivified/code/test/decompiler/if.as b/vivified/code/test/decompiler/if.as
new file mode 100644
index 0000000..2bc876d
--- /dev/null
+++ b/vivified/code/test/decompiler/if.as
@@ -0,0 +1,17 @@
+// makeswf -v 7 -s 200x150 -r 1 -o if.swf if.as
+
+if (1) {
+ trace ("Hello World!");
+} else {
+ trace ("Goodbye cruel world");
+}
+
+if ("foo")
+ trace ("Hello World");
+
+if (true)
+ ;
+else
+ trace ("Goodbye cruel world");
+
+loadMovie ("fscommand:quit", "");
diff --git a/vivified/code/test/decompiler/if.swf b/vivified/code/test/decompiler/if.swf
new file mode 100644
index 0000000..21d77a5
Binary files /dev/null and b/vivified/code/test/decompiler/if.swf differ
diff --git a/vivified/code/test/decompiler/if.swf.expect b/vivified/code/test/decompiler/if.swf.expect
new file mode 100644
index 0000000..ae8a43b
--- /dev/null
+++ b/vivified/code/test/decompiler/if.swf.expect
@@ -0,0 +1,15 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ if (1)
+ trace ("Hello World!");
+ else
+ trace ("Goodbye cruel world");
+ if ("foo")
+ trace ("Hello World");
+ if (!true)
+ trace ("Goodbye cruel world");
+ loadMovie ("fscommand:quit", "");
+}
+
diff --git a/vivified/code/test/decompiler/loop-empty.swf b/vivified/code/test/decompiler/loop-empty.swf
new file mode 100644
index 0000000..a8c5a89
Binary files /dev/null and b/vivified/code/test/decompiler/loop-empty.swf differ
diff --git a/vivified/code/test/decompiler/loop-empty.swf.expect b/vivified/code/test/decompiler/loop-empty.swf.expect
new file mode 100644
index 0000000..79326de
--- /dev/null
+++ b/vivified/code/test/decompiler/loop-empty.swf.expect
@@ -0,0 +1,8 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ for (;;)
+ ;
+}
+
diff --git a/vivified/code/test/decompiler/loop-empty.xml b/vivified/code/test/decompiler/loop-empty.xml
new file mode 100644
index 0000000..8749ac8
--- /dev/null
+++ b/vivified/code/test/decompiler/loop-empty.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+ <!-- swfmill xml2swf loops.xml loops.swf -->
+ <Header framerate="25" frames="1">
+ <size>
+ <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+ </size>
+ <tags>
+ <DoAction>
+ <actions>
+ <BranchAlways byteOffset="65531" />
+ </actions>
+ </DoAction>
+ <ShowFrame/>
+ <End/>
+ </tags>
+ </Header>
+</swf>
diff --git a/vivified/code/test/decompiler/loop-infinite.swf b/vivified/code/test/decompiler/loop-infinite.swf
new file mode 100644
index 0000000..6e6a921
Binary files /dev/null and b/vivified/code/test/decompiler/loop-infinite.swf differ
diff --git a/vivified/code/test/decompiler/loop-infinite.swf.expect b/vivified/code/test/decompiler/loop-infinite.swf.expect
new file mode 100644
index 0000000..23e8642
--- /dev/null
+++ b/vivified/code/test/decompiler/loop-infinite.swf.expect
@@ -0,0 +1,8 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ for (;;)
+ trace (undefined);
+}
+
diff --git a/vivified/code/test/decompiler/loop-infinite.xml b/vivified/code/test/decompiler/loop-infinite.xml
new file mode 100644
index 0000000..cc216a2
--- /dev/null
+++ b/vivified/code/test/decompiler/loop-infinite.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+ <!-- swfmill xml2swf loops.xml loops.swf -->
+ <Header framerate="25" frames="1">
+ <size>
+ <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+ </size>
+ <tags>
+ <DoAction>
+ <actions>
+ <Trace />
+ <BranchAlways byteOffset="65530" />
+ </actions>
+ </DoAction>
+ <ShowFrame/>
+ <End/>
+ </tags>
+ </Header>
+</swf>
diff --git a/vivified/code/test/decompiler/loop-nested.as b/vivified/code/test/decompiler/loop-nested.as
new file mode 100644
index 0000000..8a9b2aa
--- /dev/null
+++ b/vivified/code/test/decompiler/loop-nested.as
@@ -0,0 +1,5 @@
+// makeswf -v 7 -s 200x150 -r 1 -o loop-nested.swf loop-nested.as
+
+while (i > 5)
+ while (j < -10)
+ trace ("Hello");
diff --git a/vivified/code/test/decompiler/loop-nested.swf b/vivified/code/test/decompiler/loop-nested.swf
new file mode 100644
index 0000000..79b11d3
Binary files /dev/null and b/vivified/code/test/decompiler/loop-nested.swf differ
diff --git a/vivified/code/test/decompiler/loop-nested.swf.expect b/vivified/code/test/decompiler/loop-nested.swf.expect
new file mode 100644
index 0000000..eabc878
--- /dev/null
+++ b/vivified/code/test/decompiler/loop-nested.swf.expect
@@ -0,0 +1,9 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ while (5 < i)
+ while (j < 10 * -1)
+ trace ("Hello");
+}
+
diff --git a/vivified/code/test/decompiler/simple-loop.as b/vivified/code/test/decompiler/simple-loop.as
new file mode 100644
index 0000000..05e5c72
--- /dev/null
+++ b/vivified/code/test/decompiler/simple-loop.as
@@ -0,0 +1,5 @@
+// makeswf -v 7 -s 200x150 -r 1 -o simple-loop.swf simple-loop.as
+
+while (false) {
+ trace ("Hello World!");
+}
diff --git a/vivified/code/test/decompiler/simple-loop.swf b/vivified/code/test/decompiler/simple-loop.swf
new file mode 100644
index 0000000..88ccee5
Binary files /dev/null and b/vivified/code/test/decompiler/simple-loop.swf differ
diff --git a/vivified/code/test/decompiler/simple-loop.swf.expect b/vivified/code/test/decompiler/simple-loop.swf.expect
new file mode 100644
index 0000000..f0a1bbf
--- /dev/null
+++ b/vivified/code/test/decompiler/simple-loop.swf.expect
@@ -0,0 +1,8 @@
+/* version: 7 - size: 200x150 */
+
+/* Sprite0_Frame0 */
+function () {
+ while (false)
+ trace ("Hello World!");
+}
+
diff --git a/vivified/code/test/function-calls.as b/vivified/code/test/function-calls.as
deleted file mode 100644
index 3efa898..0000000
--- a/vivified/code/test/function-calls.as
+++ /dev/null
@@ -1,6 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o function-calls.swf function-calls.as
-
-foo ();
-bar (baz);
-this.foo (1, 2, 3);
-bar.baz ();
diff --git a/vivified/code/test/function-calls.swf b/vivified/code/test/function-calls.swf
deleted file mode 100644
index dfa5349..0000000
Binary files a/vivified/code/test/function-calls.swf and /dev/null differ
diff --git a/vivified/code/test/function-calls.swf.expect b/vivified/code/test/function-calls.swf.expect
deleted file mode 100644
index 176d2aa..0000000
--- a/vivified/code/test/function-calls.swf.expect
+++ /dev/null
@@ -1,10 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- foo ();
- bar (baz);
- this.foo (1, 2, 3);
- bar.baz ();
-}
-
diff --git a/vivified/code/test/hello-world.as b/vivified/code/test/hello-world.as
deleted file mode 100644
index 27c08da..0000000
--- a/vivified/code/test/hello-world.as
+++ /dev/null
@@ -1,5 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o hello-world.swf hello-world.as
-
-trace ("Hello World!");
-
-loadMovie ("fscommand:quit", "");
diff --git a/vivified/code/test/hello-world.swf b/vivified/code/test/hello-world.swf
deleted file mode 100644
index 18039af..0000000
Binary files a/vivified/code/test/hello-world.swf and /dev/null differ
diff --git a/vivified/code/test/hello-world.swf.expect b/vivified/code/test/hello-world.swf.expect
deleted file mode 100644
index aa94505..0000000
--- a/vivified/code/test/hello-world.swf.expect
+++ /dev/null
@@ -1,8 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- trace ("Hello World!");
- loadMovie ("fscommand:quit", "");
-}
-
diff --git a/vivified/code/test/if-nested.as b/vivified/code/test/if-nested.as
deleted file mode 100644
index 13fe78c..0000000
--- a/vivified/code/test/if-nested.as
+++ /dev/null
@@ -1,15 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o if-nested.swf if-nested.as
-
-if (1) {
- if (2) {
- trace ("one");
- } else {
- trace ("two");
- }
-} else {
- if (3) {
- trace ("three");
- } else {
- trace ("four");
- }
-}
diff --git a/vivified/code/test/if-nested.swf b/vivified/code/test/if-nested.swf
deleted file mode 100644
index b5bd6db..0000000
Binary files a/vivified/code/test/if-nested.swf and /dev/null differ
diff --git a/vivified/code/test/if-nested.swf.expect b/vivified/code/test/if-nested.swf.expect
deleted file mode 100644
index a4b332a..0000000
--- a/vivified/code/test/if-nested.swf.expect
+++ /dev/null
@@ -1,17 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- if (1) {
- if (2)
- trace ("one");
- else
- trace ("two");
- } else {
- if (3)
- trace ("three");
- else
- trace ("four");
- }
-}
-
diff --git a/vivified/code/test/if.as b/vivified/code/test/if.as
deleted file mode 100644
index 2bc876d..0000000
--- a/vivified/code/test/if.as
+++ /dev/null
@@ -1,17 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o if.swf if.as
-
-if (1) {
- trace ("Hello World!");
-} else {
- trace ("Goodbye cruel world");
-}
-
-if ("foo")
- trace ("Hello World");
-
-if (true)
- ;
-else
- trace ("Goodbye cruel world");
-
-loadMovie ("fscommand:quit", "");
diff --git a/vivified/code/test/if.swf b/vivified/code/test/if.swf
deleted file mode 100644
index 21d77a5..0000000
Binary files a/vivified/code/test/if.swf and /dev/null differ
diff --git a/vivified/code/test/if.swf.expect b/vivified/code/test/if.swf.expect
deleted file mode 100644
index ae8a43b..0000000
--- a/vivified/code/test/if.swf.expect
+++ /dev/null
@@ -1,15 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- if (1)
- trace ("Hello World!");
- else
- trace ("Goodbye cruel world");
- if ("foo")
- trace ("Hello World");
- if (!true)
- trace ("Goodbye cruel world");
- loadMovie ("fscommand:quit", "");
-}
-
diff --git a/vivified/code/test/loop-empty.swf b/vivified/code/test/loop-empty.swf
deleted file mode 100644
index a8c5a89..0000000
Binary files a/vivified/code/test/loop-empty.swf and /dev/null differ
diff --git a/vivified/code/test/loop-empty.swf.expect b/vivified/code/test/loop-empty.swf.expect
deleted file mode 100644
index 79326de..0000000
--- a/vivified/code/test/loop-empty.swf.expect
+++ /dev/null
@@ -1,8 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- for (;;)
- ;
-}
-
diff --git a/vivified/code/test/loop-empty.xml b/vivified/code/test/loop-empty.xml
deleted file mode 100644
index 8749ac8..0000000
--- a/vivified/code/test/loop-empty.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<swf version="7" compressed="1">
- <!-- swfmill xml2swf loops.xml loops.swf -->
- <Header framerate="25" frames="1">
- <size>
- <Rectangle left="0" right="4000" top="0" bottom="3000"/>
- </size>
- <tags>
- <DoAction>
- <actions>
- <BranchAlways byteOffset="65531" />
- </actions>
- </DoAction>
- <ShowFrame/>
- <End/>
- </tags>
- </Header>
-</swf>
diff --git a/vivified/code/test/loop-infinite.swf b/vivified/code/test/loop-infinite.swf
deleted file mode 100644
index 6e6a921..0000000
Binary files a/vivified/code/test/loop-infinite.swf and /dev/null differ
diff --git a/vivified/code/test/loop-infinite.swf.expect b/vivified/code/test/loop-infinite.swf.expect
deleted file mode 100644
index 23e8642..0000000
--- a/vivified/code/test/loop-infinite.swf.expect
+++ /dev/null
@@ -1,8 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- for (;;)
- trace (undefined);
-}
-
diff --git a/vivified/code/test/loop-infinite.xml b/vivified/code/test/loop-infinite.xml
deleted file mode 100644
index cc216a2..0000000
--- a/vivified/code/test/loop-infinite.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0"?>
-<swf version="7" compressed="1">
- <!-- swfmill xml2swf loops.xml loops.swf -->
- <Header framerate="25" frames="1">
- <size>
- <Rectangle left="0" right="4000" top="0" bottom="3000"/>
- </size>
- <tags>
- <DoAction>
- <actions>
- <Trace />
- <BranchAlways byteOffset="65530" />
- </actions>
- </DoAction>
- <ShowFrame/>
- <End/>
- </tags>
- </Header>
-</swf>
diff --git a/vivified/code/test/loop-nested.as b/vivified/code/test/loop-nested.as
deleted file mode 100644
index 8a9b2aa..0000000
--- a/vivified/code/test/loop-nested.as
+++ /dev/null
@@ -1,5 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o loop-nested.swf loop-nested.as
-
-while (i > 5)
- while (j < -10)
- trace ("Hello");
diff --git a/vivified/code/test/loop-nested.swf b/vivified/code/test/loop-nested.swf
deleted file mode 100644
index 79b11d3..0000000
Binary files a/vivified/code/test/loop-nested.swf and /dev/null differ
diff --git a/vivified/code/test/loop-nested.swf.expect b/vivified/code/test/loop-nested.swf.expect
deleted file mode 100644
index eabc878..0000000
--- a/vivified/code/test/loop-nested.swf.expect
+++ /dev/null
@@ -1,9 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- while (5 < i)
- while (j < 10 * -1)
- trace ("Hello");
-}
-
diff --git a/vivified/code/test/simple-loop.as b/vivified/code/test/simple-loop.as
deleted file mode 100644
index 05e5c72..0000000
--- a/vivified/code/test/simple-loop.as
+++ /dev/null
@@ -1,5 +0,0 @@
-// makeswf -v 7 -s 200x150 -r 1 -o simple-loop.swf simple-loop.as
-
-while (false) {
- trace ("Hello World!");
-}
diff --git a/vivified/code/test/simple-loop.swf b/vivified/code/test/simple-loop.swf
deleted file mode 100644
index 88ccee5..0000000
Binary files a/vivified/code/test/simple-loop.swf and /dev/null differ
diff --git a/vivified/code/test/simple-loop.swf.expect b/vivified/code/test/simple-loop.swf.expect
deleted file mode 100644
index f0a1bbf..0000000
--- a/vivified/code/test/simple-loop.swf.expect
+++ /dev/null
@@ -1,8 +0,0 @@
-/* version: 7 - size: 200x150 */
-
-/* Sprite0_Frame0 */
-function () {
- while (false)
- trace ("Hello World!");
-}
-
commit 1551f0bcdb70d0d1d8c628acd973b819609650dd
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 18:09:33 2008 +0200
handle errors directly
diff --git a/vivified/code/vivi_parser_scanner.c b/vivified/code/vivi_parser_scanner.c
index 0298fca..10fea61 100644
--- a/vivified/code/vivi_parser_scanner.c
+++ b/vivified/code/vivi_parser_scanner.c
@@ -34,8 +34,6 @@ vivi_parser_value_reset (ViviParserValue *value)
g_free (value->value.v_string);
} else if (value->token == TOKEN_IDENTIFIER) {
g_free (value->value.v_identifier);
- } else if (value->token == TOKEN_ERROR) {
- g_free (value->value.v_error);
}
/* FIXME: do a memset 0 here? */
@@ -88,7 +86,6 @@ static const struct {
} token_names[] = {
// special
{ TOKEN_NONE, "NONE" },
- { TOKEN_ERROR, "ERROR" },
{ TOKEN_UNKNOWN, "UNKNOWN" },
// comparision
@@ -240,16 +237,8 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
value->line_terminator = FALSE;
} else {
value->line_terminator = FALSE;
- for (;;) {
- value->token = vivi_parser_scanner_lex (scanner->scanner, value);
- g_print ("got %s\n", vivi_parser_scanner_token_name (value->token));
- if (value->token == TOKEN_ERROR) {
- vivi_parser_scanner_error (scanner, 0, 0, "%s", value->value.v_error);
- vivi_parser_value_reset (value);
- } else {
- break;
- }
- }
+ value->token = vivi_parser_scanner_lex (scanner->scanner, value);
+ g_print ("got %s\n", vivi_parser_scanner_token_name (value->token));
value->line_number = vivi_parser_scanner_get_lineno (scanner->scanner);
value->column = 0; /* FIXME */
value->position = 0; /* FIXME */
diff --git a/vivified/code/vivi_parser_scanner.h b/vivified/code/vivi_parser_scanner.h
index 9d91ab7..d731f3b 100644
--- a/vivified/code/vivi_parser_scanner.h
+++ b/vivified/code/vivi_parser_scanner.h
@@ -30,7 +30,6 @@ G_BEGIN_DECLS
typedef enum {
// special
TOKEN_NONE = 0,
- TOKEN_ERROR,
TOKEN_UNKNOWN,
// comparision
diff --git a/vivified/code/vivi_parser_scanner_lex.l b/vivified/code/vivi_parser_scanner_lex.l
index 1b0faa9..0b66919 100644
--- a/vivified/code/vivi_parser_scanner_lex.l
+++ b/vivified/code/vivi_parser_scanner_lex.l
@@ -28,6 +28,7 @@ extern YY_DECL;
%{
static GString *string = NULL;
+#define ERROR(...) vivi_parser_scanner_error (yyextra, yylineno, yycolumn, __VA_ARGS__)
%}
%option header-file="vivi_parser_scanner_lex.h"
@@ -52,9 +53,7 @@ identifier_part [$_a-zA-Z0-9]
. { /* skip */ }
<<EOF>> {
BEGIN(INITIAL);
- value->value.v_error =
- g_strdup ("Unterminated comment");
- return TOKEN_ERROR;
+ ERROR ("Unterminated comment");
}
}
@@ -226,33 +225,23 @@ identifier_part [$_a-zA-Z0-9]
\n {
BEGIN(INITIAL);
g_string_free (string, TRUE);
- value->value.v_error = g_strdup (
- "Unterminated string constant");
- return TOKEN_ERROR;
+ ERROR ("Unterminated string constant");
}
\\[0-7]{1,3} {
guint64 result;
result = g_ascii_strtoull (yytext + 1, NULL, 8);
if (result > 0xff || result == 0) {
- value->value.v_error = g_strdup_printf (
- "Invalid escape sequence %s", yytext);
- return TOKEN_ERROR;
+ ERROR ("Invalid escape sequence %s", yytext);
} else {
g_string_append_c (string, result);
}
}
- \\[0-9]+ {
- value->value.v_error = g_strdup_printf (
- "Invalid escape sequence %s", yytext);
- return TOKEN_ERROR;
- }
+ \\[0-9]+ { ERROR ("Invalid escape sequence %s", yytext); }
\\x[0-9a-fA-F]{2} {
guint64 result;
result = g_ascii_strtoull (yytext + 2, NULL, 16);
if (result == 0) {
- value->value.v_error = g_strdup_printf (
- "Invalid escape sequence %s", yytext);
- return TOKEN_ERROR;
+ ERROR ("Invalid escape sequence %s", yytext);
} else {
g_string_append_c (string, result);
}
@@ -277,11 +266,7 @@ identifier_part [$_a-zA-Z0-9]
return TOKEN_IDENTIFIER;
}
-. {
- value->value.v_error = g_strdup_printf (
- "Unknown character '%c'", yytext[0]);
- return TOKEN_ERROR;
- }
+. { ERROR ("Unknown character '%c'", yytext[0]); }
%%
commit fa7787d0efa780301274a083dd86b7c01db0c0fb
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 17:18:40 2008 +0200
make the scanner reentrant
diff --git a/vivified/code/vivi_parser_scanner.c b/vivified/code/vivi_parser_scanner.c
index 4c85aae..0298fca 100644
--- a/vivified/code/vivi_parser_scanner.c
+++ b/vivified/code/vivi_parser_scanner.c
@@ -62,6 +62,8 @@ vivi_parser_scanner_dispose (GObject *object)
while (swfdec_ring_buffer_get_n_elements (scanner->values))
vivi_parser_scanner_pop (scanner);
+ vivi_parser_scanner_lex_destroy (scanner->scanner);
+
G_OBJECT_CLASS (vivi_parser_scanner_parent_class)->dispose (object);
}
@@ -76,6 +78,7 @@ vivi_parser_scanner_class_init (ViviParserScannerClass *klass)
static void
vivi_parser_scanner_init (ViviParserScanner *scanner)
{
+ vivi_parser_scanner_lex_init_extra (scanner, &scanner->scanner);
scanner->values = swfdec_ring_buffer_new_for_type (ViviParserValue, 4);
}
@@ -238,7 +241,7 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
} else {
value->line_terminator = FALSE;
for (;;) {
- value->token = vivi_parser_scanner_lex (value);
+ value->token = vivi_parser_scanner_lex (scanner->scanner, value);
g_print ("got %s\n", vivi_parser_scanner_token_name (value->token));
if (value->token == TOKEN_ERROR) {
vivi_parser_scanner_error (scanner, 0, 0, "%s", value->value.v_error);
@@ -247,7 +250,7 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
break;
}
}
- value->line_number = vivi_parser_scanner_lineno;
+ value->line_number = vivi_parser_scanner_get_lineno (scanner->scanner);
value->column = 0; /* FIXME */
value->position = 0; /* FIXME */
}
@@ -274,7 +277,7 @@ vivi_parser_scanner_new (FILE *file)
scanner = g_object_new (VIVI_TYPE_PARSER_SCANNER, NULL);
scanner->file = file;
- vivi_parser_scanner_restart (file);
+ vivi_parser_scanner_restart (file, scanner->scanner);
return scanner;
}
diff --git a/vivified/code/vivi_parser_scanner.h b/vivified/code/vivi_parser_scanner.h
index 9385aa9..9d91ab7 100644
--- a/vivified/code/vivi_parser_scanner.h
+++ b/vivified/code/vivi_parser_scanner.h
@@ -182,6 +182,7 @@ struct _ViviParserScanner
ViviParserScannerFunction error_handler;
gpointer error_handler_data;
+ gpointer scanner;
SwfdecRingBuffer * values;
};
diff --git a/vivified/code/vivi_parser_scanner_lex.l b/vivified/code/vivi_parser_scanner_lex.l
index 7e5fca2..1b0faa9 100644
--- a/vivified/code/vivi_parser_scanner_lex.l
+++ b/vivified/code/vivi_parser_scanner_lex.l
@@ -20,8 +20,10 @@
#include "vivi_parser_scanner.h"
-#define YY_DECL int vivi_parser_scanner_lex (ViviParserValue *value)
+#define YY_DECL int vivi_parser_scanner_lex (void *yyscanner, ViviParserValue *value)
extern YY_DECL;
+
+#define YY_EXTRA_TYPE ViviParserScanner *
}
%{
@@ -34,6 +36,7 @@ static GString *string = NULL;
%option nostdinit
%option outfile="vivi_parser_scanner_lex.c"
%option prefix="vivi_parser_scanner_"
+%option reentrant
identifier_start [$_a-zA-Z]
identifier_part [$_a-zA-Z0-9]
commit 862b96aa1232015a35517b72884958781c7ad0f7
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 16:46:34 2008 +0200
change prefix to "vivi_parser_scanner_"
diff --git a/vivified/code/vivi_parser_scanner.c b/vivified/code/vivi_parser_scanner.c
index 177c6b2..4c85aae 100644
--- a/vivified/code/vivi_parser_scanner.c
+++ b/vivified/code/vivi_parser_scanner.c
@@ -238,7 +238,7 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
} else {
value->line_terminator = FALSE;
for (;;) {
- value->token = yylex (value);
+ value->token = vivi_parser_scanner_lex (value);
g_print ("got %s\n", vivi_parser_scanner_token_name (value->token));
if (value->token == TOKEN_ERROR) {
vivi_parser_scanner_error (scanner, 0, 0, "%s", value->value.v_error);
@@ -247,7 +247,7 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
break;
}
}
- value->line_number = yylineno;
+ value->line_number = vivi_parser_scanner_lineno;
value->column = 0; /* FIXME */
value->position = 0; /* FIXME */
}
@@ -274,7 +274,7 @@ vivi_parser_scanner_new (FILE *file)
scanner = g_object_new (VIVI_TYPE_PARSER_SCANNER, NULL);
scanner->file = file;
- yyrestart (file);
+ vivi_parser_scanner_restart (file);
return scanner;
}
diff --git a/vivified/code/vivi_parser_scanner_lex.l b/vivified/code/vivi_parser_scanner_lex.l
index e186e3d..7e5fca2 100644
--- a/vivified/code/vivi_parser_scanner_lex.l
+++ b/vivified/code/vivi_parser_scanner_lex.l
@@ -20,7 +20,7 @@
#include "vivi_parser_scanner.h"
-#define YY_DECL int yylex (ViviParserValue *value)
+#define YY_DECL int vivi_parser_scanner_lex (ViviParserValue *value)
extern YY_DECL;
}
@@ -33,6 +33,7 @@ static GString *string = NULL;
%option noyywrap
%option nostdinit
%option outfile="vivi_parser_scanner_lex.c"
+%option prefix="vivi_parser_scanner_"
identifier_start [$_a-zA-Z]
identifier_part [$_a-zA-Z0-9]
commit 223fb7f123b6c5b2bc3fdab3e966eebbc9460856
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 16:43:17 2008 +0200
get rid of count() and new_line() functions, that's lex's job
Also, set line terminators in the parser, and don't abort parsing.
diff --git a/vivified/code/vivi_parser.c b/vivified/code/vivi_parser.c
index 994ea6e..41c4218 100644
--- a/vivified/code/vivi_parser.c
+++ b/vivified/code/vivi_parser.c
@@ -224,9 +224,8 @@ vivi_parser_error_unexpected_line_terminator (ParseData *data, guint expected)
g_return_if_fail (data != NULL);
g_return_if_fail (expected != TOKEN_NONE);
- vivi_parser_error (data, "Expected %s before %s",
- vivi_parser_token_name (expected),
- vivi_parser_token_name (TOKEN_LINE_TERMINATOR));
+ vivi_parser_error (data, "Expected %s before end of line",
+ vivi_parser_token_name (expected));
}
G_GNUC_WARN_UNUSED_RESULT static gboolean
diff --git a/vivified/code/vivi_parser_scanner.c b/vivified/code/vivi_parser_scanner.c
index f8f9b8b..177c6b2 100644
--- a/vivified/code/vivi_parser_scanner.c
+++ b/vivified/code/vivi_parser_scanner.c
@@ -87,7 +87,6 @@ static const struct {
{ TOKEN_NONE, "NONE" },
{ TOKEN_ERROR, "ERROR" },
{ TOKEN_UNKNOWN, "UNKNOWN" },
- { TOKEN_LINE_TERMINATOR, "NEW LINE" },
// comparision
{ TOKEN_BRACE_LEFT, "{", },
@@ -241,10 +240,7 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
for (;;) {
value->token = yylex (value);
g_print ("got %s\n", vivi_parser_scanner_token_name (value->token));
- if (value->token == TOKEN_LINE_TERMINATOR) {
- value->line_terminator = TRUE;
- vivi_parser_value_reset (value);
- } else if (value->token == TOKEN_ERROR) {
+ if (value->token == TOKEN_ERROR) {
vivi_parser_scanner_error (scanner, 0, 0, "%s", value->value.v_error);
vivi_parser_value_reset (value);
} else {
diff --git a/vivified/code/vivi_parser_scanner.h b/vivified/code/vivi_parser_scanner.h
index b4beeaf..9385aa9 100644
--- a/vivified/code/vivi_parser_scanner.h
+++ b/vivified/code/vivi_parser_scanner.h
@@ -32,7 +32,6 @@ typedef enum {
TOKEN_NONE = 0,
TOKEN_ERROR,
TOKEN_UNKNOWN,
- TOKEN_LINE_TERMINATOR,
// comparision
TOKEN_BRACE_LEFT,
diff --git a/vivified/code/vivi_parser_scanner_lex.l b/vivified/code/vivi_parser_scanner_lex.l
index b7ea652..e186e3d 100644
--- a/vivified/code/vivi_parser_scanner_lex.l
+++ b/vivified/code/vivi_parser_scanner_lex.l
@@ -25,20 +25,14 @@ extern YY_DECL;
}
%{
-guint lex_line_number = 0;
-gsize lex_position = 0;
-
-static void new_line (void);
-static void count (void);
-
static GString *string = NULL;
%}
+%option header-file="vivi_parser_scanner_lex.h"
+%option never-interactive
%option noyywrap
%option nostdinit
-%option never-interactive
%option outfile="vivi_parser_scanner_lex.c"
-%option header-file="vivi_parser_scanner_lex.h"
identifier_start [$_a-zA-Z]
identifier_part [$_a-zA-Z0-9]
@@ -48,13 +42,11 @@ identifier_part [$_a-zA-Z0-9]
%%
-"/*" { count (); BEGIN(comment); }
+"/*" { BEGIN(comment); }
<comment>{
- [^*\n]* { count (); /* skip */ }
- \n { count (); new_line (); }
- "*/" { count (); BEGIN(INITIAL); }
+ "*/" { BEGIN(INITIAL); }
+ . { /* skip */ }
<<EOF>> {
- count ();
BEGIN(INITIAL);
value->value.v_error =
g_strdup ("Unterminated comment");
@@ -62,192 +54,172 @@ identifier_part [$_a-zA-Z0-9]
}
}
-"//"[^\r\n]* {
- count ();
- new_line ();
- return TOKEN_LINE_TERMINATOR;
- }
+"//"[^\r\n]* { /* skip */ }
<<EOF>> { return TOKEN_NONE; }
-[ \t] { count (); /* skip */ }
-
-\r\n {
- count ();
- new_line ();
- return TOKEN_LINE_TERMINATOR;
- }
-[\r\n] {
- count ();
- new_line ();
- return TOKEN_LINE_TERMINATOR;
- }
-
-"{" { count (); return TOKEN_BRACE_LEFT; }
-"}" { count (); return TOKEN_BRACE_RIGHT; }
-"[" { count (); return TOKEN_BRACKET_LEFT; }
-"]" { count (); return TOKEN_BRACKET_RIGHT; }
-"(" { count (); return TOKEN_PARENTHESIS_LEFT; }
-")" { count (); return TOKEN_PARENTHESIS_RIGHT; }
-
-"." { count (); return TOKEN_DOT; }
-";" { count (); return TOKEN_SEMICOLON; }
-"," { count (); return TOKEN_COMMA; }
-
-"<" { count (); return TOKEN_LESS_THAN; }
-">" { count (); return TOKEN_GREATER_THAN; }
-"<=" { count (); return TOKEN_LESS_THAN_OR_EQUAL; }
-">=" { count (); return TOKEN_EQUAL_OR_GREATER_THAN; }
-
-"==" { count (); return TOKEN_EQUAL; }
-"!=" { count (); return TOKEN_NOT_EQUAL; }
-"===" { count (); return TOKEN_STRICT_EQUAL; }
-"!==" { count (); return TOKEN_NOT_STRICT_EQUAL; }
-
-"+" { count (); return TOKEN_PLUS; }
-"-" { count (); return TOKEN_MINUS; }
-"*" { count (); return TOKEN_MULTIPLY; }
-"/" { count (); return TOKEN_DIVIDE; }
-"%" { count (); return TOKEN_REMAINDER; }
-
-"<<" { count (); return TOKEN_SHIFT_LEFT; }
-">>" { count (); return TOKEN_SHIFT_RIGHT; }
-">>>" { count (); return TOKEN_SHIFT_RIGHT_UNSIGNED; }
-
-"&" { count (); return TOKEN_BITWISE_AND; }
-"|" { count (); return TOKEN_BITWISE_OR; }
-"^" { count (); return TOKEN_BITWISE_XOR; }
-
-"!" { count (); return TOKEN_LOGICAL_NOT; }
-"~" { count (); return TOKEN_BITWISE_NOT; }
-"++" { count (); return TOKEN_INCREASE; }
-"--" { count (); return TOKEN_DESCREASE; }
-
-"?" { count (); return TOKEN_QUESTION_MARK; }
-":" { count (); return TOKEN_COLON; }
-
-"&&" { count (); return TOKEN_LOGICAL_AND; }
-"||" { count (); return TOKEN_LOGICAL_OR; }
-
-"=" { count (); return TOKEN_ASSIGN; }
-"*=" { count (); return TOKEN_ASSIGN_MULTIPLY; }
-"/=" { count (); return TOKEN_ASSIGN_DIVIDE; }
-"%=" { count (); return TOKEN_ASSIGN_REMAINDER; }
-"+=" { count (); return TOKEN_ASSIGN_ADD; }
-"-=" { count (); return TOKEN_ASSIGN_MINUS; }
-"<<=" { count (); return TOKEN_ASSIGN_SHIFT_LEFT; }
-">>=" { count (); return TOKEN_ASSIGN_SHIFT_RIGHT; }
-">>>=" { count (); return TOKEN_ASSIGN_SHIFT_RIGHT_ZERO; }
-"&=" { count (); return TOKEN_ASSIGN_BITWISE_AND; }
-"^=" { count (); return TOKEN_ASSIGN_BITWISE_XOR; }
-"|=" { count (); return TOKEN_ASSIGN_BITWISE_OR; }
-
-"break" { count (); return TOKEN_BREAK; }
-"case" { count (); return TOKEN_CASE; }
-"catch" { count (); return TOKEN_CATCH; }
-"continue" { count (); return TOKEN_CONTINUE; }
-"default" { count (); return TOKEN_DEFAULT; }
-"delete" { count (); return TOKEN_DELETE; }
-"do" { count (); return TOKEN_DO; }
-"else" { count (); return TOKEN_ELSE; }
-"finally" { count (); return TOKEN_FINALLY; }
-"for" { count (); return TOKEN_FOR; }
-"function" { count (); return TOKEN_FUNCTION; }
-"if" { count (); return TOKEN_IF; }
-"in" { count (); return TOKEN_IN; }
-"instanceof" { count (); return TOKEN_INSTANCEOF; }
-"new" { count (); return TOKEN_NEW; }
-"return" { count (); return TOKEN_RETURN; }
-"switch" { count (); return TOKEN_SWITCH; }
-"this" { count (); return TOKEN_THIS; }
-"throw" { count (); return TOKEN_THROW; }
-"try" { count (); return TOKEN_TRY; }
-"typeof" { count (); return TOKEN_TYPEOF; }
-"var" { count (); return TOKEN_VAR; }
-"void" { count (); return TOKEN_VOID; }
-"while" { count (); return TOKEN_WHILE; }
-"with" { count (); return TOKEN_WITH; }
-
-"abstract" { count (); return TOKEN_RESERVED_KEYWORD; }
-"boolean" { count (); return TOKEN_RESERVED_KEYWORD; }
-"byte" { count (); return TOKEN_RESERVED_KEYWORD; }
-"char" { count (); return TOKEN_RESERVED_KEYWORD; }
-"class" { count (); return TOKEN_RESERVED_KEYWORD; }
-"const" { count (); return TOKEN_RESERVED_KEYWORD; }
-"debugger" { count (); return TOKEN_RESERVED_KEYWORD; }
-"double" { count (); return TOKEN_RESERVED_KEYWORD; }
-"enum" { count (); return TOKEN_RESERVED_KEYWORD; }
-"export" { count (); return TOKEN_RESERVED_KEYWORD; }
-"extends" { count (); return TOKEN_RESERVED_KEYWORD; }
-"final" { count (); return TOKEN_RESERVED_KEYWORD; }
-"float" { count (); return TOKEN_RESERVED_KEYWORD; }
-"goto" { count (); return TOKEN_RESERVED_KEYWORD; }
-"implements" { count (); return TOKEN_RESERVED_KEYWORD; }
-"import" { count (); return TOKEN_RESERVED_KEYWORD; }
- /*"int" { count (); return TOKEN_RESERVED_KEYWORD; }*/
-"interface" { count (); return TOKEN_RESERVED_KEYWORD; }
-"long" { count (); return TOKEN_RESERVED_KEYWORD; }
-"native" { count (); return TOKEN_RESERVED_KEYWORD; }
-"package" { count (); return TOKEN_RESERVED_KEYWORD; }
-"private" { count (); return TOKEN_RESERVED_KEYWORD; }
-"protected" { count (); return TOKEN_RESERVED_KEYWORD; }
-"public" { count (); return TOKEN_RESERVED_KEYWORD; }
-"short" { count (); return TOKEN_RESERVED_KEYWORD; }
-"static" { count (); return TOKEN_RESERVED_KEYWORD; }
-"super" { count (); return TOKEN_RESERVED_KEYWORD; }
-"synchronized" { count (); return TOKEN_RESERVED_KEYWORD; }
-"throws" { count (); return TOKEN_RESERVED_KEYWORD; }
-"transient" { count (); return TOKEN_RESERVED_KEYWORD; }
-"volatile" { count (); return TOKEN_RESERVED_KEYWORD; }
-
-"undefined" { count (); return TOKEN_UNDEFINED; }
-
-"null" { count (); return TOKEN_NULL; }
+[ \t] { /* skip */ }
+
+\r\n { value->line_terminator = TRUE; }
+[\r\n] { value->line_terminator = TRUE; }
+
+"{" { return TOKEN_BRACE_LEFT; }
+"}" { return TOKEN_BRACE_RIGHT; }
+"[" { return TOKEN_BRACKET_LEFT; }
+"]" { return TOKEN_BRACKET_RIGHT; }
+"(" { return TOKEN_PARENTHESIS_LEFT; }
+")" { return TOKEN_PARENTHESIS_RIGHT; }
+
+"." { return TOKEN_DOT; }
+";" { return TOKEN_SEMICOLON; }
+"," { return TOKEN_COMMA; }
+
+"<" { return TOKEN_LESS_THAN; }
+">" { return TOKEN_GREATER_THAN; }
+"<=" { return TOKEN_LESS_THAN_OR_EQUAL; }
+">=" { return TOKEN_EQUAL_OR_GREATER_THAN; }
+
+"==" { return TOKEN_EQUAL; }
+"!=" { return TOKEN_NOT_EQUAL; }
+"===" { return TOKEN_STRICT_EQUAL; }
+"!==" { return TOKEN_NOT_STRICT_EQUAL; }
+
+"+" { return TOKEN_PLUS; }
+"-" { return TOKEN_MINUS; }
+"*" { return TOKEN_MULTIPLY; }
+"/" { return TOKEN_DIVIDE; }
+"%" { return TOKEN_REMAINDER; }
+
+"<<" { return TOKEN_SHIFT_LEFT; }
+">>" { return TOKEN_SHIFT_RIGHT; }
+">>>" { return TOKEN_SHIFT_RIGHT_UNSIGNED; }
+
+"&" { return TOKEN_BITWISE_AND; }
+"|" { return TOKEN_BITWISE_OR; }
+"^" { return TOKEN_BITWISE_XOR; }
+
+"!" { return TOKEN_LOGICAL_NOT; }
+"~" { return TOKEN_BITWISE_NOT; }
+"++" { return TOKEN_INCREASE; }
+"--" { return TOKEN_DESCREASE; }
+
+"?" { return TOKEN_QUESTION_MARK; }
+":" { return TOKEN_COLON; }
+
+"&&" { return TOKEN_LOGICAL_AND; }
+"||" { return TOKEN_LOGICAL_OR; }
+
+"=" { return TOKEN_ASSIGN; }
+"*=" { return TOKEN_ASSIGN_MULTIPLY; }
+"/=" { return TOKEN_ASSIGN_DIVIDE; }
+"%=" { return TOKEN_ASSIGN_REMAINDER; }
+"+=" { return TOKEN_ASSIGN_ADD; }
+"-=" { return TOKEN_ASSIGN_MINUS; }
+"<<=" { return TOKEN_ASSIGN_SHIFT_LEFT; }
+">>=" { return TOKEN_ASSIGN_SHIFT_RIGHT; }
+">>>=" { return TOKEN_ASSIGN_SHIFT_RIGHT_ZERO; }
+"&=" { return TOKEN_ASSIGN_BITWISE_AND; }
+"^=" { return TOKEN_ASSIGN_BITWISE_XOR; }
+"|=" { return TOKEN_ASSIGN_BITWISE_OR; }
+
+"break" { return TOKEN_BREAK; }
+"case" { return TOKEN_CASE; }
+"catch" { return TOKEN_CATCH; }
+"continue" { return TOKEN_CONTINUE; }
+"default" { return TOKEN_DEFAULT; }
+"delete" { return TOKEN_DELETE; }
+"do" { return TOKEN_DO; }
+"else" { return TOKEN_ELSE; }
+"finally" { return TOKEN_FINALLY; }
+"for" { return TOKEN_FOR; }
+"function" { return TOKEN_FUNCTION; }
+"if" { return TOKEN_IF; }
+"in" { return TOKEN_IN; }
+"instanceof" { return TOKEN_INSTANCEOF; }
+"new" { return TOKEN_NEW; }
+"return" { return TOKEN_RETURN; }
+"switch" { return TOKEN_SWITCH; }
+"this" { return TOKEN_THIS; }
+"throw" { return TOKEN_THROW; }
+"try" { return TOKEN_TRY; }
+"typeof" { return TOKEN_TYPEOF; }
+"var" { return TOKEN_VAR; }
+"void" { return TOKEN_VOID; }
+"while" { return TOKEN_WHILE; }
+"with" { return TOKEN_WITH; }
+
+"abstract" { return TOKEN_RESERVED_KEYWORD; }
+"boolean" { return TOKEN_RESERVED_KEYWORD; }
+"byte" { return TOKEN_RESERVED_KEYWORD; }
+"char" { return TOKEN_RESERVED_KEYWORD; }
+"class" { return TOKEN_RESERVED_KEYWORD; }
+"const" { return TOKEN_RESERVED_KEYWORD; }
+"debugger" { return TOKEN_RESERVED_KEYWORD; }
+"double" { return TOKEN_RESERVED_KEYWORD; }
+"enum" { return TOKEN_RESERVED_KEYWORD; }
+"export" { return TOKEN_RESERVED_KEYWORD; }
+"extends" { return TOKEN_RESERVED_KEYWORD; }
+"final" { return TOKEN_RESERVED_KEYWORD; }
+"float" { return TOKEN_RESERVED_KEYWORD; }
+"goto" { return TOKEN_RESERVED_KEYWORD; }
+"implements" { return TOKEN_RESERVED_KEYWORD; }
+"import" { return TOKEN_RESERVED_KEYWORD; }
+ /*"int" { return TOKEN_RESERVED_KEYWORD; }*/
+"interface" { return TOKEN_RESERVED_KEYWORD; }
+"long" { return TOKEN_RESERVED_KEYWORD; }
+"native" { return TOKEN_RESERVED_KEYWORD; }
+"package" { return TOKEN_RESERVED_KEYWORD; }
+"private" { return TOKEN_RESERVED_KEYWORD; }
+"protected" { return TOKEN_RESERVED_KEYWORD; }
+"public" { return TOKEN_RESERVED_KEYWORD; }
+"short" { return TOKEN_RESERVED_KEYWORD; }
+"static" { return TOKEN_RESERVED_KEYWORD; }
+"super" { return TOKEN_RESERVED_KEYWORD; }
+"synchronized" { return TOKEN_RESERVED_KEYWORD; }
+"throws" { return TOKEN_RESERVED_KEYWORD; }
+"transient" { return TOKEN_RESERVED_KEYWORD; }
+"volatile" { return TOKEN_RESERVED_KEYWORD; }
+
+"undefined" { return TOKEN_UNDEFINED; }
+
+"null" { return TOKEN_NULL; }
"true" {
- count ();
value->value.v_boolean = 1;
return TOKEN_BOOLEAN;
}
"false" {
- count ();
value->value.v_boolean = 0;
return TOKEN_BOOLEAN;
}
0[xX][0-9a-fA-F]+ {
- count ();
value->value.v_number =
g_ascii_strtoull (yytext, NULL, 16);
return TOKEN_NUMBER;
}
([1-9][0-9]*|0)(\.[0-9]*)?([eE][+-]?[0-9]+)? {
- count ();
value->value.v_number = g_ascii_strtod (yytext, NULL);
return TOKEN_NUMBER;
}
\.[0-9]+([eE][+-]?[0-9]+)? {
- count ();
value->value.v_number = g_ascii_strtod (yytext, NULL);
return TOKEN_NUMBER;
}
\" {
- count ();
string = g_string_new ("");
BEGIN(str);
}
<str>{
\" {
- count ();
BEGIN(INITIAL);
value->value.v_string = g_string_free (string, FALSE);
return TOKEN_STRING;
}
\n {
- count ();
BEGIN(INITIAL);
g_string_free (string, TRUE);
value->value.v_error = g_strdup (
@@ -256,7 +228,6 @@ identifier_part [$_a-zA-Z0-9]
}
\\[0-7]{1,3} {
guint64 result;
- count ();
result = g_ascii_strtoull (yytext + 1, NULL, 8);
if (result > 0xff || result == 0) {
value->value.v_error = g_strdup_printf (
@@ -267,14 +238,12 @@ identifier_part [$_a-zA-Z0-9]
}
}
\\[0-9]+ {
- count ();
value->value.v_error = g_strdup_printf (
"Invalid escape sequence %s", yytext);
return TOKEN_ERROR;
}
\\x[0-9a-fA-F]{2} {
guint64 result;
- count ();
result = g_ascii_strtoull (yytext + 2, NULL, 16);
if (result == 0) {
value->value.v_error = g_strdup_printf (
@@ -284,16 +253,15 @@ identifier_part [$_a-zA-Z0-9]
g_string_append_c (string, result);
}
}
- \\b { count (); g_string_append_c (string, '\b'); }
- \\f { count (); g_string_append_c (string, '\f'); }
- \\n { count (); g_string_append_c (string, '\n'); }
- \\r { count (); g_string_append_c (string, '\r'); }
- \\t { count (); g_string_append_c (string, '\t'); }
- \\v { count (); g_string_append_c (string, '\v'); }
- \\. { count (); g_string_append_c (string, yytext[1]); }
+ \\b { g_string_append_c (string, '\b'); }
+ \\f { g_string_append_c (string, '\f'); }
+ \\n { g_string_append_c (string, '\n'); }
+ \\r { g_string_append_c (string, '\r'); }
+ \\t { g_string_append_c (string, '\t'); }
+ \\v { g_string_append_c (string, '\v'); }
+ \\. { g_string_append_c (string, yytext[1]); }
[^\\\n\"]+ {
char *p;
- count ();
for (p = yytext; *p != '\0'; p++) {
g_string_append_c (string, *p);
}
@@ -301,13 +269,11 @@ identifier_part [$_a-zA-Z0-9]
}
{identifier_start}({identifier_part})* {
- count ();
value->value.v_identifier = g_strdup (yytext);
return TOKEN_IDENTIFIER;
}
. {
- count ();
value->value.v_error = g_strdup_printf (
"Unknown character '%c'", yytext[0]);
return TOKEN_ERROR;
@@ -315,12 +281,3 @@ identifier_part [$_a-zA-Z0-9]
%%
-static void new_line (void)
-{
- lex_line_number++;
-}
-
-static void count (void)
-{
- lex_position += yyleng;
-}
commit 73fbc0c89027a81d22db4164748c884cfecfb6fa
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 25 16:31:21 2008 +0200
get rid of ValueType
we can use the token to identify the value contents
PS: no, the parser still doesn't work
diff --git a/vivified/code/vivi_parser.c b/vivified/code/vivi_parser.c
index 2ed3b93..994ea6e 100644
--- a/vivified/code/vivi_parser.c
+++ b/vivified/code/vivi_parser.c
@@ -623,7 +623,7 @@ peek_boolean_value (ParseData *data)
{
const ViviParserValue *value = vivi_parser_scanner_get_value (data->scanner, 1);
- if (value->type == VALUE_TYPE_BOOLEAN) {
+ if (value->token == TOKEN_BOOLEAN) {
return value->value.v_boolean;
} else {
return FALSE;
@@ -638,7 +638,7 @@ parse_boolean_value (ParseData *data)
parse_token (data, TOKEN_BOOLEAN);
value = vivi_parser_scanner_get_value (data->scanner, 0);
- if (value->type == VALUE_TYPE_BOOLEAN) {
+ if (value->token == TOKEN_BOOLEAN) {
return value->value.v_boolean;
} else {
return FALSE;
@@ -670,7 +670,7 @@ peek_numeric_value (ParseData *data)
{
const ViviParserValue *value = vivi_parser_scanner_get_value (data->scanner, 1);
- if (value->type == VALUE_TYPE_NUMBER) {
+ if (value->token == TOKEN_NUMBER) {
return value->value.v_number;
} else {
return NAN;
@@ -685,7 +685,7 @@ parse_numeric_value (ParseData *data)
parse_token (data, TOKEN_NUMBER);
value = vivi_parser_scanner_get_value (data->scanner, 0);
- if (value->type == VALUE_TYPE_NUMBER) {
+ if (value->token == TOKEN_NUMBER) {
return value->value.v_number;
} else {
return NAN;
@@ -716,7 +716,7 @@ G_GNUC_UNUSED static const char *
peek_string_value (ParseData *data)
{
const ViviParserValue *value = vivi_parser_scanner_get_value (data->scanner, 1);
- if (value->type == VALUE_TYPE_STRING) {
+ if (value->token == TOKEN_STRING) {
return value->value.v_string;
} else {
return "undefined";
@@ -731,7 +731,7 @@ parse_string_value (ParseData *data)
parse_token (data, TOKEN_STRING);
value = vivi_parser_scanner_get_value (data->scanner, 0);
- if (value->type == VALUE_TYPE_STRING) {
+ if (value->token == TOKEN_STRING) {
return value->value.v_string;
} else {
return "undefined";
@@ -808,7 +808,7 @@ peek_identifier_value (ParseData *data)
{
const ViviParserValue *value = vivi_parser_scanner_get_value (data->scanner, 1);
- if (value->type == VALUE_TYPE_IDENTIFIER) {
+ if (value->token == TOKEN_IDENTIFIER) {
return value->value.v_identifier;
} else {
return "undefined";
@@ -822,7 +822,7 @@ parse_identifier_value (ParseData *data)
parse_token (data, TOKEN_IDENTIFIER);
value = vivi_parser_scanner_get_value (data->scanner, 0);
- if (value->type == VALUE_TYPE_IDENTIFIER) {
+ if (value->token == TOKEN_IDENTIFIER) {
return value->value.v_identifier;
} else {
return "undefined";
diff --git a/vivified/code/vivi_parser_scanner.c b/vivified/code/vivi_parser_scanner.c
index 67d30b3..f8f9b8b 100644
--- a/vivified/code/vivi_parser_scanner.c
+++ b/vivified/code/vivi_parser_scanner.c
@@ -30,28 +30,16 @@ G_DEFINE_TYPE (ViviParserScanner, vivi_parser_scanner, G_TYPE_OBJECT)
static void
vivi_parser_value_reset (ViviParserValue *value)
{
- switch (value->type) {
- case VALUE_TYPE_STRING:
- g_free (value->value.v_string);
- break;
- case VALUE_TYPE_IDENTIFIER:
- g_free (value->value.v_identifier);
- break;
- case VALUE_TYPE_ERROR:
- g_free (value->value.v_error);
- break;
- case VALUE_TYPE_NONE:
- case VALUE_TYPE_BOOLEAN:
- case VALUE_TYPE_NUMBER:
- /* nothing */
- break;
- default:
- g_assert_not_reached ();
- break;
+ if (value->token == TOKEN_STRING) {
+ g_free (value->value.v_string);
+ } else if (value->token == TOKEN_IDENTIFIER) {
+ g_free (value->value.v_identifier);
+ } else if (value->token == TOKEN_ERROR) {
+ g_free (value->value.v_error);
}
/* FIXME: do a memset 0 here? */
- value->type = VALUE_TYPE_NONE;
+ value->token = TOKEN_NONE;
}
static void
@@ -244,7 +232,6 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
if (scanner->file == NULL) {
value->token = TOKEN_NONE;
- value->type = VALUE_TYPE_NONE;
value->column = 0;
value->position = 0;
value->line_number = 0;
@@ -253,7 +240,6 @@ vivi_parser_scanner_advance (ViviParserScanner *scanner)
value->line_terminator = FALSE;
for (;;) {
value->token = yylex (value);
- value->type = VALUE_TYPE_NONE;
g_print ("got %s\n", vivi_parser_scanner_token_name (value->token));
if (value->token == TOKEN_LINE_TERMINATOR) {
value->line_terminator = TRUE;
diff --git a/vivified/code/vivi_parser_scanner.h b/vivified/code/vivi_parser_scanner.h
index d514be6..b4beeaf 100644
--- a/vivified/code/vivi_parser_scanner.h
+++ b/vivified/code/vivi_parser_scanner.h
@@ -147,18 +147,8 @@ typedef enum {
TOKEN_LAST
} ViviParserScannerToken;
-typedef enum {
- VALUE_TYPE_NONE,
- VALUE_TYPE_BOOLEAN,
- VALUE_TYPE_NUMBER,
- VALUE_TYPE_STRING,
- VALUE_TYPE_IDENTIFIER,
- VALUE_TYPE_ERROR
-} ViviParserScannerValueType;
-
typedef struct {
ViviParserScannerToken token;
- ViviParserScannerValueType type;
union {
gboolean v_boolean;
double v_number;
diff --git a/vivified/code/vivi_parser_scanner_lex.l b/vivified/code/vivi_parser_scanner_lex.l
index 85bb04d..b7ea652 100644
--- a/vivified/code/vivi_parser_scanner_lex.l
+++ b/vivified/code/vivi_parser_scanner_lex.l
@@ -56,7 +56,6 @@ identifier_part [$_a-zA-Z0-9]
<<EOF>> {
count ();
BEGIN(INITIAL);
- value->type = VALUE_TYPE_ERROR;
value->value.v_error =
g_strdup ("Unterminated comment");
return TOKEN_ERROR;
@@ -206,20 +205,17 @@ identifier_part [$_a-zA-Z0-9]
"null" { count (); return TOKEN_NULL; }
"true" {
count ();
- value->type = VALUE_TYPE_BOOLEAN;
value->value.v_boolean = 1;
return TOKEN_BOOLEAN;
}
"false" {
count ();
- value->type = VALUE_TYPE_BOOLEAN;
value->value.v_boolean = 0;
return TOKEN_BOOLEAN;
}
0[xX][0-9a-fA-F]+ {
count ();
- value->type = VALUE_TYPE_NUMBER;
value->value.v_number =
g_ascii_strtoull (yytext, NULL, 16);
return TOKEN_NUMBER;
@@ -227,14 +223,12 @@ identifier_part [$_a-zA-Z0-9]
([1-9][0-9]*|0)(\.[0-9]*)?([eE][+-]?[0-9]+)? {
count ();
- value->type = VALUE_TYPE_NUMBER;
value->value.v_number = g_ascii_strtod (yytext, NULL);
return TOKEN_NUMBER;
}
\.[0-9]+([eE][+-]?[0-9]+)? {
count ();
- value->type = VALUE_TYPE_NUMBER;
value->value.v_number = g_ascii_strtod (yytext, NULL);
return TOKEN_NUMBER;
}
@@ -249,7 +243,6 @@ identifier_part [$_a-zA-Z0-9]
\" {
count ();
BEGIN(INITIAL);
- value->type = VALUE_TYPE_STRING;
value->value.v_string = g_string_free (string, FALSE);
return TOKEN_STRING;
}
@@ -257,7 +250,6 @@ identifier_part [$_a-zA-Z0-9]
count ();
BEGIN(INITIAL);
g_string_free (string, TRUE);
- value->type = VALUE_TYPE_ERROR;
value->value.v_error = g_strdup (
"Unterminated string constant");
return TOKEN_ERROR;
@@ -267,7 +259,6 @@ identifier_part [$_a-zA-Z0-9]
count ();
result = g_ascii_strtoull (yytext + 1, NULL, 8);
if (result > 0xff || result == 0) {
- value->type = VALUE_TYPE_ERROR;
value->value.v_error = g_strdup_printf (
"Invalid escape sequence %s", yytext);
return TOKEN_ERROR;
@@ -277,7 +268,6 @@ identifier_part [$_a-zA-Z0-9]
}
\\[0-9]+ {
count ();
- value->type = VALUE_TYPE_ERROR;
value->value.v_error = g_strdup_printf (
"Invalid escape sequence %s", yytext);
return TOKEN_ERROR;
@@ -287,7 +277,6 @@ identifier_part [$_a-zA-Z0-9]
count ();
result = g_ascii_strtoull (yytext + 2, NULL, 16);
if (result == 0) {
- value->type = VALUE_TYPE_ERROR;
value->value.v_error = g_strdup_printf (
"Invalid escape sequence %s", yytext);
return TOKEN_ERROR;
@@ -313,14 +302,12 @@ identifier_part [$_a-zA-Z0-9]
{identifier_start}({identifier_part})* {
count ();
- value->type = VALUE_TYPE_IDENTIFIER;
value->value.v_identifier = g_strdup (yytext);
return TOKEN_IDENTIFIER;
}
. {
count ();
- value->type = VALUE_TYPE_ERROR;
value->value.v_error = g_strdup_printf (
"Unknown character '%c'", yytext[0]);
return TOKEN_ERROR;
More information about the Swfdec-commits
mailing list