Browse Source

MViewer : Added Light & axis gizmo

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 11 years ago
parent
commit
f82a996c18
12 changed files with 971 additions and 680 deletions
  1. +17
    -9
      test/data/mesh-buffer.txt
  2. +178
    -123
      test/generated/scenesetup-parser.cpp
  3. +12
    -10
      test/generated/scenesetup-parser.h
  4. +509
    -381
      test/generated/scenesetup-parser.output
  5. +142
    -119
      test/generated/scenesetup-scanner.cpp
  6. +93
    -36
      test/meshviewer.cpp
  7. +1
    -1
      test/meshviewer.index.html
  8. +9
    -1
      test/scenesetup-parser.y
  9. +4
    -0
      test/scenesetup-scanner.l
  10. +2
    -0
      test/scenesetup.cpp
  11. +2
    -0
      test/scenesetup.h
  12. +2
    -0
      test/scenesetupdictionnary.js

+ 17
- 9
test/data/mesh-buffer.txt View File

@@ -1,16 +1,22 @@
addlight 0.0 position (1 -1 1) color #fff
addlight 0.0 position (-1 -1 -1) color #fff
clearcolor #000
addlight 0 position (4 -4 0) color #fff
addlight 1 position (0 0 6) color #bfb
clearcolor #d0d
showgizmo true
showlight true

//SCENE SETUP END

//addlight 0.0 position (1 0 1) color #0ff
//addlight 0.0 position (-0.2 -1 -0.5) color (.0 .2 .5 1)

//custom setmesh "sc#f00 ab 2 ty 1.5 ab 2"
custom setmesh "
tqw
//tqw
//CMD TEST
//sc#0f0 ab 1
sc#0f0 ab 5
//sc#0f0 afcb 1 -.2
//sc#0f0 acg 8 1 1 1 2 2 1.5 1.5 -.4
//sc#0f0 as 6 1 2
@@ -19,13 +25,17 @@ tqw
//sc#0f0 aq 1
//splt 2 smth 4 0 1
//[sc#0f0 ac 3 .5 .4 0 false false true ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 false false true ty .5 dup [ rz 90 ry 90 scv#00f dup [ ry 90 scv#f00 ] ] ]
//[sc#fff ab 1 tx 2]
//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup [ rz 90 ry 90 scv#00f dup [ ry 90 scv#f00 ] ] ]
//[sc#fff ab .1]
//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1]
//[sc#fff ab 1 tx .5 ty .5]
//[sc#fff ab 1 tx -.5 ty -.5]
//[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1]
//smth 3 1 1 smth 8 0 1
//[sc#fff loop 4 [ [loop 4 [ab 1 tx 2]] tz 2]]
@@ -40,8 +50,6 @@ tqw
"
//splt 0
//test
//[sc#f8f ab 1 splt 4 twy 90]


+ 178
- 123
test/generated/scenesetup-parser.cpp View File

@@ -67,7 +67,7 @@
/* User implementation prologue. */

/* Line 316 of lalr1.cc */
#line 75 "scenesetup-parser.y"
#line 76 "scenesetup-parser.y"

#include "../scenesetup-compiler.h"

