Author: pmichaud
Date: Mon Jan 8 15:58:26 2007
New Revision: 16509
Modified:
trunk/compilers/tge/TGE/Compiler.pir
trunk/compilers/tge/tgc.pir
Log:
[TGE]:
* Resolve RT #39905: [TODO] TGE - line number reporting.
* TGE now reports PIR errors against original .tg location; i.e.,
error:imcc: <message> in file 'src/PASTGrammar.tg' line 124
instead of
error:imcc: <message> in file 'src/PASTGrammar_gen.pir' line 152
* Thanks to jonathan++ for RT#40806 patch that enables this to work.
Modified: trunk/compilers/tge/TGE/Compiler.pir
==============================================================================
--- trunk/compilers/tge/TGE/Compiler.pir (original)
+++ trunk/compilers/tge/TGE/Compiler.pir Mon Jan 8 15:58:26 2007
@@ -238,11 +238,14 @@
.sub action_value :method
.param pmc tree
.param pmc node
- .local pmc value
- value = new .String
+ .local pmc value, infile
+ .local int lineno
+ value = new 'PGE::CodeString'
+ infile = get_global '$!infile'
$P2 = node[0]
- $S1 = $P2
- value = $S1
+ (lineno) = $P2.'line_number'()
+ value.'emit'('#line %0 "%1"', lineno, infile)
+ value .= $P2
.return (value)
.end
@@ -268,10 +271,13 @@
.sub 'precompile' :method
.param string source
+ .param pmc infile
.local pmc rule_data
.local string outstring
.local string header_string
+ set_global '$!infile', infile
+
# Unnamed grammars are class 'AnonGrammar'
.local string grammarname
grammarname = 'AnonGrammar'
Modified: trunk/compilers/tge/tgc.pir
==============================================================================
--- trunk/compilers/tge/tgc.pir (original)
+++ trunk/compilers/tge/tgc.pir Mon Jan 8 15:58:26 2007
@@ -84,7 +84,7 @@
grammar = new 'TGE::Compiler'
.local string compiled_source
- compiled_source = grammar.'precompile'(source)
+ compiled_source = grammar.'precompile'(source, infile)
print outfh, compiled_source
goto END