Skip to content

Commit

Permalink
Support all excapes in char / string literals both in indent and syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
nddrylliog committed Dec 4, 2013
1 parent 0ee080d commit d05245d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 34 deletions.
4 changes: 2 additions & 2 deletions indent/ooc.vim
Expand Up @@ -93,10 +93,10 @@ function! GetStrippedLine(lnum)
let line = getline(a:lnum)

" get rid of strings
let line = substitute(line, '"\(\\"\|[^"]\)*"', '', 'g')
let line = substitute(line, '"\(\\[\"]\|[^"]\)*"', '', 'g')

" get rid of char literals
let line = substitute(line, "'\\(\\\\'\\|[^']\\)\\{-}'", '', 'g')
let line = substitute(line, "'\\(\\\\[\\']\\|[^']\\)\\{-}'", '', 'g')

" get rid of single-line comments
let line = substitute(line, '//.*$', '', 'g')
Expand Down
7 changes: 7 additions & 0 deletions spec/samples/char_escape.ooc
Expand Up @@ -3,7 +3,14 @@ yes(
a,
expr ? (':' + expr()) ':',
expr ? ('\'' + expr()) '\'',
expr ? ('\\' + expr()) '\\',
expr ? ('\n' + expr()) '\n',
expr ? ('\013' + expr()) '\013',
expr ? ('\x13' + expr()) '\x13',
expr ? ('\u1230' + expr()) '\u1230',
// invalid, but should still not fuck up
expr ? ('' + expr()) '',
expr ? ('\018' + expr()) '\018',
expr ? ('\xeg' + expr()) '\0eg',
c
)
7 changes: 7 additions & 0 deletions spec/samples/char_escape.ooc.ref
Expand Up @@ -3,7 +3,14 @@ yes(
a,
expr ? (':' + expr()) ':',
expr ? ('\'' + expr()) '\'',
expr ? ('\\' + expr()) '\\',
expr ? ('\n' + expr()) '\n',
expr ? ('\013' + expr()) '\013',
expr ? ('\x13' + expr()) '\x13',
expr ? ('\u1230' + expr()) '\u1230',
// invalid, but should still not fuck up
expr ? ('' + expr()) '',
expr ? ('\018' + expr()) '\018',
expr ? ('\xeg' + expr()) '\0eg',
c
)
16 changes: 16 additions & 0 deletions spec/samples/string_escape.ooc
@@ -0,0 +1,16 @@
// don't remove me
yes(
a,
expr ? (":" + expr()) ":",
expr ? ("\"" + expr()) "\"",
expr ? ("\\" + expr()) "\\",
expr ? ("\n" + expr()) "\n",
expr ? ("\a" + expr()) "\a",
expr ? ("\013456" + expr()) "\013456",
expr ? ("\x13adf" + expr()) "\x13adf",
expr ? ("\u13adf" + expr()) "\u13adf",
expr ? ("" + expr()) "",
expr ? ("\018" + expr()) "\018",
expr ? ("\xeg" + expr()) "\0eg",
c
)
16 changes: 16 additions & 0 deletions spec/samples/string_escape.ooc.ref
@@ -0,0 +1,16 @@
// don't remove me
yes(
a,
expr ? (":" + expr()) ":",
expr ? ("\"" + expr()) "\"",
expr ? ("\\" + expr()) "\\",
expr ? ("\n" + expr()) "\n",
expr ? ("\a" + expr()) "\a",
expr ? ("\013456" + expr()) "\013456",
expr ? ("\x13adf" + expr()) "\x13adf",
expr ? ("\u13adf" + expr()) "\u13adf",
expr ? ("" + expr()) "",
expr ? ("\018" + expr()) "\018",
expr ? ("\xeg" + expr()) "\0eg",
c
)
6 changes: 0 additions & 6 deletions spec/samples/string_escapes.ooc

This file was deleted.

6 changes: 0 additions & 6 deletions spec/samples/string_escapes.ooc.ref

This file was deleted.

9 changes: 0 additions & 9 deletions spec/samples/tostring.ooc

This file was deleted.

9 changes: 0 additions & 9 deletions spec/samples/tostring.ooc.ref

This file was deleted.

4 changes: 2 additions & 2 deletions syntax/ooc.vim
Expand Up @@ -46,10 +46,10 @@ syn match oocNoInterpolation "\\#{" display contained
syn match oocNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained
syn match oocNoInterpolation "\\#\$\W" display contained

syn match oocEscapedChar display contained "\\\([\\\"\'nrbtf]\|[0-9]\{1,3}\|u[0-9]\{1,4}\)"
syn match oocEscapedChar display contained "\\\([\\\"\'anrbtfv]\|\o\{1,3}\|x\x\{1,2}\|u\x\{1,4}\)"
syn region oocString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=oocEscapedChar,oocInterpolation,oocNoInterpolation,@Spell

syn match oocCharacter "L\='[^\\]'"
syn match oocCharacter "L\='\(\\['anrbtfv\\]\|\\\o\{1,3}\|\\x\x\{1,2}\|\\u\x\{1,4}\|[^\\]\)'" contains=oocEscapedChar
syn match oocCharacter "L'[^']*'" contains=oocEscapedChar

syn keyword oocTodo TODO FIXME
Expand Down

0 comments on commit d05245d

Please sign in to comment.