@@ -435,49 +435,49 @@ namespace lol {
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 11:
case 12:

/* Line 677 of lalr1.cc */
#line 114 "scenesetup-parser.y"
#line 116 "scenesetup-parser.y"
{ uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; }
break;

case 12:
case 13:

/* Line 677 of lalr1.cc */
#line 115 "scenesetup-parser.y"
#line 117 "scenesetup-parser.y"
{ uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT";
uc.m_sstp.m_lights.Last()->SetPosition(vec4(vec3::zero, (yysemantic_stack_[(2) - (2)].fval))); }
break;

case 13:
case 14:

/* Line 677 of lalr1.cc */
#line 120 "scenesetup-parser.y"
#line 122 "scenesetup-parser.y"
{ if (uc.m_last_cmd == "ADDLIGHT")
uc.m_sstp.m_lights.Last()->SetPosition(vec4(vec3((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2]), uc.m_sstp.m_lights.Last()->GetPosition().w)); }
break;

case 14:
case 15:

/* Line 677 of lalr1.cc */
#line 122 "scenesetup-parser.y"
#line 124 "scenesetup-parser.y"
{ if (uc.m_last_cmd == "ADDLIGHT")
{ /* */ } }
break;

case 15:
case 16:

/* Line 677 of lalr1.cc */
#line 124 "scenesetup-parser.y"
#line 126 "scenesetup-parser.y"
{ if (uc.m_last_cmd == "ADDLIGHT")
uc.m_sstp.m_lights.Last()->SetColor(vec4((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2], (yysemantic_stack_[(2) - (2)].vval)[3])); }
break;

case 16:
case 17:

/* Line 677 of lalr1.cc */
#line 126 "scenesetup-parser.y"
#line 128 "scenesetup-parser.y"
{ uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
vec4 vv = vec4(v) * (1.f / 255.f);
@@ -485,133 +485,175 @@ namespace lol {
uc.m_sstp.m_lights.Last()->SetColor(vv); }
break;

case 17:
case 18:

/* Line 677 of lalr1.cc */
#line 131 "scenesetup-parser.y"
#line 136 "scenesetup-parser.y"
{ uc.m_sstp.m_clear_color = vec4((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2], (yysemantic_stack_[(2) - (2)].vval)[3]); }
break;

case 18:
case 19:

/* Line 677 of lalr1.cc */
#line 137 "scenesetup-parser.y"
{ uc.m_sstp.m_clear_color = vec4((yysemantic_stack_[(5) - (2)].vval)[0], (yysemantic_stack_[(5) - (2)].vval)[1], (yysemantic_stack_[(5) - (2)].vval)[2], 1.f); }
break;

case 20:

/* Line 677 of lalr1.cc */
#line 132 "scenesetup-parser.y"
#line 138 "scenesetup-parser.y"
{ uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
uc.m_sstp.m_clear_color = vec4(v) * (1.f / 255.f); }
break;

case 19:
case 21:

/* Line 677 of lalr1.cc */
#line 137 "scenesetup-parser.y"
#line 140 "scenesetup-parser.y"
{ uc.m_sstp.m_show_gizmo = (yysemantic_stack_[(2) - (2)].bval); }
break;

case 22:

/* Line 677 of lalr1.cc */
#line 141 "scenesetup-parser.y"
{ uc.m_sstp.m_show_lights = (yysemantic_stack_[(2) - (2)].bval); }
break;

case 23:

/* Line 677 of lalr1.cc */
#line 145 "scenesetup-parser.y"
{ uc.m_sstp.m_custom_cmd.Push((yysemantic_stack_[(3) - (2)].svval), (yysemantic_stack_[(3) - (3)].sval)); }
break;

case 20:
case 24:

/* Line 677 of lalr1.cc */
#line 143 "scenesetup-parser.y"
#line 151 "scenesetup-parser.y"
{ (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
break;

case 21:
case 25:

/* Line 677 of lalr1.cc */
#line 144 "scenesetup-parser.y"
#line 152 "scenesetup-parser.y"
{ (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
break;

case 22:
case 26:

/* Line 677 of lalr1.cc */
#line 145 "scenesetup-parser.y"
#line 153 "scenesetup-parser.y"
{ (yyval.fval) = (float)(yysemantic_stack_[(1) - (1)].ival); }
break;

case 23:
case 27:

/* Line 677 of lalr1.cc */
#line 146 "scenesetup-parser.y"
#line 154 "scenesetup-parser.y"
{ (yyval.fval) = -(float)(yysemantic_stack_[(2) - (2)].ival); }
break;

case 24:
case 28:

/* Line 677 of lalr1.cc */
#line 150 "scenesetup-parser.y"
#line 158 "scenesetup-parser.y"
{ (yyval.ival) = (yysemantic_stack_[(1) - (1)].ival); }
break;

case 25:
case 29:

/* Line 677 of lalr1.cc */
#line 151 "scenesetup-parser.y"
#line 159 "scenesetup-parser.y"
{ (yyval.ival) = -(yysemantic_stack_[(2) - (2)].ival); }
break;

case 26:
case 30:

/* Line 677 of lalr1.cc */
#line 152 "scenesetup-parser.y"
#line 160 "scenesetup-parser.y"
{ (yyval.ival) = (int)(yysemantic_stack_[(1) - (1)].fval); }
break;

case 27:
case 31:

/* Line 677 of lalr1.cc */
#line 153 "scenesetup-parser.y"
#line 161 "scenesetup-parser.y"
{ (yyval.ival) = -(int)(yysemantic_stack_[(2) - (2)].fval); }
break;

case 28:
case 32:

/* Line 677 of lalr1.cc */
#line 158 "scenesetup-parser.y"
#line 166 "scenesetup-parser.y"
{ (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); }
break;

case 29:
case 33:

/* Line 677 of lalr1.cc */
#line 159 "scenesetup-parser.y"
#line 167 "scenesetup-parser.y"
{ (yyval.vval)[0] = (yysemantic_stack_[(5) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(5) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(5) - (4)].fval); }
break;

case 30:
case 34:

/* Line 677 of lalr1.cc */
#line 168 "scenesetup-parser.y"
#line 176 "scenesetup-parser.y"
{ (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[3] = (yysemantic_stack_[(3) - (2)].fval); }
break;

case 31:
case 35:

/* Line 677 of lalr1.cc */
#line 169 "scenesetup-parser.y"
#line 177 "scenesetup-parser.y"
{ (yyval.vval)[0] = (yysemantic_stack_[(6) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(6) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(6) - (4)].fval); (yyval.vval)[3] = (yysemantic_stack_[(6) - (5)].fval); }
break;

case 32:
case 36:

/* Line 677 of lalr1.cc */
#line 180 "scenesetup-parser.y"
{ (yyval.svval) = (yysemantic_stack_[(1) - (1)].svval); }
#line 182 "scenesetup-parser.y"
{ (yyval.bval) = (yysemantic_stack_[(1) - (1)].bval); }
break;

case 33:
case 37:

/* Line 677 of lalr1.cc */
#line 183 "scenesetup-parser.y"
{ (yyval.bval) = !!(yysemantic_stack_[(1) - (1)].ival); }
break;

case 38:

/* Line 677 of lalr1.cc */
#line 184 "scenesetup-parser.y"
{ (yyval.bval) = !!(yysemantic_stack_[(1) - (1)].fval); }
break;

case 39:

/* Line 677 of lalr1.cc */
#line 188 "scenesetup-parser.y"
{ (yyval.svval) = (yysemantic_stack_[(1) - (1)].svval); }
break;

case 40:

/* Line 677 of lalr1.cc */
#line 192 "scenesetup-parser.y"
{ String t = (yysemantic_stack_[(1) - (1)].sval);
t.Replace('"', ' ', true);
free((yysemantic_stack_[(1) - (1)].sval));
(yyval.sval) = strdup((const char *)t.C()); }
break;

case 34:
case 41:

/* Line 677 of lalr1.cc */
#line 188 "scenesetup-parser.y"
#line 196 "scenesetup-parser.y"
{ String t = (yysemantic_stack_[(2) - (1)].sval);
t += (yysemantic_stack_[(2) - (2)].sval);
t.Replace('"', ' ', true);
@@ -623,7 +665,7 @@ namespace lol {


/* Line 677 of lalr1.cc */
#line 627 "generated/scenesetup-parser.cpp"
#line 669 "generated/scenesetup-parser.cpp"
default:
break;
}
@@ -828,16 +870,17 @@ namespace lol {

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
const signed char SceneSetupParser::yypact_ninf_ = -18;
const signed char SceneSetupParser::yypact_ninf_ = -20;
const signed char
SceneSetupParser::yypact_[] =
{
30, 8, -13, -13, -6, -2, 3, 1, 26, 30,
30, -18, -18, -18, -18, -18, -18, 12, -18, 8,
-18, -18, -18, 8, -18, -18, -18, -18, 14, -18,
-18, -18, -18, -18, -18, 12, -18, -18, -8, -4,
14, -18, -18, -18, -18, 8, -18, 8, -18, 13,
8, -18, 21, -18
38, 4, -18, -18, -7, 14, 16, 16, -10, 15,
21, 38, 38, -20, -20, -20, -20, -20, -20, -20,
6, -20, 4, -20, -20, -20, 4, -20, -20, -20,
-20, -20, -20, -20, -20, -20, 7, -20, -20, -20,
-20, -20, -20, 6, -20, -20, -9, -5, 18, 7,
-20, -20, -20, -20, 4, -20, 4, -18, -20, 10,
4, -20, -20, 17, -20
};

/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@@ -846,28 +889,29 @@ namespace lol {
const unsigned char
SceneSetupParser::yydefact_[] =
{
0, 11, 0, 0, 0, 0, 0, 0, 0, 3,
5, 6, 8, 9, 10, 20, 22, 0, 12, 0,
13, 14, 16, 0, 15, 18, 17, 32, 0, 1,
2, 4, 7, 20, 22, 0, 21, 23, 0, 0,
33, 19, 21, 23, 28, 0, 30, 0, 34, 0,
0, 29, 0, 31
0, 12, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 5, 6, 8, 9, 10, 11, 24, 26,
0, 13, 0, 14, 15, 17, 0, 16, 20, 18,
38, 37, 36, 21, 22, 39, 0, 1, 2, 4,
7, 24, 26, 0, 25, 27, 0, 0, 0, 40,
23, 25, 27, 32, 0, 34, 0, 0, 41, 0,
0, 19, 33, 0, 35
};

/* YYPGOTO[NTERM-NUM]. */
const signed char
SceneSetupParser::yypgoto_[] =
{
-18, -18, 22, -18, -18, 31, -18, -18, -18, -17,
7, 40, 39, -18, 5
-20, -20, 25, -20, -20, 27, -20, -20, -20, -20,
-20, -19, 8, -3, 35, 43, -20, 3
};

/* YYDEFGOTO[NTERM-NUM]. */
const signed char
SceneSetupParser::yydefgoto_[] =
{
-1, 7, 8, 9, 10, 11, 12, 13, 14, 18,
37, 20, 24, 28, 41
-1, 9, 10, 11, 12, 13, 14, 15, 16, 48,
17, 21, 45, 23, 27, 33, 36, 50
};

/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -877,22 +921,24 @@ namespace lol {
const unsigned char
SceneSetupParser::yytable_[] =
{
36, 29, 38, 15, 16, 19, 39, 15, 16, 17,
22, 44, 23, 17, 25, 46, 23, 27, 42, 15,
16, 45, 47, 33, 34, 17, 30, 40, 49, 35,
50, 31, 51, 52, 1, 2, 3, 4, 5, 6,
53, 32, 43, 21, 26, 48
24, 44, 22, 46, 18, 19, 35, 47, 18, 19,
20, 25, 53, 26, 20, 37, 55, 18, 19, 41,
42, 38, 49, 20, 51, 43, 57, 54, 56, 30,
31, 62, 28, 32, 26, 59, 39, 60, 64, 40,
29, 63, 1, 2, 3, 4, 5, 6, 7, 8,
34, 52, 58, 0, 61
};

/* YYCHECK. */
const unsigned char
const signed char
SceneSetupParser::yycheck_[] =
{
17, 0, 19, 11, 12, 18, 23, 11, 12, 17,
16, 19, 18, 17, 16, 19, 18, 14, 35, 11,
12, 38, 39, 11, 12, 17, 0, 13, 45, 17,
47, 9, 19, 50, 4, 5, 6, 7, 8, 9,
19, 10, 35, 3, 5, 40
3, 20, 20, 22, 13, 14, 16, 26, 13, 14,
19, 18, 21, 20, 19, 0, 21, 13, 14, 13,
14, 0, 15, 19, 43, 19, 8, 46, 47, 13,
14, 21, 18, 17, 20, 54, 11, 56, 21, 12,
5, 60, 4, 5, 6, 7, 8, 9, 10, 11,
7, 43, 49, -1, 57
};

/* STOS_[STATE-NUM] -- The (internal number of the) accessing
@@ -900,12 +946,13 @@ namespace lol {
const unsigned char
SceneSetupParser::yystos_[] =
{
0, 4, 5, 6, 7, 8, 9, 21, 22, 23,
24, 25, 26, 27, 28, 11, 12, 17, 29, 18,
31, 31, 16, 18, 32, 16, 32, 14, 33, 0,
0, 22, 25, 11, 12, 17, 29, 30, 29, 29,
13, 34, 29, 30, 19, 29, 19, 29, 34, 29,
29, 19, 29, 19
0, 4, 5, 6, 7, 8, 9, 10, 11, 23,
24, 25, 26, 27, 28, 29, 30, 32, 13, 14,
19, 33, 20, 35, 35, 18, 20, 36, 18, 36,
13, 14, 17, 37, 37, 16, 38, 0, 0, 24,
27, 13, 14, 19, 33, 34, 33, 33, 31, 15,
39, 33, 34, 21, 33, 21, 33, 8, 39, 33,
33, 35, 21, 33, 21
};

#if YYDEBUG
@@ -915,7 +962,8 @@ namespace lol {
SceneSetupParser::yytoken_number_[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 45, 40, 41
265, 266, 267, 268, 269, 270, 271, 272, 273, 45,
40, 41
};
#endif

@@ -923,10 +971,11 @@ namespace lol {
const unsigned char
SceneSetupParser::yyr1_[] =
{
0, 20, 21, 22, 22, 23, 24, 24, 25, 25,
25, 26, 26, 27, 27, 27, 27, 27, 27, 28,
29, 29, 29, 29, 30, 30, 30, 30, 31, 31,
32, 32, 33, 34, 34
0, 22, 23, 24, 24, 25, 26, 26, 27, 27,
27, 27, 28, 28, 29, 29, 29, 29, 31, 30,
30, 30, 30, 32, 33, 33, 33, 33, 34, 34,
34, 34, 35, 35, 36, 36, 37, 37, 37, 38,
39, 39
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@@ -934,9 +983,10 @@ namespace lol {
SceneSetupParser::yyr2_[] =
{
0, 2, 2, 1, 2, 1, 1, 2, 1, 1,
1, 1, 2, 2, 2, 2, 2, 2, 2, 3,
1, 2, 1, 2, 1, 2, 1, 2, 3, 5,
3, 6, 1, 1, 2
1, 1, 1, 2, 2, 2, 2, 2, 0, 5,
2, 2, 2, 3, 1, 2, 1, 2, 1, 2,
1, 2, 3, 5, 3, 6, 1, 1, 1, 1,
1, 2
};

#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
@@ -947,11 +997,12 @@ namespace lol {
{
"T_END", "error", "$undefined", "T_COLOR", "T_ADDLIGHT",
"T_OBJPOSITION", "T_OBJLOOKAT", "T_OBJCOLOR", "T_CLEARCOLOR",
"T_CUSTOMCMD", "T_ERROR", "F_NUMBER", "I_NUMBER", "STRING", "STRING_VAR",
"BOOLEAN", "COLOR", "'-'", "'('", "')'", "$accept", "sstp_description",
"sstp_expression_list", "sstp_expression", "sstp_command_list",
"sstp_command", "light_command", "setup_command", "custom_command", "fv",
"iv", "v3", "v4", "svv", "sv", 0
"T_SHOWGIZMO", "T_SHOWLIGHT", "T_CUSTOMCMD", "T_ERROR", "F_NUMBER",
"I_NUMBER", "STRING", "STRING_VAR", "BOOLEAN", "COLOR", "'-'", "'('",
"')'", "$accept", "sstp_description", "sstp_expression_list",
"sstp_expression", "sstp_command_list", "sstp_command", "light_command",
"setup_command", "scene_command", "$@1", "custom_command", "fv", "iv",
"v3", "v4", "bv", "svv", "sv", 0
};
#endif

@@ -960,16 +1011,18 @@ namespace lol {
const SceneSetupParser::rhs_number_type
SceneSetupParser::yyrhs_[] =
{
21, 0, -1, 22, 0, -1, 23, -1, 23, 22,
-1, 24, -1, 25, -1, 24, 25, -1, 26, -1,
27, -1, 28, -1, 4, -1, 4, 29, -1, 5,
31, -1, 6, 31, -1, 7, 32, -1, 7, 16,
-1, 8, 32, -1, 8, 16, -1, 9, 33, 34,
-1, 11, -1, 17, 29, -1, 12, -1, 17, 30,
-1, 12, -1, 17, 30, -1, 11, -1, 17, 29,
-1, 18, 29, 19, -1, 18, 29, 29, 29, 19,
-1, 18, 29, 19, -1, 18, 29, 29, 29, 29,
19, -1, 14, -1, 13, -1, 13, 34, -1
23, 0, -1, 24, 0, -1, 25, -1, 25, 24,
-1, 26, -1, 27, -1, 26, 27, -1, 28, -1,
29, -1, 30, -1, 32, -1, 4, -1, 4, 33,
-1, 5, 35, -1, 6, 35, -1, 7, 36, -1,
7, 18, -1, -1, 8, 36, 31, 8, 35, -1,
8, 18, -1, 9, 37, -1, 10, 37, -1, 11,
38, 39, -1, 13, -1, 19, 33, -1, 14, -1,
19, 34, -1, 14, -1, 19, 34, -1, 13, -1,
19, 33, -1, 20, 33, 21, -1, 20, 33, 33,
33, 21, -1, 20, 33, 21, -1, 20, 33, 33,
33, 33, 21, -1, 17, -1, 14, -1, 13, -1,
16, -1, 15, -1, 15, 39, -1
};

/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
@@ -978,19 +1031,21 @@ namespace lol {
SceneSetupParser::yyprhs_[] =
{
0, 0, 3, 6, 8, 11, 13, 15, 18, 20,
22, 24, 26, 29, 32, 35, 38, 41, 44, 47,
51, 53, 56, 58, 61, 63, 66, 68, 71, 75,
81, 85, 92, 94, 96
22, 24, 26, 28, 31, 34, 37, 40, 43, 44,
50, 53, 56, 59, 63, 65, 68, 70, 73, 75,
78, 80, 83, 87, 93, 97, 104, 106, 108, 110,
112, 114
};

/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
const unsigned char
SceneSetupParser::yyrline_[] =
{
0, 90, 90, 94, 95, 99, 103, 104, 108, 109,
110, 114, 115, 120, 122, 124, 126, 131, 132, 137,
143, 144, 145, 146, 150, 151, 152, 153, 158, 159,
168, 169, 180, 184, 188
0, 91, 91, 95, 96, 100, 104, 105, 109, 110,
111, 112, 116, 117, 122, 124, 126, 128, 136, 136,
138, 140, 141, 145, 151, 152, 153, 154, 158, 159,
160, 161, 166, 167, 176, 177, 182, 183, 184, 188,
192, 196
};

// Print the state stack on the debug stream.
@@ -1034,7 +1089,7 @@ namespace lol {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18, 19, 2, 2, 2, 17, 2, 2, 2, 2,
20, 21, 2, 2, 2, 19, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -1057,7 +1112,7 @@ namespace lol {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16
15, 16, 17, 18
};
if ((unsigned int) t <= yyuser_token_number_max_)
return translate_table[t];
@@ -1066,26 +1121,26 @@ namespace lol {
}

const int SceneSetupParser::yyeof_ = 0;
const int SceneSetupParser::yylast_ = 45;
const int SceneSetupParser::yynnts_ = 15;
const int SceneSetupParser::yylast_ = 54;
const int SceneSetupParser::yynnts_ = 18;
const int SceneSetupParser::yyempty_ = -2;
const int SceneSetupParser::yyfinal_ = 29;
const int SceneSetupParser::yyfinal_ = 37;
const int SceneSetupParser::yyterror_ = 1;
const int SceneSetupParser::yyerrcode_ = 256;
const int SceneSetupParser::yyntokens_ = 20;
const int SceneSetupParser::yyntokens_ = 22;

const unsigned int SceneSetupParser::yyuser_token_number_max_ = 271;
const unsigned int SceneSetupParser::yyuser_token_number_max_ = 273;
const SceneSetupParser::token_number_type SceneSetupParser::yyundef_token_ = 2;


} // lol

/* Line 1053 of lalr1.cc */
#line 1085 "generated/scenesetup-parser.cpp"
#line 1140 "generated/scenesetup-parser.cpp"


/* Line 1055 of lalr1.cc */
#line 196 "scenesetup-parser.y"
#line 204 "scenesetup-parser.y"


void lol::SceneSetupParser::error(const SceneSetupParser::location_type& l,


+ 12
- 10
test/generated/scenesetup-parser.h View File

@@ -143,14 +143,16 @@ namespace lol {
T_OBJLOOKAT = 261,
T_OBJCOLOR = 262,
T_CLEARCOLOR = 263,
T_CUSTOMCMD = 264,
T_ERROR = 265,
F_NUMBER = 266,
I_NUMBER = 267,
STRING = 268,
STRING_VAR = 269,
BOOLEAN = 270,
COLOR = 271
T_SHOWGIZMO = 264,
T_SHOWLIGHT = 265,
T_CUSTOMCMD = 266,
T_ERROR = 267,
F_NUMBER = 268,
I_NUMBER = 269,
STRING = 270,
STRING_VAR = 271,
BOOLEAN = 272,
COLOR = 273
};

};
@@ -247,7 +249,7 @@ namespace lol {
static const unsigned char yytable_[];
static const signed char yytable_ninf_;

static const unsigned char yycheck_[];
static const signed char yycheck_[];

/// For a state, its accessing symbol.
static const unsigned char yystos_[];
@@ -324,7 +326,7 @@ namespace lol {
} // lol

/* Line 34 of lalr1.cc */
#line 328 "generated/scenesetup-parser.h"
#line 330 "generated/scenesetup-parser.h"





+ 509
- 381
test/generated/scenesetup-parser.output
File diff suppressed because it is too large
View File


+ 142
- 119
test/generated/scenesetup-scanner.cpp View File

@@ -330,8 +330,8 @@ typedef unsigned char YY_CHAR;
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;

#define YY_NUM_RULES 24
#define YY_END_OF_BUFFER 25
#define YY_NUM_RULES 27
#define YY_END_OF_BUFFER 28
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -339,17 +339,19 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[87] =
static yyconst flex_int16_t yy_accept[101] =
{ 0,
0, 0, 25, 23, 22, 21, 23, 23, 19, 20,
23, 18, 23, 23, 14, 23, 23, 23, 23, 23,
23, 23, 0, 15, 0, 0, 14, 13, 17, 16,
16, 16, 16, 16, 16, 16, 16, 16, 0, 0,
17, 16, 16, 16, 16, 16, 16, 16, 16, 7,
0, 13, 16, 16, 16, 16, 16, 16, 16, 11,
8, 16, 16, 4, 16, 12, 16, 16, 0, 16,
16, 6, 3, 16, 9, 16, 16, 16, 0, 1,
16, 2, 10, 16, 5, 0
0, 0, 28, 26, 25, 24, 26, 26, 22, 23,
26, 21, 26, 26, 17, 26, 26, 26, 26, 26,
26, 26, 26, 0, 18, 0, 0, 17, 16, 20,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
0, 0, 20, 19, 19, 19, 19, 19, 19, 19,
19, 19, 10, 0, 16, 19, 19, 19, 19, 19,
19, 19, 19, 14, 11, 19, 19, 4, 19, 15,
19, 19, 19, 19, 0, 19, 19, 8, 3, 19,
19, 19, 12, 19, 19, 19, 19, 19, 0, 1,
19, 2, 19, 19, 13, 19, 6, 7, 5, 0

} ;

static yyconst flex_int32_t yy_ec[256] =
@@ -366,8 +368,8 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 16, 1, 17, 13, 18, 19,

20, 21, 22, 23, 24, 15, 25, 26, 27, 28,
29, 30, 15, 31, 32, 33, 34, 15, 15, 15,
15, 15, 1, 1, 1, 1, 1, 1, 1, 1,
29, 30, 15, 31, 32, 33, 34, 15, 35, 15,
15, 36, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -384,86 +386,92 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;

static yyconst flex_int32_t yy_meta[35] =
static yyconst flex_int32_t yy_meta[37] =
{ 0,
1, 2, 1, 1, 1, 1, 1, 1, 3, 1,
1, 4, 5, 5, 3, 3, 5, 5, 5, 5,
5, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3
3, 3, 3, 3, 3, 3
} ;

static yyconst flex_int16_t yy_base[98] =
static yyconst flex_int16_t yy_base[112] =
{ 0,
0, 0, 127, 128, 128, 128, 122, 0, 128, 128,
25, 26, 113, 113, 29, 0, 104, 14, 105, 92,
91, 88, 114, 128, 0, 105, 32, 33, 0, 0,
97, 95, 88, 81, 86, 82, 78, 75, 0, 42,
0, 82, 90, 77, 72, 72, 78, 78, 81, 0,
88, 87, 74, 66, 65, 66, 74, 76, 59, 0,
0, 69, 72, 0, 62, 0, 55, 63, 0, 63,
56, 0, 0, 55, 0, 35, 37, 24, 0, 0,
20, 0, 128, 15, 0, 128, 54, 56, 59, 61,
66, 68, 70, 72, 74, 76, 78

0, 0, 142, 143, 143, 143, 137, 0, 143, 143,
27, 28, 128, 128, 31, 0, 119, 16, 120, 107,
106, 111, 102, 128, 143, 0, 119, 34, 35, 0,
0, 111, 109, 102, 95, 100, 96, 92, 94, 88,
0, 44, 0, 95, 103, 90, 85, 85, 91, 91,
79, 93, 0, 100, 99, 86, 78, 77, 78, 86,
88, 71, 32, 0, 0, 81, 84, 0, 74, 0,
67, 75, 74, 73, 0, 73, 66, 0, 0, 65,
57, 70, 0, 58, 64, 61, 61, 49, 0, 0,
38, 0, 28, 18, 143, 17, 0, 0, 0, 143,

58, 60, 63, 65, 70, 72, 74, 76, 78, 80,
82
} ;

static yyconst flex_int16_t yy_def[98] =
static yyconst flex_int16_t yy_def[112] =
{ 0,
86, 1, 86, 86, 86, 86, 87, 88, 86, 86,
86, 86, 86, 86, 86, 89, 89, 89, 89, 89,
89, 89, 87, 86, 90, 86, 86, 86, 91, 89,
89, 89, 89, 89, 89, 89, 89, 89, 92, 86,
91, 89, 89, 89, 89, 89, 89, 89, 89, 93,
86, 86, 89, 89, 89, 89, 89, 89, 89, 89,
94, 89, 89, 89, 89, 89, 89, 89, 95, 89,
89, 89, 89, 89, 96, 89, 89, 89, 97, 89,
89, 89, 86, 89, 89, 0, 86, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86

100, 1, 100, 100, 100, 100, 101, 102, 100, 100,
100, 100, 100, 100, 100, 103, 103, 103, 103, 103,
103, 103, 103, 101, 100, 104, 100, 100, 100, 105,
103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
106, 100, 105, 103, 103, 103, 103, 103, 103, 103,
103, 103, 107, 100, 100, 103, 103, 103, 103, 103,
103, 103, 103, 103, 108, 103, 103, 103, 103, 103,
103, 103, 103, 103, 109, 103, 103, 103, 103, 103,
103, 103, 110, 103, 103, 103, 103, 103, 111, 103,
103, 103, 103, 103, 100, 103, 103, 103, 103, 0,

100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100
} ;

static yyconst flex_int16_t yy_nxt[163] =
static yyconst flex_int16_t yy_nxt[180] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 16, 16, 4, 17, 18, 16, 16,
19, 16, 16, 16, 16, 20, 16, 16, 16, 21,
16, 16, 22, 16, 26, 26, 27, 27, 26, 32,
27, 26, 33, 27, 28, 85, 40, 34, 84, 51,
51, 82, 40, 52, 23, 23, 23, 23, 23, 25,
25, 30, 81, 30, 39, 39, 41, 80, 41, 41,
41, 50, 50, 61, 61, 69, 69, 75, 75, 79,
79, 83, 83, 78, 77, 76, 74, 73, 72, 71,
70, 68, 67, 66, 65, 64, 63, 62, 52, 52,

60, 59, 58, 57, 56, 55, 54, 53, 49, 48,
47, 46, 45, 44, 43, 42, 28, 24, 38, 37,
36, 35, 31, 29, 28, 24, 86, 3, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86
16, 22, 23, 16, 16, 16, 27, 27, 28, 28,
27, 33, 28, 27, 34, 28, 29, 99, 42, 35,
98, 54, 54, 73, 42, 55, 97, 74, 24, 24,
24, 24, 24, 26, 26, 31, 96, 31, 41, 41,
43, 94, 43, 43, 43, 53, 53, 65, 65, 75,
75, 83, 83, 89, 89, 95, 95, 93, 92, 91,
90, 88, 87, 86, 85, 84, 82, 81, 80, 79,

78, 77, 76, 72, 71, 70, 69, 68, 67, 66,
55, 55, 64, 63, 62, 61, 60, 59, 58, 57,
56, 52, 51, 50, 49, 48, 47, 46, 45, 44,
29, 25, 40, 39, 38, 37, 36, 32, 30, 29,
25, 100, 3, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100
} ;

static yyconst flex_int16_t yy_chk[163] =
static yyconst flex_int16_t yy_chk[180] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 11, 12, 11, 12, 15, 18,
15, 27, 18, 27, 28, 84, 28, 18, 81, 40,
40, 78, 28, 40, 87, 87, 87, 87, 87, 88,
88, 89, 77, 89, 90, 90, 91, 76, 91, 91,
91, 92, 92, 93, 93, 94, 94, 95, 95, 96,
96, 97, 97, 74, 71, 70, 68, 67, 65, 63,
62, 59, 58, 57, 56, 55, 54, 53, 52, 51,

49, 48, 47, 46, 45, 44, 43, 42, 38, 37,
36, 35, 34, 33, 32, 31, 26, 23, 22, 21,
20, 19, 17, 14, 13, 7, 3, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86
1, 1, 1, 1, 1, 1, 11, 12, 11, 12,
15, 18, 15, 28, 18, 28, 29, 96, 29, 18,
94, 42, 42, 63, 29, 42, 93, 63, 101, 101,
101, 101, 101, 102, 102, 103, 91, 103, 104, 104,
105, 88, 105, 105, 105, 106, 106, 107, 107, 108,
108, 109, 109, 110, 110, 111, 111, 87, 86, 85,
84, 82, 81, 80, 77, 76, 74, 73, 72, 71,

69, 67, 66, 62, 61, 60, 59, 58, 57, 56,
55, 54, 52, 51, 50, 49, 48, 47, 46, 45,
44, 40, 39, 38, 37, 36, 35, 34, 33, 32,
27, 24, 23, 22, 21, 20, 19, 17, 14, 13,
7, 3, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100
} ;

/* The intent behind this definition is that it'll catch
@@ -512,7 +520,7 @@ typedef lol::SceneSetupParser::token_type token_type;
#define yyterminate() return token::T_END
#define YY_NO_UNISTD_H
#define YY_USER_ACTION yylloc->columns(yyleng);
#line 516 "generated/scenesetup-scanner.cpp"
#line 524 "generated/scenesetup-scanner.cpp"

#define INITIAL 0

@@ -624,7 +632,7 @@ YY_DECL
yylloc->step();


#line 628 "generated/scenesetup-scanner.cpp"
#line 636 "generated/scenesetup-scanner.cpp"

if ( !(yy_init) )
{
@@ -677,13 +685,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 87 )
if ( yy_current_state >= 101 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 86 );
while ( yy_current_state != 100 );
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);

@@ -731,13 +739,28 @@ YY_RULE_SETUP
case 6:
YY_RULE_SETUP
#line 56 "scenesetup-scanner.l"
{ return token::T_SHOWGIZMO; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 57 "scenesetup-scanner.l"
{ return token::T_SHOWLIGHT; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 58 "scenesetup-scanner.l"
{ return token::T_CUSTOMCMD; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 60 "scenesetup-scanner.l"
{ return token::T_CUSTOMCMD; }
YY_BREAK
/* ======= BASE COLOR TYPES ========================================= */
/* COLOR */
case 7:
case 10:
YY_RULE_SETUP
#line 60 "scenesetup-scanner.l"
#line 64 "scenesetup-scanner.l"
{
uint32_t tmp = std::strtol(yytext + 1, nullptr, 16);
yylval->u32val = 0x11000000u * (tmp >> 8)
@@ -746,9 +769,9 @@ YY_RULE_SETUP
| 0x000000ffu;
return token::COLOR; }
YY_BREAK
case 8:
case 11:
YY_RULE_SETUP
#line 67 "scenesetup-scanner.l"
#line 71 "scenesetup-scanner.l"
{
uint32_t tmp = std::strtol(yytext + 1, nullptr, 16);
yylval->u32val = 0x11000000u * (tmp >> 12)
@@ -757,106 +780,106 @@ YY_RULE_SETUP
| 0x00000011u * (tmp & 0xf);
return token::COLOR; }
YY_BREAK
case 9:
case 12:
YY_RULE_SETUP
#line 74 "scenesetup-scanner.l"
#line 78 "scenesetup-scanner.l"
{
yylval->u32val = 0xffu
| 0x100u * (uint32_t)std::strtol(yytext + 1, nullptr, 16);
return token::COLOR; }
YY_BREAK
case 10:
case 13:
YY_RULE_SETUP
#line 78 "scenesetup-scanner.l"
#line 82 "scenesetup-scanner.l"
{
yylval->u32val = (uint32_t)std::strtol(yytext + 1, nullptr, 16);
return token::COLOR; }
YY_BREAK
/* ======= BASE DATA TYPES ========================================= */
/* BOOL */
case 11:
case 14:
YY_RULE_SETUP
#line 84 "scenesetup-scanner.l"
#line 88 "scenesetup-scanner.l"
{ yylval->bval = true; return token::BOOLEAN; }
YY_BREAK
case 12:
case 15:
YY_RULE_SETUP
#line 85 "scenesetup-scanner.l"
#line 89 "scenesetup-scanner.l"
{ yylval->bval = false; return token::BOOLEAN; }
YY_BREAK
/* FLOAT */
case 13:
case 16:
YY_RULE_SETUP
#line 87 "scenesetup-scanner.l"
#line 91 "scenesetup-scanner.l"
{
yylval->fval = (float)std::atof(yytext); return token::F_NUMBER; }
YY_BREAK
/* INT */
case 14:
case 17:
YY_RULE_SETUP
#line 90 "scenesetup-scanner.l"
#line 94 "scenesetup-scanner.l"
{
yylval->ival = std::atoi(yytext); return token::I_NUMBER; }
YY_BREAK
/* STRING */
case 15:
/* rule 15 can match eol */
case 18:
/* rule 18 can match eol */
YY_RULE_SETUP
#line 93 "scenesetup-scanner.l"
#line 97 "scenesetup-scanner.l"
{
yylval->sval = strdup(yytext); return token::STRING; }
YY_BREAK
/* STRING VAR */
case 16:
case 19:
YY_RULE_SETUP
#line 96 "scenesetup-scanner.l"
#line 100 "scenesetup-scanner.l"
{
yylval->svval = strdup(yytext); return token::STRING_VAR; }
YY_BREAK
/* ======= COMMENTS ======= */
case 17:
case 20:
YY_RULE_SETUP
#line 100 "scenesetup-scanner.l"
#line 104 "scenesetup-scanner.l"
{ /* ignore this */ }
YY_BREAK
/* Semantics tokens */
case 18:
case 21:
YY_RULE_SETUP
#line 103 "scenesetup-scanner.l"
#line 107 "scenesetup-scanner.l"
{ return token_type('-'); }
YY_BREAK
case 19:
case 22:
YY_RULE_SETUP
#line 104 "scenesetup-scanner.l"
#line 108 "scenesetup-scanner.l"
{ return token_type('('); }
YY_BREAK
case 20:
case 23:
YY_RULE_SETUP
#line 105 "scenesetup-scanner.l"
#line 109 "scenesetup-scanner.l"
{ return token_type(')'); }
YY_BREAK
case 21:
case 24:
YY_RULE_SETUP
#line 106 "scenesetup-scanner.l"
#line 110 "scenesetup-scanner.l"
{ /* ignore this */ }
YY_BREAK
case 22:
/* rule 22 can match eol */
case 25:
/* rule 25 can match eol */
YY_RULE_SETUP
#line 107 "scenesetup-scanner.l"
#line 111 "scenesetup-scanner.l"
{ /* ignore this */ }
YY_BREAK
case 23:
case 26:
YY_RULE_SETUP
#line 108 "scenesetup-scanner.l"
#line 112 "scenesetup-scanner.l"
{ return token::T_ERROR; }
YY_BREAK
case 24:
case 27:
YY_RULE_SETUP
#line 110 "scenesetup-scanner.l"
#line 114 "scenesetup-scanner.l"
ECHO;
YY_BREAK
#line 860 "generated/scenesetup-scanner.cpp"
#line 883 "generated/scenesetup-scanner.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();

@@ -1238,7 +1261,7 @@ int yyFlexLexer::yy_get_next_buffer()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 87 )
if ( yy_current_state >= 101 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1266,11 +1289,11 @@ int yyFlexLexer::yy_get_next_buffer()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 87 )
if ( yy_current_state >= 101 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 86);
yy_is_jam = (yy_current_state == 100);

return yy_is_jam ? 0 : yy_current_state;
}
@@ -1757,7 +1780,7 @@ void SceneSetupfree (void * ptr )

#define YYTABLES_NAME "yytables"

#line 110 "scenesetup-scanner.l"
#line 114 "scenesetup-scanner.l"





+ 93
- 36
test/meshviewer.cpp View File

@@ -25,12 +25,12 @@ using namespace lol;
static int const TEXTURE_WIDTH = 256;

#define R_M 1.f
#define DEFAULT_WIDTH (770.f * R_M)
#define DEFAULT_HEIGHT (200.f * R_M)
#define DEFAULT_WIDTH (1200.f * R_M)
#define DEFAULT_HEIGHT (400.f * R_M)
#define WIDTH ((float)Video::GetSize().x)
#define HEIGHT ((float)Video::GetSize().y)
#define SCREEN_W (10.f / WIDTH)
#define SCREEN_LIMIT 1.1f
#define SCREEN_LIMIT 1.4f
#define RATIO_HW (HEIGHT / WIDTH)
#define RATIO_WH (WIDTH / HEIGHT)

@@ -111,12 +111,13 @@ enum MVMouseAxisList
#define ALL_FEATURES 1
#define NO_SC_SETUP 0

enum MessageType
enum GizmoType
{
MSG_IN,
MSG_OUT,
GZ_Editor = 0,
GZ_LightPos,
GZ_LightDir,

MSG_MAX
GZ_MAX
};

struct LightData
@@ -147,8 +148,16 @@ public:
m_camera = nullptr;
m_controller = nullptr;

//Compile ref meshes
m_gizmos << new EasyMesh();
m_gizmos.Last()->Compile("[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1]");
m_gizmos << new EasyMesh();
m_gizmos.Last()->Compile("[sc#666 acap 1 .5 .5 ty -.5 sc#fff asph 2 1]");
m_gizmos << new EasyMesh();
m_gizmos.Last()->Compile("[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1 rz 90 ry 90]");

// Mesh Setup
m_render_max = vec2(-.9f, 6.1f);
m_render_max = vec2(-.9f, 4.1f);
m_mesh_id = 0;
m_mesh_id1 = 0.f;
m_default_texture = nullptr;
@@ -282,9 +291,9 @@ public:
m_meshes.Push(em);
}
#else
m_ssetup->Compile(" addlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)"
" addlight 0.0 position (8 2 6) color #ffff");
// " custom setmesh \"sc#fff ab 1\""
m_ssetup->Compile("addlight 0.0 position (4 -1 -4) color (.0 .2 .5 1) "
"addlight 0.0 position (8 2 6) color #ffff "
"showgizmo true ");
m_ssetup->Startup();
#endif //NO_SC_SETUP
for (int i = 0; i < m_ssetup->m_lights.Count(); ++i)
@@ -319,6 +328,12 @@ public:
}
#endif //NO_NACL_EM

//Compute render mesh count
float a_j = lol::abs(m_render_max[1]);
float i_m = m_hist_scale_mesh.x;
float i_trans = a_j - ((a_j * a_j * i_m * i_m + a_j * i_m) * .5f);
m_render_max[1] = a_j * ((RATIO_WH * 1.f) / ((i_trans != 0.f)?(i_trans):(RATIO_WH))) - RATIO_HW * .3f;

//Mesh Change
#if NO_NACL_EM
m_mesh_id = clamp(m_mesh_id + ((int)KeyPressed(KEY_MESH_PREV) - (int)KeyPressed(KEY_MESH_NEXT)), 0, m_meshes.Count() - 1);
@@ -497,7 +512,7 @@ public:
//Message Service
//--
String mesh("");
int u = 4;
int u = 1;
while (u-- > 0 && MessageService::FetchFirst(MessageBucket::AppIn, mesh))
{
int o = 1;
@@ -549,20 +564,24 @@ public:
}

//Check the custom cmd even if we don't have new messages.
for (int i = 0; m_ssetup && i < m_ssetup->m_custom_cmd.Count(); ++i)
int o = 1;
while (o-- > 0)
{
if (m_ssetup->m_custom_cmd[i].m1 == "setmesh")
for (int i = 0; m_ssetup && i < m_ssetup->m_custom_cmd.Count(); ++i)
{
//Create a new mesh
EasyMesh* em = new EasyMesh();
if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C()))
if (m_ssetup->m_custom_cmd[i].m1 == "setmesh")
{
if (m_mesh_id == m_meshes.Count() - 1)
m_mesh_id++;
m_meshes.Push(em);
//Create a new mesh
EasyMesh* em = new EasyMesh();
if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C()))
{
if (m_mesh_id == m_meshes.Count() - 1)
m_mesh_id++;
m_meshes.Push(em);
}
else
delete(em);
}
else
delete(em);
}
}
m_ssetup->m_custom_cmd.Empty();
@@ -643,8 +662,24 @@ public:

g_renderer->SetClearColor(m_ssetup->m_clear_color);

for (int i = 0; i < m_gizmos.Count(); ++i)
{
if (m_gizmos[i]->GetMeshState() == MeshRender::NeedConvert)
m_gizmos[i]->MeshConvert();
else
break;
}

vec3 x = vec3(1.f,0.f,0.f);
vec3 y = vec3(0.f,1.f,0.f);
mat4 save_proj = m_camera->GetProjection();
//Y object Offset
mat4 mat_obj_offset = mat4::translate(x * m_screen_offset.x + y * m_screen_offset.y) *
//Mesh Pos Offset
mat4::translate((x * m_pos_mesh.x * RATIO_HW + y * m_pos_mesh.y) * 2.f * (1.f + .5f * m_zoom_mesh / SCREEN_LIMIT));
//Align right meshes
mat4 mat_align = mat4::translate(x - x * RATIO_HW);
mat4 mat_gizmo = mat_obj_offset * mat_align * save_proj;
for (int i = 0; i < m_meshes.Count(); i++)
{
{
@@ -659,7 +694,6 @@ public:
#endif //WITH_TEXTURE
}
#if ALL_FEATURES
mat4 save_proj = m_camera->GetProjection();
float j = -(float)(m_meshes.Count() - (i + 1)) + (-m_mesh_id1 + (float)(m_meshes.Count() - 1));

if (m_mesh_id1 - m_render_max[0] > (float)i && m_mesh_id1 - m_render_max[1] < (float)i &&
@@ -668,19 +702,14 @@ public:
float a_j = lol::abs(j);
float i_trans = (a_j * a_j * m_hist_scale_mesh.x + a_j * m_hist_scale_mesh.x) * .5f;
float i_scale = clamp(1.f - (m_hist_scale_mesh.y * (m_mesh_id1 - (float)i)), 0.f, 1.f);
mat4 new_proj =
//Y object Offset
mat4::translate(x * m_screen_offset.x + y * m_screen_offset.y) *
//Mesh Pos Offset
mat4::translate((x * m_pos_mesh.x * RATIO_HW + y * m_pos_mesh.y) * 2.f * (1.f + .5f * m_zoom_mesh / SCREEN_LIMIT)) *
//Mesh count offset
mat4::translate(x * RATIO_HW * 2.f * (j + i_trans)) *
//Align right meshes
mat4::translate(x - x * RATIO_HW) *
//Mesh count scale
mat4::scale(vec3(vec2(i_scale), 1.f)) *
//Camera projection
save_proj;

//Mesh count offset
mat4 mat_count_offset = mat4::translate(x * RATIO_HW * 2.f * (j + i_trans));
//Mesh count scale
mat4 mat_count_scale = mat4::scale(vec3(vec2(i_scale), 1.f));

//Camera projection
mat4 new_proj = mat_obj_offset * mat_count_offset * mat_align * mat_count_scale * save_proj;
m_camera->SetProjection(new_proj);
//#if NO_NACL_EM
m_meshes[i]->Render(m_mat);
@@ -693,6 +722,33 @@ public:
#endif //ALL_FEATURES
}
}
if (m_ssetup)
{
m_camera->SetProjection(mat_gizmo);
if (m_ssetup->m_show_gizmo)
m_gizmos[GZ_Editor]->Render(m_mat);

if (m_ssetup->m_show_lights)
{
for (int k = 0; k < m_ssetup->m_lights.Count(); ++k)
{
Light* tmp = m_ssetup->m_lights[k];
mat4 world = mat4::translate(tmp->GetPosition().xyz);
mat4 local = mat4::translate((inverse(m_mat) * world).v3.xyz);
//dir light
if (tmp->GetPosition().w == 0.f)
{
m_gizmos[GZ_LightPos]->Render(m_mat * inverse(local));
m_gizmos[GZ_LightDir]->Render(inverse(world) * inverse(mat4::lookat(vec3::zero, -tmp->GetPosition().xyz, vec3::axis_y)));
}
else //point light
{
m_gizmos[GZ_LightPos]->Render(m_mat * local);
}
}
}
m_camera->SetProjection(save_proj);
}
}

private:
@@ -730,6 +786,7 @@ private:
int m_mesh_id;
float m_mesh_id1;
Array<EasyMesh*> m_meshes;
Array<EasyMesh*> m_gizmos;

//File data
String m_file_name;


+ 1
- 1
test/meshviewer.index.html View File

@@ -110,7 +110,7 @@ progress::-webkit-progress-value

g_code_id = 0;
g_code_base[0] = "//This is a comment\nsc#f8f afcb 1 1 1 0";
g_code_base[1] = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff";
g_code_base[1] = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff\nshowgizmo true\nshowlight true";
function machinchose() { return 'test machin '; }
function GetTextAreaCodeSrc() { return g_txtarea_code_src; }


+ 9
- 1
test/scenesetup-parser.y View File

@@ -47,6 +47,7 @@
%token T_COLOR

%token T_ADDLIGHT T_OBJPOSITION T_OBJLOOKAT T_OBJCOLOR T_CLEARCOLOR
%token T_SHOWGIZMO T_SHOWLIGHT
%token T_CUSTOMCMD

%token T_END 0
@@ -107,6 +108,7 @@ sstp_command_list:
sstp_command:
light_command
| setup_command
| scene_command
| custom_command
;

@@ -128,9 +130,15 @@ setup_command:
vec4 vv = vec4(v) * (1.f / 255.f);
if (uc.m_last_cmd == "ADDLIGHT")
uc.m_sstp.m_lights.Last()->SetColor(vv); }
| T_CLEARCOLOR v4 { uc.m_sstp.m_clear_color = vec4($2[0], $2[1], $2[2], $2[3]); }
;

