From 408d592c3e267743f6ded0b37c5eb72ef92c2ae6 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Wed, 1 Apr 2009 05:03:28 +0200 Subject: [PATCH] FUEL: Font lock and no indentation for EBNF: ... ;EBNF forms. --- extra/peg/pl0/pl0.factor | 22 +++++++++++----------- misc/fuel/fuel-font-lock.el | 7 ++++++- misc/fuel/fuel-syntax.el | 4 +++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/extra/peg/pl0/pl0.factor b/extra/peg/pl0/pl0.factor index eff923dc01..179e03f1cf 100644 --- a/extra/peg/pl0/pl0.factor +++ b/extra/peg/pl0/pl0.factor @@ -6,20 +6,20 @@ IN: peg.pl0 #! 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> ]] diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 5961d9e86f..bc1bb900ce 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -58,6 +58,7 @@ (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>>)") @@ -75,7 +76,9 @@ (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) @@ -85,6 +88,8 @@ '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) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 4cff58ae3b..7aba6282d6 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -48,7 +48,7 @@ "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:" @@ -254,6 +254,8 @@ ("\\_<<\\(\"\\)\\_>" (1 "\\_>" (1 ">b")) ;; Multiline constructs + ("\\_<\\(E\\)BNF:\\( \\|\n\\)" (1 "" (1 ">b")) ("\\_<\\(U\\)SING: \\(;\\)" (1 "b")) ("\\_b"))