GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [swift] Manage swift5 string literals by kenji21 · Pull Request #2666 · pmd/pmd

Conversation

@kenji21

@kenji21 kenji21 commented Jul 27, 2020 •
edited by oowekyala
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Describe the PR

Previous PR on Swift 5 (#2475) support missed string literals like explained in this article:

https://www.swiftbysundell.com/articles/string-literals-in-swift/

Related issues

none

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kenji21
Manage swift5 string literals
4a6bc93
oowekyala
oowekyala reviewed Jul 27, 2020
View reviewed changes

@oowekyala oowekyala left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pr!

This is missing a few things, I mean it only implements a small subset of the possible string literals. For example, Switft 5 also defines multiline raw strings:

#"""
  ooo
"""#

Cf the swift reference

Do you want to work on this too?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-swift/src/test/resources/net/sourceforge/pmd/lang/swift/cpd/testdata/Swift5.0.txt
[}] 5 5
L48
[}] 1 1
L49

@oowekyala oowekyala Jul 27, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this line has no counterpart in the source file. Maybe this was forgotten?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-swift/src/main/antlr4/net/sourceforge/pmd/lang/swift/antlr4/Swift.g4

DashedSingleStringLiteral : '#"' DashedMultiQuotedText? '"#' ;
fragment DashedMultiQuotedText : DashedMultiQuotedTextItem+ ;
fragment DashedMultiQuotedTextItem : EscapedCharacter | DashedMultiInterpolatedString

@oowekyala oowekyala Jul 27, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure EscapedCharacter should be here. Apparently those dashed string literals are raw strings, so the only escape being processed is \#(..) I guess

Looking at this, it looks like MultiQuotedTextItem (just above) is missing EscapedCharacter too...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-swift/src/main/antlr4/net/sourceforge/pmd/lang/swift/antlr4/Swift.g4
;
fragment MultiInterpolatedString: '\\(' (MultiQuotedTextItem | SingleStringLiteral)* ')';

DashedSingleStringLiteral : '#"' DashedMultiQuotedText? '"#' ;

@oowekyala oowekyala Jul 27, 2020

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One may use an arbitrary number of # delimiters provided they're balanced, eg ##"..."##

This link may be a good starting point to implement this

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@oowekyala oowekyala changed the title Manage swift5 string literals [swift] Manage swift5 string literals Jul 27, 2020
@oowekyala oowekyala added this to the 6.31.0 milestone Dec 11, 2020
@oowekyala oowekyala self-assigned this Dec 11, 2020
@oowekyala oowekyala added the in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception label Jan 18, 2021
oowekyala added a commit that referenced this pull request Jan 18, 2021
@oowekyala
Fixups for #2666
7e9f176
Support full swift 5 string grammar

- arbitrary balanced delimiters
- raw strings ignore escapes
- multiline raw strings

Also rename lexer rules, 'dashed' is not adapted
oowekyala added a commit that referenced this pull request Jan 18, 2021
@oowekyala
Update release notes, refs #2666
e42fa18
oowekyala added a commit that referenced this pull request Jan 18, 2021
@oowekyala
Merge branch 'pr/2666'
6eb36fd
Refs #2666
@oowekyala
oowekyala merged commit b18c73d into pmd:master Jan 18, 2021
@oowekyala oowekyala mentioned this pull request May 27, 2021
[swift] Parsing errors encountered with emoji #2698
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@oowekyala oowekyala oowekyala left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@oowekyala oowekyala

Labels

in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception

Projects

None yet

Milestone

6.31.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kenji21 @oowekyala
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.