I have been assigned to write a compiler for Basic programming language. In basic, codes are separated with new lines or by :
mark. e.g to following to codes are valid.
Model# 1
10 PRINT "Hello World 1" : PRINT "Hello World 2"
Model# 2
10 PRINT "Hello World 1"
20 PRINT "Hello World 2"
You can test those here.
The First thing i need to do, before parsing codes in my compiler is to split codes.
I have already splited codes in lines but i am stucked with finding a regex to split The following code sample:
This following code sample should be splited in 2 PRINT
codes.
10 PRINT "Hello World 1" : PRINT "Hello World 2"
But DO NOT match this:
The following code sample is a single standalone command.
10 PRINT "Hello World 1" ": PRINT Hello World 2"
Question
Any regex pattern to DO match the first of above code samples which :
is outside of pair of "
and DO NOT match the second one?
Can anybody help me out here?
Any thing would help. :)