@@ -629,6 +629,49 @@ static get_char_t skip_macros(parser_t *p)
629
629
return PARSER_EOF ;
630
630
}
631
631
632
+ static get_char_t skip_inline_asm (parser_t * p )
633
+ {
634
+ get_char_t ch = get_char (p );
635
+ if (ch != 's' )
636
+ goto check_s_failed ;
637
+ if (UNLIKELY (ch == PARSER_EOF ))
638
+ return ch ;
639
+ ch = get_char (p );
640
+ if (ch != 'm' )
641
+ goto check_m_failed ;
642
+ if (UNLIKELY (ch == PARSER_EOF ))
643
+ return ch ;
644
+
645
+ int paren = 0 ;
646
+ do {
647
+ ch = get_char (p );
648
+ if (ch == '\n' ) {
649
+ lines ++ ;
650
+ lineno ++ ;
651
+ continue ;
652
+ }
653
+ if (ch == '/' ) {
654
+ get_char_t ret = skip_comments (p );
655
+ if (LIKELY (ret == PARSER_COMMENT_FOUND ))
656
+ continue ;
657
+ if (UNLIKELY (ret == PARSER_EOF ))
658
+ return ret ;
659
+ }
660
+ if (UNLIKELY (ch == PARSER_EOF ))
661
+ return ch ;
662
+ /* Increase paren by 1 if ch is '(' and decrease by 1 if ch is ')'. */
663
+ ch ^= '(' ; /* This results 0, 1, or other for '(', ')', or other. */
664
+ paren += !ch - (ch == 1 );
665
+ } while (paren );
666
+ return PARSER_COMMENT_FOUND ;
667
+
668
+ check_m_failed :
669
+ unget_char (p );
670
+ check_s_failed :
671
+ unget_char (p );
672
+ return PARSER_OK ;
673
+ }
674
+
632
675
/* Parse an integer value.
633
676
* Since the Linux kernel does not support floats or doubles, only decimal,
634
677
* octal, and hexadecimal formats are handled.
@@ -743,6 +786,23 @@ static get_char_t parse_identifier(parser_t *restrict p,
743
786
}
744
787
}
745
788
789
+ /* Parse an potential inline assembly. */
790
+ static get_char_t parse_inline_asm (parser_t * restrict p ,
791
+ token_t * restrict t ,
792
+ get_char_t ch )
793
+ {
794
+ get_char_t ret = skip_inline_asm (p );
795
+
796
+ if (ret == PARSER_COMMENT_FOUND ) {
797
+ ret |= PARSER_CONTINUE ;
798
+ return ret ;
799
+ }
800
+ if (UNLIKELY (ret == PARSER_EOF ))
801
+ return ret ;
802
+
803
+ return parse_identifier (p , t , ch );
804
+ }
805
+
746
806
/* Process escape sequences at the end of a string literal.
747
807
* Transformations:
748
808
* "foo\n" becomes "foo"
@@ -1112,7 +1172,7 @@ static get_token_action_t get_token_actions[] = {
1112
1172
['|' ] = parse_op ,
1113
1173
['&' ] = parse_op ,
1114
1174
['-' ] = parse_minus ,
1115
- ['a' ] = parse_identifier ,
1175
+ ['a' ] = parse_inline_asm ,
1116
1176
['b' ] = parse_identifier ,
1117
1177
['c' ] = parse_identifier ,
1118
1178
['d' ] = parse_identifier ,
0 commit comments