Skip to content

Commit

Permalink
Objective C: Improved string token (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Dec 7, 2021
1 parent afd77ed commit 8e0e95f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion components/prism-objectivec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Prism.languages.objectivec = Prism.languages.extend('c', {
'string': /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|@"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
'string': {
pattern: /@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
greedy: true
},
'keyword': /\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,
'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/
});
Expand Down
2 changes: 1 addition & 1 deletion components/prism-objectivec.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions tests/languages/objectivec/char_feature.test
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
''
'fo\'o'
'foo\
bar'
'a'
'\n'
'\000'
'\x00'
'\u0000'

----------------------------------------------------

[
["char", "''"],
["char", "'fo\\'o'"],
["char", "'foo\\\r\nbar'"]
["char", "'a'"],
["char", "'\\n'"],
["char", "'\\000'"],
["char", "'\\x00'"],
["char", "'\\u0000'"]
]

0 comments on commit 8e0e95f

Please sign in to comment.