StrictDoc Documentation
strictdoc/backend/sdoc/grammar/grammar_grammar.py
Source file coverage
Path:
strictdoc/backend/sdoc/grammar/grammar_grammar.py
Lines:
103
Non-empty lines:
89
Non-empty lines covered with requirements:
89 / 89 (100.0%)
Functions:
0
Functions covered by requirements:
0 / 0 (0.0%)
1
GRAMMAR_GRAMMAR = r"""
2
DocumentGrammar[noskipws]:
3
  '[GRAMMAR]' '\n'
4
 
5
  (
6
    (
7
      'ELEMENTS:' '\n'
8
      elements += GrammarElement
9
    )? |
10
    (
11
      'IMPORT_FROM_FILE: ' import_from_file = /.+$/ '\n'
12
    )?
13
  )
14
;
15
 
16
GrammarElement[noskipws]:
17
  '- TAG: ' tag = RequirementType '\n'
18
  (
19
    '  PROPERTIES:' '\n'
20
    ('    IS_COMPOSITE: ' property_is_composite=/(True|False)/ '\n' )?
21
    ('    PREFIX: ' property_prefix=/.*/ '\n' )?
22
    ('    VIEW_STYLE: ' property_view_style=/(Plain|Simple|Inline|Narrative|Table|Zebra)/ '\n')?
23
  )?
24
  '  FIELDS:' '\n'
25
  fields += GrammarElementField
26
  (
27
    '  RELATIONS:' '\n'
28
    relations += GrammarElementRelation
29
  )?
30
;
31
 
32
GrammarElementRelation[noskipws]:
33
  (GrammarElementRelationParent | GrammarElementRelationChild | GrammarElementRelationFile)
34
;
35
 
36
GrammarElementRelationParent[noskipws]:
37
  '  - TYPE: ' relation_type='Parent' '\n'
38
  ('    ROLE: ' relation_role=/.+/ '\n')?
39
  ('    REVERSE_ROLE: ' reverse_relation_role=/.+/ '\n')?
40
;
41
 
42
GrammarElementRelationChild[noskipws]:
43
  '  - TYPE: ' relation_type='Child' '\n'
44
  ('    ROLE: ' relation_role=/.+/ '\n')?
45
  ('    REVERSE_ROLE: ' reverse_relation_role=/.+/ '\n')?
46
;
47
 
48
GrammarElementRelationFile[noskipws]:
49
  '  - TYPE: ' relation_type='File' '\n'
50
  ('    ROLE: ' relation_role=/.+/ '\n')?
51
;
52
 
53
GrammarElementField[noskipws]:
54
  GrammarElementFieldString |
55
  GrammarElementFieldSingleChoice |
56
  GrammarElementFieldMultipleChoice |
57
  GrammarElementFieldTag
58
;
59
 
60
GrammarElementFieldString[noskipws]:
61
  '  - TITLE: ' title=FieldName '\n'
62
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
63
  '    TYPE: String' '\n'
64
  '    REQUIRED: ' (required = BooleanChoice) '\n'
65
;
66
 
67
GrammarElementFieldSingleChoice[noskipws]:
68
  '  - TITLE: ' title=FieldName '\n'
69
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
70
  '    TYPE: SingleChoice'
71
    '(' ((options = ChoiceOption) (options *= ChoiceOptionXs)) ')' '\n'
72
  '    REQUIRED: ' (required = BooleanChoice) '\n'
73
;
74
 
75
GrammarElementFieldMultipleChoice[noskipws]:
76
  '  - TITLE: ' title=FieldName '\n'
77
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
78
  '    TYPE: MultipleChoice'
79
    '(' ((options = ChoiceOption) (options *= ChoiceOptionXs)) ')' '\n'
80
  '    REQUIRED: ' (required = BooleanChoice) '\n'
81
;
82
 
83
GrammarElementFieldTag[noskipws]:
84
  '  - TITLE: ' title=FieldName '\n'
85
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
86
  '    TYPE: Tag' '\n'
87
  '    REQUIRED: ' (required = BooleanChoice) '\n'
88
;
89
 
90
ReferenceType[noskipws]:
91
  ('ParentReqReference' | 'ChildReqReference' | 'FileReference')
92
;
93
 
94
ReferenceTypeXs[noskipws]:
95
  /, /- ReferenceType
96
;
97
"""
98
 
99
GRAMMAR_WRAPPER = """
100
DocumentGrammarWrapper[noskipws]:
101
    grammar = DocumentGrammar
102
;
103
"""