lava-oushudb-dt-sql-parser/peg/comment.pegjs

72 lines
1.0 KiB
Plaintext
Raw Normal View History

2018-07-05 11:16:30 +08:00
start
= union_stmt:union_stmt
{
return union_stmt;
}
union_stmt
=stmt:
(
words:(!kw_start word:. {return word})*
stmt:(comment:comment {return ''}/quote:quote {return quote})
{return words.join("")+stmt}
)* other:.*
{return stmt.join("")+other.join("")}
comment
=comment:(multiLine/singleLine)
{
return comment;
}
singleLine
= start:KW_SINGLE_LINE_START
words:[^\r\n]*
{
return start+words.join("")
}
multiLine
=start:KW_MULTI_LINE_START
words:(!"*/" word:. {return word })*
end:KW_MULTI_LINE_END
{return start+words.join("")+end }
quote
=content:(
(
start:"\""
words:[^"]*
end:"\""
{return start+words.join("")+end;}
)
/
(
start:"'"
words:[^']*
end:"'"
{return start+words.join("")+end;}
)
)
kw_start=KW_SINGLE_LINE_START/KW_MULTI_LINE_START/"\""/"'"
KW_SINGLE_LINE_START = "--";
KW_SINGLE_LINE_END = [\r\n];
KW_MULTI_LINE_START = "/*";
KW_MULTI_LINE_END = "*/";
__ = whitespace*
whitespace
= [ \t\r\n];