Writing C Parser

So, I had started working on C parser. But, I have had some issues compiling C source code. Following is the screenshot of error.

Image

 

 

I researched a lot to figure out the possible reason of the failure (problem linking libraries, trying -m32 to change compilation environment) but none of them seemed to work. So, I started working on my Windows machine rather than wasting a lot of time on fixing this.

The code I was working on for the majority of the time was the cue payload (text). It essentially covers one of the major portion of the parser code. So, I will be blogging about cue text. If anything else, I think, should be included in the blogs, I will blog about it. To start with, Kyle spec was a big help. It is very readable and understandable. Parsing cue text includes you deal with a couple of things. One is the escape characters and the another is text tags. According to the spec, cue text may have newlines but not a blank line. As pointed by Kyle, one way to overcome this is by inserting a space in between two new line characters. This will let you have a blank line within cue text. In cue text, you cannot have an ‘&’ sign and ‘<‘ sign. Here is a table of escape sequence for special characters taken from Kyle’s blog.

Escape sequences

Name Character Escape Sequence
Ampersand & &amp;
Less-than < &lt;
Greater-than > &gt;
Left-to-right mark   &lrm;
Right-to-left mark   &rlm;
Non-breaking space    &nbsp;

Another thing you have to deal with in cue text is the ‘Text Tags’. You can have a timestamp tag within the cue text provided the time is greater than the start time of the cue and less than the end time of the cue. Other text tags you can have in the cue text are common class tags, italics tags, underline tags, ruby tags, ruby text tags, and voice tags.

This is the berief explanation of what I am working on and that it will be implemented in the parser. I will post one more blog post when I am done with it. A little trouble I had working on the C parser was that it had been quite long since I had studied or used C language. So, I didn’t quite remember the data types and the syntax of C although it is very simple.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s