Wiki

Ticket #166 (closed defect: worksforme)

Opened 15 years ago

Last modified 15 years ago

LexerError when nesting single quotes in Strings

Reported by: webnov8 Owned by:
Priority: critical Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

The compilation error: "error: Expecting COMMA, but got "'" (SINGLE_QUOTE) instead." is raised when using escaped single-quoted characters.

For example:

print '\''

Current workaround is to use a temp variable containing the single quote, like:

single = c'\''
print '[single]'

Attachments

ticket166.patch Download (2.6 KB) - added by webnov8 15 years ago.

Change History

Changed 15 years ago by eric.sellon

This is an interesting issue, but I'll give you an easier workaround:

print "\'"

The same sort of problem happens with:

print "\""

So as long as you don't need both quote marks within the same string, you should be okay. Obviously this problem needs to be fixed, but I thought you'd like to know about an easier workaround (at least it is in my opinion).

Changed 15 years ago by Chuck

yeah i think you can also go double-single-double as in:

print "'"
}}
I just meant that other workaround for the general case where you do have a messier string, but thanks.

Changed 15 years ago by Chuck

For reference, here is a regex for Python string lits:

 http://code.activestate.com/recipes/475109/

Changed 15 years ago by webnov8

  • status changed from new to closed
  • resolution set to worksforme

I have put together a patch with some tests for this problem.

Changed 15 years ago by webnov8

Note: See TracTickets for help on using tickets.