diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-06-28 14:20:35 +0200 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-07-10 10:57:38 +1000 |
commit | 911b490f2288f81b36d484b40dd3d875320cf624 (patch) | |
tree | 9ea9fb81b0986688fa507e26aeb7451720fd6d15 /spec/integration/util/autoload.rb | |
parent | faefd92c78f69580204c40179f3f0b766b0208fb (diff) | |
download | puppet-911b490f2288f81b36d484b40dd3d875320cf624.tar.gz puppet-911b490f2288f81b36d484b40dd3d875320cf624.tar.xz puppet-911b490f2288f81b36d484b40dd3d875320cf624.zip |
Fix #2364 - Associates the correct comment to the right statement
Due to the problem that we associate documentation in the lexer and
not in the parser (which would be to complex and unmaintenable to
do), and since the parser reads new tokens before reducing
the current statement (thus creating the AST node), we could
sometimes associate comments seen after a statement associated
to this one.
Ex:
1. $foo = 1
2. # doc of next class
3. class test {
When we parse the first line, the parser can reduce this to the
correct VarDef only after it lexed the CLASS token.
But lexing this token means we already pushed on the comment stack
the "doc of next class" comment.
That means at the time we create the AST VarDef node, the parser thinks
it should associate this documentation to it, which is incorrect.
As soon as the parser uses token line number, we can enhance the lexer
to allow comments to be associated to current AST node only if
the statement line number is greater or equal than the last comment
line number.
This way it is impossible to associate a comment appearing later in the
source than a previous statement.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/integration/util/autoload.rb')
0 files changed, 0 insertions, 0 deletions