Compiler/Simple file inclusion pre processor: Difference between revisions

(→‎{{header|Phix}}: marked incorrect, the penny has just dropped...)
Line 233:
result
END # get string # ;
# getsreturns s unquoted a string denotation from the source without the quotes #
PROC get unquotedunquote string = ( STRING s )STRING:
BEGIN
STRING result := "";
# within a string denotation, "" denotes the " character #
WHILEINT havec stringpos delimiter:= DOLWB s + 1;
WHILE cpos < UPB WHILE nexts char;DO
CHAR ch = s[ c pos NOT at eof AND NOT have string delimiter];
DOIF ch = """" THEN
result# +:=have can embedded quote - it will be doubled #
OD; c pos +:= 1
IF NOT have string delimiter THEN
# unterminated string #
unterminated( "string" )
FI;
nextresult char+:= ch;
IFc havepos string delimiter+:= THEN1
# embedded string delimiter #
result +:= c
FI
OD;
result
END # get unquotedunquote string # ;
# gets a bold word from then source #
PROC get bold word = STRING:
Line 297 ⟶ 291:
IF at eof THEN
# unterminated commant #
unterminated( """'" + delimiter + """' comment" )
FI;
put string( delimiter )
Line 318 ⟶ 312:
IF have string delimiter THEN
# have a file name #
file name := get unquoted string;
pragment +:= file name + get whitespace;
file name := unquote string( file name )
FI;
# should now have the closing delimiter #
IF NOT have bold THEN
# no bold word in/at-the-nd-of the pragment #
bold word result +:= c""
ELSE
# have a bold word - could be the delimiter #
pragment +:= ( bold word := get bold word )
Line 332 ⟶ 330:
# not a read/include pragmatic comment #
put string( pragment );
WHILEIF bold word :/= skipdelimiter to bold;THEN
# haven't NOTgot atthe eofclosing delimiter yet #
AND WHILE bold word /:= delimiterskip to bold;
DO SKIP OD; NOT at eof
IF at eof THEN AND bold word /= delimiter
#DO unterminatedSKIP commant #OD;
unterminated(IF """"at +eof delimiter + """ pragmatic comment" )THEN
FI; # unterminated commant #
put string unterminated( """" + delimiter )
unterminated( "string" )FI;
IF NOT have put string( delimiter THEN)
FI
ELIF
# attempt to include the file #
3,043

edits