aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-16 08:42:48 +1000
committerDavid Walter Seikel2012-01-16 08:42:48 +1000
commit10c298df37f430b4c7914448fb43a05bbec6302f (patch)
treed44541ffaf5ad55be53cd06a0d226057c07cc426 /LuaSL
parentParser now parses a real script to completion with no syntax errors! B-) (diff)
downloadSledjHamr-10c298df37f430b4c7914448fb43a05bbec6302f.zip
SledjHamr-10c298df37f430b4c7914448fb43a05bbec6302f.tar.gz
SledjHamr-10c298df37f430b4c7914448fb43a05bbec6302f.tar.bz2
SledjHamr-10c298df37f430b4c7914448fb43a05bbec6302f.tar.xz
yylineno does not track colums, so do it myself.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.c3
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h1
-rw-r--r--LuaSL/src/LuaSL_lexer.l19
3 files changed, 20 insertions, 3 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c
index 0f9013a..b1bbaa7 100644
--- a/LuaSL/src/LuaSL_LSL_tree.c
+++ b/LuaSL/src/LuaSL_LSL_tree.c
@@ -761,6 +761,9 @@ static int nextFile(LuaSL_yyparseParam *param)
761 burnLeaf(param->ast); 761 burnLeaf(param->ast);
762 param->ast = NULL; 762 param->ast = NULL;
763 param->lval = calloc(1, sizeof(LSL_Leaf)); 763 param->lval = calloc(1, sizeof(LSL_Leaf));
764 // Text editors usually start counting at 1, even programmers editors.
765 param->column = 1;
766 param->line = 1;
764 return TRUE; 767 return TRUE;
765 } 768 }
766/* 769/*
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 1429393..b547976 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -276,6 +276,7 @@ typedef struct
276 LSL_Leaf *ast; 276 LSL_Leaf *ast;
277 char *ignorableText; 277 char *ignorableText;
278 LSL_Leaf *lval; 278 LSL_Leaf *lval;
279 int column, line;
279} LuaSL_yyparseParam; 280} LuaSL_yyparseParam;
280 281
281 282
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l
index c805659..afc99ce 100644
--- a/LuaSL/src/LuaSL_lexer.l
+++ b/LuaSL/src/LuaSL_lexer.l
@@ -8,7 +8,7 @@ int common(YYSTYPE *lval, char *text, LuaSL_yyparseParam *param, boolean checkIg
8%} 8%}
9 9
10%option reentrant never-interactive batch 10%option reentrant never-interactive batch
11%option bison-bridge yylineno 8bit 11%option bison-bridge 8bit
12%option noreject noyymore 12%option noreject noyymore
13%option backup debug perf-report perf-report verbose warn 13%option backup debug perf-report perf-report verbose warn
14%option align full 14%option align full
@@ -115,9 +115,22 @@ STRING \"(\\.|[^\\"\n])*\"
115 115
116int common(YYSTYPE *lval, char *text, LuaSL_yyparseParam *param, boolean checkIgnorable, int type) 116int common(YYSTYPE *lval, char *text, LuaSL_yyparseParam *param, boolean checkIgnorable, int type)
117{ 117{
118 char *p;
119
120 for (p = text; *p; p++)
121 {
122 if ('\n' == *p)
123 {
124 param->line++;
125 param->column = 1;
126 }
127 else
128 param->column++;
129 }
130
118 lval->token = tokens[type - lowestToken]; 131 lval->token = tokens[type - lowestToken];
119 lval->line = yyget_lineno(param->scanner); 132 lval->line = param->line;
120 lval->column = yyget_column(param->scanner); 133 lval->column = param->column;
121 134
122 if (checkIgnorable) 135 if (checkIgnorable)
123 { 136 {