#! Grammar for PL/0 based on http://en.wikipedia.org/wiki/PL/0
-EBNF: pl0
+EBNF: pl0
-block = { "CONST" ident "=" number { "," ident "=" number }* ";" }?
- { "VAR" ident { "," ident }* ";" }?
- { "PROCEDURE" ident ";" { block ";" }? }* statement
-statement = { ident ":=" expression
- | "CALL" ident
- | "BEGIN" statement { ";" statement }* "END"
- | "IF" condition "THEN" statement
- | "WHILE" condition "DO" statement }?
+block = { "CONST" ident "=" number { "," ident "=" number }* ";" }?
+ { "VAR" ident { "," ident }* ";" }?
+ { "PROCEDURE" ident ";" { block ";" }? }* statement
+statement = { ident ":=" expression
+ | "CALL" ident
+ | "BEGIN" statement { ";" statement }* "END"
+ | "IF" condition "THEN" statement
+ | "WHILE" condition "DO" statement }?
condition = { "ODD" expression }
| { expression ("=" | "#" | "<=" | "<" | ">=" | ">") expression }
-expression = {"+" | "-"}? term { {"+" | "-"} term }*
-term = factor { {"*" | "/"} factor }*
+expression = {"+" | "-"}? term { {"+" | "-"} term }*
+term = factor { {"*" | "/"} factor }*
factor = ident | number | "(" expression ")"
ident = (([a-zA-Z])+) => [[ >string ]]
digit = ([0-9]) => [[ digit> ]]
(number constant "integers and floats")
(ratio constant "ratios")
(declaration keyword "declaration words")
+ (ebnf-form constant "EBNF: ... ;EBNF form")
(parsing-word keyword "parsing words")
(setter-word function-name "setter words (>>foo)")
(getter-word function-name "getter words (foo>>)")
(defun fuel-font-lock--syntactic-face (state)
(if (nth 3 state) 'factor-font-lock-string
(let ((c (char-after (nth 8 state))))
- (cond ((or (char-equal c ?\ ) (char-equal c ?\n))
+ (cond ((or (char-equal c ?\ )
+ (char-equal c ?\n)
+ (char-equal c ?E))
(save-excursion
(goto-char (nth 8 state))
(beginning-of-line)
'factor-font-lock-symbol)
((looking-at-p "C-ENUM:\\( \\|\n\\)")
'factor-font-lock-constant)
+ ((looking-at-p "E")
+ 'factor-font-lock-ebnf-form)
(t 'default))))
((or (char-equal c ?U) (char-equal c ?C))
'factor-font-lock-parsing-word)
"B" "BIN:"
"C:" "C-ENUM:" "C-STRUCT:" "C-UNION:" "CHAR:" "CONSTANT:" "call-next-method"
"DEFER:"
- "ERROR:" "EXCLUDE:"
+ "EBNF:" ";EBNF" "ERROR:" "EXCLUDE:"
"f" "FORGET:" "FROM:" "FUNCTION:"
"GENERIC#" "GENERIC:"
"HELP:" "HEX:" "HOOK:"
("\\_<<\\(\"\\)\\_>" (1 "<b"))
("\\_<\\(\"\\)>\\_>" (1 ">b"))
;; Multiline constructs
+ ("\\_<\\(E\\)BNF:\\( \\|\n\\)" (1 "<b"))
+ ("\\_<;EBN\\(F\\)\\_>" (1 ">b"))
("\\_<\\(U\\)SING: \\(;\\)" (1 "<b") (2 ">b"))
("\\_<USING:\\( \\)" (1 "<b"))
("\\_<\\(C\\)-ENUM: \\(;\\)" (1 "<b") (2 ">b"))