StrictDoc Documentation
strictdoc/backend/sdoc/grammar/grammar_grammar.py
Source file coverage
Path:
strictdoc/backend/sdoc/grammar/grammar_grammar.py
Lines:
101
Non-empty lines:
87
Non-empty lines covered with requirements:
87 / 87 (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
;
40
 
41
GrammarElementRelationChild[noskipws]:
42
  '  - TYPE: ' relation_type='Child' '\n'
43
  ('    ROLE: ' relation_role=/.+/ '\n')?
44
;
45
 
46
GrammarElementRelationFile[noskipws]:
47
  '  - TYPE: ' relation_type='File' '\n'
48
  ('    ROLE: ' relation_role=/.+/ '\n')?
49
;
50
 
51
GrammarElementField[noskipws]:
52
  GrammarElementFieldString |
53
  GrammarElementFieldSingleChoice |
54
  GrammarElementFieldMultipleChoice |
55
  GrammarElementFieldTag
56
;
57
 
58
GrammarElementFieldString[noskipws]:
59
  '  - TITLE: ' title=FieldName '\n'
60
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
61
  '    TYPE: String' '\n'
62
  '    REQUIRED: ' (required = BooleanChoice) '\n'
63
;
64
 
65
GrammarElementFieldSingleChoice[noskipws]:
66
  '  - TITLE: ' title=FieldName '\n'
67
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
68
  '    TYPE: SingleChoice'
69
    '(' ((options = ChoiceOption) (options *= ChoiceOptionXs)) ')' '\n'
70
  '    REQUIRED: ' (required = BooleanChoice) '\n'
71
;
72
 
73
GrammarElementFieldMultipleChoice[noskipws]:
74
  '  - TITLE: ' title=FieldName '\n'
75
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
76
  '    TYPE: MultipleChoice'
77
    '(' ((options = ChoiceOption) (options *= ChoiceOptionXs)) ')' '\n'
78
  '    REQUIRED: ' (required = BooleanChoice) '\n'
79
;
80
 
81
GrammarElementFieldTag[noskipws]:
82
  '  - TITLE: ' title=FieldName '\n'
83
  ('    HUMAN_TITLE: ' human_title=SingleLineString '\n')?
84
  '    TYPE: Tag' '\n'
85
  '    REQUIRED: ' (required = BooleanChoice) '\n'
86
;
87
 
88
ReferenceType[noskipws]:
89
  ('ParentReqReference' | 'ChildReqReference' | 'FileReference')
90
;
91
 
92
ReferenceTypeXs[noskipws]:
93
  /, /- ReferenceType
94
;
95
"""
96
 
97
GRAMMAR_WRAPPER = """
98
DocumentGrammarWrapper[noskipws]:
99
    grammar = DocumentGrammar
100
;
101
"""