Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion strictdoc/backend/sdoc/grammar/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
;

FieldName[noskipws]:
/{NEGATIVE_UID}{NEGATIVE_RELATIONS}[A-Z]+[A-Z_0-9]*/
/{NEGATIVE_UID}{NEGATIVE_RELATIONS}[A-Z]+[A-Za-z0-9_\-]*/
;
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GrammarTemplate(Template):


RELATION_MARKER_START = r"@relation[\(\{]"
REGEX_NODE_NAME = r"[A-Za-z0-9_\-]+"

GRAMMAR = GrammarTemplate("""
start: ##START
Expand All @@ -29,13 +30,13 @@ class GrammarTemplate(Template):
relation_role: ALPHANUMERIC_WORD

node_field: node_name ":" node_multiline_value
node_name: /(?!(##RESERVED_KEYWORDS))[A-Z_]+/
node_name: /(?!(##RESERVED_KEYWORDS))##REGEX_NODE_NAME/
node_multiline_value: (_WS_INLINE | _NL) (NODE_FIRST_STRING_VALUE _NL) (NODE_STRING_VALUE _NL)*

NODE_FIRST_STRING_VALUE.2: /\\s*[^\n\r]+/x
NODE_STRING_VALUE.2: /(?![ ]*##RELATION_MARKER_START)(?!\\s*[A-Z_]+: )[^\n\r]+/x

_NORMAL_STRING_NO_MARKER_NO_NODE: /(?!\\s*##RELATION_MARKER_START)((?!\\s*[A-Z_]+: )|(##RESERVED_KEYWORDS)).+/
_NORMAL_STRING_NO_MARKER_NO_NODE: /(?!\\s*##RELATION_MARKER_START)((?!\\s*##REGEX_NODE_NAME: )|(##RESERVED_KEYWORDS)).+/

_NORMAL_STRING_NO_MARKER: /(?!\\s*##RELATION_MARKER_START).+/

Expand Down Expand Up @@ -68,6 +69,7 @@ def parse(source_input: str, parse_nodes: bool = False) -> ParseTree:
start = "(relation_marker | _NORMAL_STRING_NO_MARKER | _WS)*"

grammar = GRAMMAR.substitute(
REGEX_NODE_NAME=REGEX_NODE_NAME,
RELATION_MARKER_START=RELATION_MARKER_START,
RESERVED_KEYWORDS=RESERVED_KEYWORDS,
REGEX_REQ=REGEX_REQ,
Expand Down
2 changes: 2 additions & 0 deletions strictdoc/backend/sdoc_source_code/models/source_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union

from strictdoc.backend.sdoc_source_code.models.function import Function
from strictdoc.backend.sdoc_source_code.models.function_range_marker import (
FunctionRangeMarker,
)
Expand All @@ -21,3 +22,4 @@ class SourceNode:
default_factory=list
)
fields: Dict[str, str] = field(default_factory=dict)
function: Optional[Function] = None
9 changes: 9 additions & 0 deletions strictdoc/backend/sdoc_source_code/reader_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from strictdoc.backend.sdoc_source_code.models.source_file_info import (
SourceFileTraceabilityInfo,
)
from strictdoc.backend.sdoc_source_code.models.source_node import SourceNode
from strictdoc.backend.sdoc_source_code.parse_context import ParseContext
from strictdoc.backend.sdoc_source_code.processors.general_language_marker_processors import (
function_range_marker_processor,
Expand Down Expand Up @@ -69,6 +70,8 @@ def read(
tree = parser.parse(input_buffer)

nodes = traverse_tree(tree)

source_node: Optional[SourceNode]
for node_ in nodes:
function_name: str
function_markers: List[FunctionRangeMarker]
Expand Down Expand Up @@ -168,6 +171,7 @@ def read(
if specifier_node_.text == b"static":
function_attributes.add(FunctionAttribute.STATIC)

source_node = None
function_markers = []
function_comment_node = None
if (
Expand Down Expand Up @@ -215,6 +219,8 @@ def read(
markers=function_markers,
attributes=function_attributes,
)
if source_node is not None:
source_node.function = new_function
traceability_info.functions.append(new_function)

elif node_.type == "function_definition":
Expand Down Expand Up @@ -266,6 +272,7 @@ def read(
if function_name.startswith("TEST"):
function_display_name = function_name

source_node = None
function_markers = []
function_comment_node = None
function_comment_text = None
Expand Down Expand Up @@ -326,6 +333,8 @@ def read(
traceability_info.ng_map_names_to_definition_functions[
function_name
] = new_function
if source_node is not None:
source_node.function = new_function
elif node_.type == "comment":
#
# FIXME: Here parsing of function comments can happen as well
Expand Down
Loading
Loading