File: sp21.sty

package info (click to toggle)
styx 1.7-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,324 kB
  • ctags: 5,329
  • sloc: ansic: 96,480; sh: 7,972; cpp: 1,572; makefile: 227; xml: 107; pascal: 15
file content (156 lines) | stat: -rwxr-xr-x 3,439 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
;; [sp21.sty] Context-free grammar for the STEP exchange format, ISO 10303 Part 21


Language sp21 ;; STEP exchange format, ISO 10303 Part 21

Regular Grammar

; Character Set

  let Byte        = '\00' .. '\ff' ; all extended ascii
  let Control     = '\00' .. '\1f' ; control
                  |          '\7f' ; DEL
                  |          '\ff' ; space-like extended ascii

; Basic elements of tokens

  let Printable   = Byte - Control

  ign Space       = " "  | "\t"  ; ASCII - Space
  ign Line        = "\n" | "\r"  ; UNIX / Windows / DOS / Mac
  ign Page        = "\p"         ; weak separation convention

  ign Etx         = "\1a" {Byte} ; CPM / older DOS Versions

; Definitions and simple tokens

  let ULetter     = 'A'..'Z' | '_'
  let LLetter     = 'a'..'z'
  let Letter      = ULetter | LLetter
  let Hex1        = '0'..'9' | 'a'..'f' | 'A' .. 'Z'
  let Hex2        = Hex1 Hex1
  let Hex4        = Hex2 Hex2
  let Digit       = '0'..'9'
  let Special     = '!\"*$%&.#+,-()?/:;<=>@[]{}|^~\`'
  let Character   = Letter | Digit | Special | ' ' | '\'' | '\\'
  let Directive   = ( "\\P" ULetter "\\" )
                  | ( "\\S\\" Character )
                  | ( "\\X" Hex1 "\\" )
                  | ( "\\X2\\" Hex2 { Hex2 } "\\X0\\" )
                  | ( "\\X4\\" Hex4 { Hex4 } "\\X0\\" )
  let LitChar     = Letter | Digit | Special | ' ' | "\'\'" | "\\\\" | Directive
  let Sign        = "+" | "-"
  let Nat         = Digit { Digit }
  let Alpha       = ULetter { ULetter | Digit }

; Comments et al

  com Comment  = "/*" ({Byte}-({Byte}"*/"{Byte})) "*/"
               | "//" ({Byte}-({Byte} Line {Byte})) Line

; Complex tokens

  tok Key   = [ "!" ] Alpha                  ; KEYWORD

  tok Enum  = "." Alpha "."                  ; ENUMERATION

  tok Ide   = "#" Nat                        ; ENTITY_INSTANCE_NAME

  tok Int   = [ Sign ] Nat                   ; INTEGER

  tok Flt   = [ Sign ] Nat "." { Digit }
              [ "E" [ Sign ] Nat ]           ; REAL

  tok Str   = '\'' {LitChar} '\''            ; STRING

  tok Bin   = "\"" 
              ( "0" | "1" | "2" | "3" ) 
              { Hex1 } "\""                  ; BINARY

  tok Opr   = '(),;=*$' 
            | ( [ "END-" ] "ISO-10303-21;" )
            | "HEADER;"
            | "ENDSEC;"                      ; Operator

Context Free Grammar

start Step21
:root: "ISO-10303-21;" HdrSec DataSecs "END-ISO-10303-21;"

let HdrSec
:dfn : "HEADER;" HdrEntities "ENDSEC;" ; min. 3 elements

let HdrEntities
:cons: HdrEntity HdrEntities2

let HdrEntities2
:cons: HdrEntity HdrEntities1

let HdrEntities1
:cons: HdrEntity HdrEntities0

let HdrEntities0
:nil :
:cons: HdrEntity HdrEntities0

let DataSecs
:cons: DataSec DataSecs0

let DataSecs0
:nil :
:cons: DataSec DataSecs0

let HdrEntity
:dfn : Key "(" Params ")" ";"

let Params0
:nil :
:cons: "," Param Params0 

let Params
:nil :
:ign0: Params1 

let Params1
:cons: Param Params0 

let Params2
:nil :
:ign0: "(" Params1 ")"

let Param
:typ : Key "(" Param ")"
:null: "*"
:opt : "$"
:ide : Ide
:int : Int
:flt : Flt
:str : Str
:bin : Bin
:enum: Enum
:list: "(" Params ")"

let DataSec
:dfn : "DATA" Params2 ";" Instances "ENDSEC;"

let Instances
:nil :
:cons: Instance Instances

let Instance
:dfn : Ide "=" Record ";"

let Record0
:srec: Key "(" Params ")"

let Record
:crec: "(" SRecords ")"
:ign0: Record0

let SRecords
:cons: Record0 SRecords0

let SRecords0
:nil :
:cons: Record0 SRecords0