@@ -798,31 +798,13 @@ ag_token token;
798
798
BEGIN (xb);
799
799
// strbuf_append_char(&yyextra.literal_buf, 'b');
800
800
}
801
- <xb >{xbinside } {
802
- strbuf_append_buf (&yyextra.literal_buf , yytext, yyleng);
803
- }
801
+
804
802
<xb ><<EOF>> {
805
803
ereport (ERROR, (errcode (ERRCODE_SYNTAX_ERROR),
806
804
scan_errmsg (" unterminated hexadecimal string literal" ),
807
805
scan_errposition ()));
808
806
}
809
807
810
- <xb >{squote } {
811
- BEGIN (INITIAL);
812
-
813
- /*
814
- * In quoted strings, only Unicode escape sequences need to be verified,
815
- * and the actions for <dqstr,sqstr>{esunicode} and <qstru>{esunicode}
816
- * rules verify the code point values. So, quoted strings are always valid.
817
- */
818
-
819
- token.type = AG_TOKEN_BCONST;
820
- token.value .s = strbuf_get_str (&yyextra.literal_buf );
821
- token.location = get_location ();
822
- return token;
823
- }
824
-
825
-
826
808
{xhstart } {
827
809
/* Hexadecimal bit type.
828
810
* At some point we should simply pass the string
@@ -833,35 +815,18 @@ ag_token token;
833
815
BEGIN (xh);
834
816
strbuf_append_char (&yyextra.literal_buf , ' x' );
835
817
}
836
-
837
- <xh >{xhinside } {
818
+
819
+ <xh >{xhinside } |
820
+ <xb >{xbinside } {
838
821
strbuf_append_buf (&yyextra.literal_buf , yytext, yyleng);
839
822
}
823
+
840
824
<xh ><<EOF>> {
841
825
ereport (ERROR, (errcode (ERRCODE_SYNTAX_ERROR),
842
826
scan_errmsg (" unterminated hexadecimal string literal" ),
843
827
scan_errposition ()));
844
828
}
845
829
846
- <xh >{squote } {
847
- BEGIN (INITIAL);
848
-
849
- /*
850
- * In quoted strings, only Unicode escape sequences need to be verified,
851
- * and the actions for <dqstr,sqstr>{esunicode} and <qstru>{esunicode}
852
- * rules verify the code point values. So, quoted strings are always valid.
853
- */
854
-
855
- token.type = AG_TOKEN_XCONST;
856
- // token.value.s = strbuf_get_str(&yyextra.literal_buf);
857
- // token.value.s = copy_string(strbuf_get_str(&yyextra.literal_buf), yyleng);
858
- token.value .s = strbuf_get_str (&yyextra.literal_buf );
859
- token.location = get_location ();
860
- return token;
861
- }
862
-
863
-
864
-
865
830
{xestart } {
866
831
yyextra.warn_on_first_escape = false ;
867
832
yyextra.saw_non_ascii = false ;
@@ -877,8 +842,7 @@ ag_token token;
877
842
*/
878
843
BEGIN (yyextra.state_before_str_stop );
879
844
}
880
- <xqs >{quotecontinuefail } |
881
- <xqs >{other } |
845
+
882
846
<xb ,xh ,xq ,xe ,xus >{squote } {
883
847
/*
884
848
* When we are scanning a quoted string and see an end
@@ -906,18 +870,17 @@ ag_token token;
906
870
switch (yyextra.state_before_str_stop )
907
871
{
908
872
case xb:
909
-
910
873
token.type = AG_TOKEN_BCONST;
911
874
token.value .s = strbuf_get_str (&yyextra.literal_buf );
912
875
token.location = get_location ();
876
+ strbuf_reset (&yyextra.literal_buf );
913
877
return token;
914
878
case xh:
915
879
token.type = AG_TOKEN_XCONST;
916
880
token.value .s = strbuf_get_str (&yyextra.literal_buf );
917
881
token.location = get_location ();
882
+ strbuf_reset (&yyextra.literal_buf );
918
883
return token;
919
- // yylval->str = litbufdup(yyscanner);
920
- // return XCONST;
921
884
case xq:
922
885
case xe:
923
886
/*
@@ -928,27 +891,23 @@ ag_token token;
928
891
pg_verifymbstr (yyextra.literal_buf .buffer ,
929
892
yyextra.literal_buf .length ,
930
893
false );
931
- // yylval->str = litbufdup(yyscanner);
932
- // return SCONST;
894
+
933
895
token.type = AG_TOKEN_STRING;
934
896
token.value .s = strbuf_get_str (&yyextra.literal_buf );
935
897
token.location = get_location ();
898
+ strbuf_reset (&yyextra.literal_buf );
936
899
return token;
937
900
case xus:
938
901
token.type = AG_TOKEN_STRING;
939
902
token.value .s = strbuf_get_str (&yyextra.literal_buf );
940
903
token.location = get_location ();
904
+ strbuf_reset (&yyextra.literal_buf );
941
905
return token;
942
- // yylval->str = litbufdup(yyscanner);
943
- // return USCONST;
906
+
944
907
default :{
945
- token.type = AG_TOKEN_STRING;
946
- token.value .s = strbuf_get_str (&yyextra.literal_buf );
947
- token.location = get_location ();
948
- return token;
949
- /*ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR),
908
+ ereport (ERROR, (errcode (ERRCODE_SYNTAX_ERROR),
950
909
scan_errmsg (" unhandled previous state in xqs" ),
951
- scan_errposition()));*/
910
+ scan_errposition ()));
952
911
}
953
912
}
954
913
}
0 commit comments