2022-07-25 14:34:33 +00:00
|
|
|
// Includes are at the start of the file, before any other code.
|
|
|
|
// There might be some comments before or between the includes.
|
|
|
|
// #include "string"
|
|
|
|
// #include "string2"
|
|
|
|
|
|
|
|
start
|
2022-08-23 09:47:24 +00:00
|
|
|
= (newLine/_/comment/delimitedComment)* @includes newLine* ignore
|
2022-07-25 14:34:33 +00:00
|
|
|
|
|
|
|
includes
|
|
|
|
= head:includeStatement tail:(newLine+ @includeStatement)*
|
|
|
|
{return [head, ...tail].filter( e => e != '');}
|
|
|
|
/ ignore
|
|
|
|
{return [];}
|
|
|
|
|
|
|
|
includeStatement
|
2022-08-23 09:47:24 +00:00
|
|
|
= _* '#include' _* @string _*
|
2022-07-25 14:34:33 +00:00
|
|
|
/ comment
|
|
|
|
/ delimitedComment
|
|
|
|
|
|
|
|
string 'string'
|
|
|
|
= characters:("'" @([^'])* "'") {return characters.join('');}
|
|
|
|
/ characters:('"' @([^"])* '"') {return characters.join('');}
|
|
|
|
|
|
|
|
ignore = (any / newLine / _)*
|
|
|
|
|
|
|
|
comment
|
|
|
|
= '//'any*
|
|
|
|
{ return '';}
|
|
|
|
|
|
|
|
delimitedComment
|
|
|
|
= '/*' ([^*]*) '*/'
|
|
|
|
{ return '';}
|
|
|
|
|
|
|
|
_ "white space"
|
|
|
|
= [ \t]
|
|
|
|
|
|
|
|
newLine "newline"
|
|
|
|
= [\n\r]
|
|
|
|
|
|
|
|
any = [^\r\n]
|