Skip to content

Commit

Permalink
Merge pull request #3475 from masatake/rake--symbol-defined-with-quot…
Browse files Browse the repository at this point in the history
…e-chars

Rake: accept symbols defined with single and double quote characters
  • Loading branch information
masatake authored Sep 4, 2022
2 parents 096dc1c + 57a52a7 commit 934f60e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Units/parser-rake.r/xtasks.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ verify_private_key_present input.rake /^task :verify_private_key_present do$/;"
build input.rake /^task :build => :verify_private_key_present$/;" task
default input-0.rake /^task :default => :test$/;" task
test input-0.rake /^Rake::TestTask.new 'test' do |t|$/;" xtask typeref:typename:Rake::TestTask.new
spec:rcovSingle input-1.rake /^RSpec::Core::RakeTask.new(:'spec:rcovSingle') do |t|$/;" xtask typeref:typename:RSpec::Core::RakeTask.new
spec:rcovDouble input-1.rake /^RSpec::Core::RakeTask.new(:"spec:rcovDouble") do |t|$/;" xtask typeref:typename:RSpec::Core::RakeTask.new
19 changes: 19 additions & 0 deletions Units/parser-rake.r/xtasks.d/input-1.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://raw.githubusercontent.com/apache/thrift/master/lib/rb/Rakefile
RSpec::Core::RakeTask.new(:'spec:rcovSingle') do |t|
t.rspec_opts = ['--color', '--format d']
t.rcov = true
t.rcov_opts = ['--exclude', '^spec,/gems/']
end

RSpec::Core::RakeTask.new(:"spec:rcovDouble") do |t|
t.rspec_opts = ['--color', '--format d']
t.rcov = true
t.rcov_opts = ['--exclude', '^spec,/gems/']
end

# The next one may be extracted.
RSpec::Core::RakeTask.new(:) do |t|
t.rspec_opts = ['--color', '--format d']
t.rcov = true
t.rcov_opts = ['--exclude', '^spec,/gems/']
end
8 changes: 5 additions & 3 deletions parsers/rake.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static vString *readTask (const unsigned char **cp, bool *variable)
}
break;
case ':':
++*cp;
vstr = vStringNew ();
if (!rubyParseMethodName (cp, vstr))
{
Expand Down Expand Up @@ -184,8 +183,11 @@ static int parseXTask (rubySubparser *s, struct taskType *xtask, const unsigned
int r = makeSimpleRakeTag (vstr, xtask->kind, s, variable);
vStringDelete (vstr);
tagEntryInfo *e = getEntryInCorkQueue (r);
e->extensionFields.typeRef [0] = eStrdup ("typename");
e->extensionFields.typeRef [1] = eStrdup (xtask->keyword);
if (e)
{
e->extensionFields.typeRef [0] = eStrdup ("typename");
e->extensionFields.typeRef [1] = eStrdup (xtask->keyword);
}
return r;
}
}
Expand Down
27 changes: 15 additions & 12 deletions parsers/ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,18 +463,23 @@ static rubyKind parseIdentifier (
}

/* Copy the identifier into 'name'. */
if (**cp == ':' && (*((*cp) + 1) == '"' || *((*cp) + 1) == '\''))
if (**cp == ':')
{
/* The symbol is defined with string literal like:
----
:"[]"
:"[]="
----
*/
unsigned char b = *(++*cp);
if (*((*cp) + 1) == '"' || *((*cp) + 1) == '\'')
{
/* The symbol is defined with string literal like:
----
:"[]"
:"[]="
----
*/
unsigned char b = *(++*cp);
++*cp;
parseString (cp, b, name);
return kind;
}
/* May be symbol like :name. Skip the first character. */
++*cp;
parseString (cp, b, name);
return kind;
}

while (**cp != 0 && (**cp == ':' || isIdentChar (**cp) || charIsIn (**cp, also_ok)))
Expand Down Expand Up @@ -810,7 +815,6 @@ static void readAttrsAndEmitTags (const unsigned char **cp, bool reader, bool wr
skipWhitespace (cp);
if (**cp == ':')
{
++*cp;
if (K_METHOD == parseIdentifier (cp, a, K_METHOD))
{
emitRubyAccessorTags (a, reader, writer);
Expand Down Expand Up @@ -854,7 +858,6 @@ static int readAliasMethodAndEmitTags (const unsigned char **cp)
skipWhitespace (cp);
if (**cp == ':')
{
++*cp;
if (K_METHOD != parseIdentifier (cp, a, K_METHOD))
vStringClear (a);
}
Expand Down

0 comments on commit 934f60e

Please sign in to comment.