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