Changeset a64e772 in rtems-central


Ignore:
Timestamp:
01/13/23 15:41:01 (14 months ago)
Author:
Andrew Butterfield <Andrew.Butterfield@…>
Branches:
master
Children:
ebe9144
Parents:
5d08ea3
git-author:
Andrew Butterfield <Andrew.Butterfield@…> (01/13/23 15:41:01)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/18/23 11:42:32)
Message:

modifications made to comment_filter

Location:
formal/promela/src/src/modules/comment_filter
Files:
9 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • formal/promela/src/src/modules/comment_filter/LICENSE

    r5d08ea3 ra64e772  
    1 Copyright (c) 2017, The Linux Foundation. All rights reserved.
     1Copyright (c) 2019-2020 Trinity College Dublin, Ireland
     2Copyright (c) 2017, The Linux Foundation.
     3All rights reserved.
    24
    35Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • formal/promela/src/src/modules/comment_filter/comment_filter/language.py

    r5d08ea3 ra64e772  
    88
    99c = Lang(
    10     line_comment='//',
     10    line_comment=['//'],
    1111    comment_bookends=[('/*', '*/'), (';;', ';;')],
    1212    nested_comments=False)
    1313
    1414haskell = Lang(
    15     line_comment='--',
     15    line_comment=['--'],
    1616    comment_bookends=[('{-', '-}')],
    1717    nested_comments=True)
    1818
    1919python = Lang(
    20     line_comment='#',
     20    line_comment=['#'],
    2121    comment_bookends=[('"""', '"""'), ("'''", "'''")],
    2222    nested_comments=False)
    2323
    2424ruby = Lang(
    25     line_comment='#',
     25    line_comment=['#'],
    2626    comment_bookends=[("=begin", "=end")],
    2727    nested_comments=False)
    2828
    2929lua = Lang(
    30     line_comment='--',
     30    line_comment=['--'],
    3131    comment_bookends=[("--[[", "--]]")],
    3232    nested_comments=False)
    3333
    3434perl = Lang(
    35     line_comment='#',
     35    line_comment=['#'],
    3636    comment_bookends=[("=pod", "=cut")],
    3737    nested_comments=False)
    3838
    3939java = Lang(
    40     line_comment='//',
     40    line_comment=['//'],
    4141    comment_bookends=[('/*', '*/')],
    4242    nested_comments=True)
  • formal/promela/src/src/modules/comment_filter/comment_filter/rfc.py

    r5d08ea3 ra64e772  
    7474    # complete parsing that declaration.  Store the result in 'rest_of_decl'.
    7575    rest_of_decl = ''
     76    rest_of_decl0 = ''
    7677    if state.in_literal:
    7778        # Parsing a string literal.
     
    8485        # If there is state, we assume it is because we have parsed
    8586        # the start of a multiline comment, but haven't found the end.
    86         cmt, state = finish_multiline_comment(lang, state, keep_tokens)
     87        cmt, cmt0, state = finish_multiline_comment(lang, state, keep_tokens)
    8788        if code_only:
    8889            rest_of_decl = clear_line(cmt)
     90            rest_of_decl0 = clear_line(cmt0)
    8991        else:
    9092            rest_of_decl = cmt
     93            rest_of_decl0 = cmt0
    9194
    9295    if state.in_literal or state.multi_end_stack:
    93         return rest_of_decl, state
     96        return [rest_of_decl + rest_of_decl0], state
    9497
    9598    decls, state = parse_declarations(lang, state, code_only, keep_tokens)
    96     return rest_of_decl + decls, state
     99    return [rest_of_decl, rest_of_decl0] + decls, state
    97100
    98101
     
    121124    code, state = parse_code(lang, state)
    122125    comment, state = parse_line_comment(lang, state, keep_tokens)
    123     comment2, state = parse_multiline_comment(lang, state, keep_tokens)
    124 
    125     if comment or comment2:
    126         line = state.line
     126    comment2, comment2_0, state = parse_multiline_comment(lang, state, keep_tokens)
     127
     128    if comment or comment2 or comment2_0:
     129        line = [state.line]
    127130        if not state.multi_end_stack:
    128131            # Continue looking for declarations.
    129132            line, state = parse_declarations(lang, state, code_only, keep_tokens)
    130133        if code_only:
    131             line = code + clear_line(comment) + clear_line(comment2) + line
    132         else:
    133             line = clear_line(code) + comment + comment2 + line
     134            line = [code, clear_line(comment), clear_line(comment2), clear_line(comment2_0)] + line
     135        else:
     136            line = [clear_line(code), comment, comment2, comment2_0] + line
    134137        return line, state
    135138    else:
    136139        state.line = ''
    137140        if code_only:
    138             return code, state
    139         else:
    140             return clear_line(code), state
     141            return [code], state
     142        else:
     143            return [clear_line(code)], state
    141144
    142145
     
    158161        line = state.line
    159162        multi_start_tokens = [start for start, end in lang.comment_bookends]
    160         tokens = multi_start_tokens + [
    161             lang.line_comment,
     163        tokens = multi_start_tokens + lang.line_comment + [
    162164            lang.string_literal_start,
    163165            lang.string_literal2_start]
     
    166168            state.line = line[i:]
    167169            code += line[:i]
    168             if line.startswith(lang.line_comment, i) or \
     170            if [ () for cmt in lang.line_comment if line.startswith(cmt, i) ] or \
    169171                    index_of_first_found(line, multi_start_tokens) == i:
    170172                return code, state
     
    272274    """
    273275    line = state.line
    274     line_comment = lang.line_comment
    275     if line.startswith(line_comment):
    276         state.line = ''
    277         i = len(line_comment)
    278         if not keep_tokens:
    279             line_comment = ' ' * i
    280         return line_comment + line[i:], state
    281     else:
    282         return '', state
     276    for line_comment in lang.line_comment:
     277        if line.startswith(line_comment):
     278            state.line = ''
     279            i = len(line_comment)
     280            if not keep_tokens:
     281                line_comment = ' ' * i
     282            return line_comment + line[i:], state
     283    return '', state
    283284
    284285
     
    305306            state.multi_end_stack.append(multi_end)
    306307            state.line = line[len(multi_start):]
    307             cnts, state = finish_multiline_comment(lang, state, keep_tokens)
     308            cnts, cnts0, state = finish_multiline_comment(lang, state, keep_tokens)
    308309            if not keep_tokens:
    309310                multi_start = ' ' * len(multi_start)
    310             return multi_start + cnts, state
    311     return '', state
     311            return multi_start + cnts, cnts0, state
     312    return '', '', state
    312313
    313314
     
    333334    # Handle language supports nested comments.
    334335    if lang.nested_comments:
    335         cmt, state = parse_multiline_comment(lang, state, keep_tokens)
     336        cmt, cmt0, state = parse_multiline_comment(lang, state, keep_tokens)
    336337    else:
    337338        cmt = ''
     339        cmt0 = ''
    338340
    339341    line = state.line
     
    345347            if not keep_tokens:
    346348                multi_end = ' ' * len(multi_end)
    347             return cnts + cmt + multi_end, state
    348         else:
    349             more_cnts, state = finish_multiline_comment(lang, state, keep_tokens)
    350             return cnts + cmt + more_cnts, state
    351     else:
    352         return cnts + cmt, state
     349            return cnts + cmt + cmt0, multi_end, state
     350        else:
     351            more_cnts, more_cnts0, state = finish_multiline_comment(lang, state, keep_tokens)
     352            return cnts + cmt + cmt0 + more_cnts, more_cnts0, state
     353    else:
     354        return cnts + cmt + cmt0, '', state
    353355
    354356
Note: See TracChangeset for help on using the changeset viewer.