scene_command:
T_CLEARCOLOR v4 { uc.m_sstp.m_clear_color = vec4($2[0], $2[1], $2[2], $2[3]); }
T_CLEARCOLOR v3 { uc.m_sstp.m_clear_color = vec4($2[0], $2[1], $2[2], 1.f); }
| T_CLEARCOLOR COLOR { uint32_t x = $2; ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
uc.m_sstp.m_clear_color = vec4(v) * (1.f / 255.f); }
| T_SHOWGIZMO bv { uc.m_sstp.m_show_gizmo = $2; }
| T_SHOWLIGHT bv { uc.m_sstp.m_show_lights = $2; }
;

custom_command:


+ 4
- 0
test/scenesetup-scanner.l View File

@@ -53,6 +53,10 @@ lookat { return token::T_OBJLOOKAT; }
color { return token::T_OBJCOLOR; }
clearcolor { return token::T_CLEARCOLOR; }

showgizmo { return token::T_SHOWGIZMO; }
showlight { return token::T_SHOWLIGHT; }
custom { return token::T_CUSTOMCMD; }

custom { return token::T_CUSTOMCMD; }

%{ /* ======= BASE COLOR TYPES ========================================= */ %}


+ 2
- 0
test/scenesetup.cpp View File

@@ -25,6 +25,8 @@ namespace lol
SceneSetup::SceneSetup()
{
m_clear_color = vec4(vec3::zero, 1.f);
m_show_gizmo = true;
m_show_lights = true;
}

//----


+ 2
- 0
test/scenesetup.h View File

@@ -42,6 +42,8 @@ public:
vec4 m_clear_color;
Array<Light *> m_lights;
Array<String, String> m_custom_cmd;
bool m_show_gizmo;
bool m_show_lights;
};

} /* namespace lol */


+ 2
- 0
test/scenesetupdictionnary.js View File

@@ -16,4 +16,6 @@ CmdType(["addlight"], "Add a light to the scene.\nUse other commands after thi
CmdType(["position"], "Set a position.\nWhen put after a light, sets its position.", [CmdArg("vec3", "pos")]);
CmdType(["color"], "Set a color.", [CmdArg("color", "color")]);
CmdType(["clearcolor"], "Sets the color used for screen clearing.", [CmdArg("color", "color")]);
CmdType(["showgizmo"], "If true, show the axis gizmo.", [CmdArg("bool", "show")]);
CmdType(["showlight"], "If true, show the light locations.", [CmdArg("bool", "show")]);


Loading…
Cancel
Save