[A68-MODE][COMMITTED 09/10] More work in the grammar
Jose E. Marchesi
jemarch@gnu.org
Thu May 15 09:59:28 GMT 2025
---
a68-mode.el | 137 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 118 insertions(+), 19 deletions(-)
diff --git a/a68-mode.el b/a68-mode.el
index 3607479..f658ad8 100644
--- a/a68-mode.el
+++ b/a68-mode.el
@@ -354,7 +354,7 @@ with the equivalent upcased form."
(defconst a68--bnf-grammar
'((id)
- (declarer)
+ (field-selector)
(ids (id "-anchor-" id))
(fields (fields "," fields)
(ids))
@@ -364,7 +364,7 @@ with the equivalent upcased form."
(fargs (fargs "," fargs)
(modal)
(exp))
- (modal ("-mode-" type-decl**))
+ (modal ("-mode-" mode-indication))
(specs (specs "," specs)
(spec))
(exp (ids)
@@ -372,15 +372,6 @@ with the equivalent upcased form."
(exp "[" exp "]")
("module" exp "def" exp "fed")
("module" exp "def" exp "postlude" exp "fed"))
- ;; Declarations:
- (type-decl** ("struct" args)
- ("union" args)
- ("proc" args))
- (op-decl (op-decl "," op-decl)
- ("op" ids "=" args ids ":" exp))
- (proc-decl (proc-decl "," proc-decl)
- ("op" ids "=" args ids ":" exp)
- ("proc" ids "=" ids ":" exp))
;; Compilation inputs
;; ==================
(compilation-input (labeled-enclosed-clause)
@@ -553,18 +544,14 @@ with the equivalent upcased form."
;; mode joined definition :
;; (mode joined definition, and also token), mode definition.
;; mode definition :
- ;; defined mode indication, is defined as token, declarer or code.
+ ;; defined mode indication, is defined as token, declarer.
;; defined mode indication :
;; mode indication.
- ;; declarer or code :
- ;; declarer ; code.
(mode-declaration ("mode" mode-joined-definition))
(mode-joined-definition (mode-joined-definition "," mode-joined-definition)
(mode-definition))
- (mode-definition (mode-indication "=" declarer-or-code))
+ (mode-definition (mode-indication "-bold=-" declarer))
(mode-indication ("-bold-"))
- (declarer-or-code (declarer)
- (code))
;; Priority declarations
;; ---------------------
;; priority declaration :
@@ -578,10 +565,84 @@ with the equivalent upcased form."
(priority-declaration ("prio" priority-joined-definition))
(priority-joined-definition (priority-joined-definition "," priority-joined-definition)
(priority-definition))
- (priority-definition (operator "=" priority-unit))
+ (priority-definition (operator "-op=-" priority-unit))
(operator ("-oper-"))
(priority-unit ("1") ("2") ("3") ("4") ("5")
("6") ("7") ("8") ("9"))
+ ;; Operation declarations
+ ;; ----------------------
+ ;; operation declaration :
+ ;; operation token, operation joined definition.
+ ;; operation joined definition :
+ ;; (operation joined definition, and also token),
+ ;; operation definition.
+ ;; operation definition :
+ ;; operator, is defined as token, routine text.
+ ;; operator :
+ ;; defining operator.
+ (operation-declaration ("op" operation-joined-definition))
+ (operation-joined-definition (operation-joined-definition "," operation-joined-definition)
+ (operation-definition))
+ (operation-definition (operator "-op=-" routine-text)
+ (operator "-op=-" operator-indication)
+ (operator-indication "-op=-" routine-text)
+ (operator-indication "-op=-" operator-indication))
+ (operator-indication ("-bold-"))
+ ;; Declarers
+ ;; ---------
+ ;; declarer :
+ ;; nonproc declarer; procedure declarator.
+ ;; nonproc declarer :
+ ;; reference to declarator ; structured with declarator ;
+ ;; flexible rows of declarator ; rows of declarator ;
+ ;; union of declarator ; mode indication.
+ ;; reference to declarator :
+ ;; reference to token, declarer.
+ ;; structured with declarator :
+ ;; structure token, portrayer pack.
+ ;; portrayer pack :
+ ;; brief begin token, portrayer, brief end token.
+ ;; portrayer :
+ ;; common portrayer, (separate and also token, portrayer).
+ ;; common portrayer :
+ ;; declarer, dectag insert, joined definition of field.
+ ;; joined definition of field :
+ ;; (joined definition of fields, and also token), field selector.
+ ;; flexible rows of declarator :
+ ;; flexible token, declarer.
+ ;; rows of declarator :
+ ;; rower bracket, row insert, declarer.
+ ;; rower bracket :
+ ;; brief sub token, rower, brief bus token;
+ ;; style i sub token, rower, style i bus token.
+ ;; rower :
+ ;; (rower, and also token), row rower.
+ ;; rower part :
+ ;; (unit), up to token.
+ ;; procedure declarator :
+ ;; procedure token, formal procedure plan.
+ ;; formal procedure plan :
+ ;; (joined declarer pack, formals insert), declarer.
+ ;; joined declarer pack :
+ ;; brief begin token, joined declarer, brief end token.
+ ;; joined declarer :
+ ;; (joined declarer, and also token), declarer.
+ ;; union of declarator :
+ ;; union of token, joined declarer pack.
+ (declarer (nonproc-declarer)
+ (procedure-declarator))
+ (nonproc-declarer ("ref" declarer)
+ ("struct" portrayer-pack)
+ ;;(structured-with-declarator)
+ ;;(flexible-rows-of-declarator)
+ ;;(rows-of-declarator)
+ ;;(union-of-declarator)
+ (mode-indication)
+ ("-stdmode-"))
+ (portrayer-pack ("(" portrayer ")"))
+ (portrayer (portrayer "," portrayer)
+ (declarer "-dectag-")
+ (id))
;; Units
;; =====
;; unit :
@@ -708,7 +769,15 @@ with the equivalent upcased form."
;; Casts
;; -----
(cast (declarer "-cast-" enclosed-clause)))
- "Algol 68 BNF operator precedence grammar to use with SMIE")
+ "Algol 68 BNF operator precedence grammar to use with SMIE.
+
+This grammar has been adapted from the Algol 68+ operator precedence
+grammar described by L.G.L.T Meertens and J.C. van Vliet in their
+article \"An operator-priority grammar for Algol 68+\". The grammar is
+simplified to adapt it to the purpose of indentation, to work well with
+SMIE, and to denote Algol 68 as oppossed to Algol 68+, which is a
+superlanguage of Algol 68 that is capable of expressing the code for the
+standard prelude described in the Revised Report.")
(defvar a68--smie-grammar-upper
(smie-prec2->grammar
@@ -828,10 +897,25 @@ with the equivalent upcased form."
(forward-comment (point-max))
(let ((case-fold-search nil))
(cond
+ ;; Standard mode indicators.
+ ((looking-at (concat "\\<" (regexp-opt a68-std-modes-supper) "\\>"))
+ (goto-char (match-end 0))
+ "-stdmode-")
;; operator.
((posix-looking-at a68--oper-regexp)
(goto-char (match-end 0))
"-oper-")
+ ;; = can be an equal operator or an is-defined-token.
+ ((looking-at "=")
+ (let ((token (cond
+ ((looking-back "\\<[A-Z][A-Za-z_]+\\>[ \n\t]*")
+ "-bold=-")
+ ((looking-back (concat a68--oper-regexp "[ \n\t]*"))
+ "-op=-")
+ (t
+ "="))))
+ (goto-char (+ (point) 1))
+ token))
;; A bold-word may be a ssecca insert if it is preceded by a
;; joined list of bold words, preceded by access.
((looking-at "[A-Z][A-Za-z_]+")
@@ -953,11 +1037,26 @@ with the equivalent upcased form."
(forward-comment (- (point)))
(let ((case-fold-search nil))
(cond
+ ;; Standard mode indicators.
+ ((looking-back (concat "\\<" (regexp-opt a68-std-modes-supper) "\\>")
+ (pos-bol))
+ (goto-char (match-beginning 0))
+ "-stdmode-")
;; operator, so any nomad or monad.
((looking-back a68--oper-regexp
(pos-bol))
(goto-char (match-beginning 0))
"-oper-")
+ ((looking-back "=")
+ (let ((token (cond
+ ((looking-back "\\<[A-Z][A-Za-z_]+\\>[ \n\t]*=")
+ "-bold=-")
+ ((looking-back (concat a68--oper-regexp "[ \n\t]*="))
+ "-op=-")
+ (t
+ "="))))
+ (goto-char (- (point) 1))
+ token))
((looking-back "[A-Z][A-Za-z_]+" (pos-bol))
(goto-char (match-beginning 0))
(if (and (not (looking-at "[A-Z][A-Za-z_]+[ \t\n]*,"))
--
2.30.2
More information about the Algol68
mailing list