From 9de9ac16960a1ac2c0ab967013f2ec6847b7bc21 Mon Sep 17 00:00:00 2001 From: Nagi5Yeq Date: Sun, 31 May 2020 20:51:34 +0800 Subject: commet support --- .gitignore | 1 + Lexer.l | 6 ++++++ t/trivial.pas | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d902acc..1304f0a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ out Parser.cc Lexer.cc Parser.hh +*.ll diff --git a/Lexer.l b/Lexer.l index e69ddb0..f2fdc9a 100644 --- a/Lexer.l +++ b/Lexer.l @@ -50,6 +50,10 @@ identifier [a-z_][0-9a-z_]* white [\t\f\r ] +comment1 \{((.|[\n\r])*?)\} +comment2 \(\*((.|[\n\r])*?)\*\) +comment {comment1}|{comment2} + %{ #define YY_USER_ACTION loc.columns(yyleng); %} @@ -169,6 +173,8 @@ white [\t\f\r ] {white}+ {loc.step();} \n+ {loc.lines(yyleng); loc.step();} +{comment} {} + . { std::cerr<<"ERROR"; } diff --git a/t/trivial.pas b/t/trivial.pas index 2795e2e..72f2d40 100644 --- a/t/trivial.pas +++ b/t/trivial.pas @@ -5,12 +5,17 @@ const gi=5; gr=3.1415; gs='nagi'; -var +var {this is comment} gvi:integer; gvf:real; gvp:^char; gva:array[0..4] of integer; +(* multiline + + +comments *) + function arithmetic_test(a:integer;b:char;c:real):integer; var d:integer; -- cgit