branch: externals/a68-mode commit 1e71d0c67437e6078fd677b0ccb55ccd929ad1fd Author: Jose E. Marchesi <jose.march...@oracle.com> Commit: Jose E. Marchesi <jose.march...@oracle.com>
Revert "More work in the grammar" This reverts commit 5458a4ff9aa0a06977bf6bd5228240315bf2b299. --- a68-mode.el | 137 +++++++++--------------------------------------------------- 1 file changed, 19 insertions(+), 118 deletions(-) diff --git a/a68-mode.el b/a68-mode.el index f658ad8ec1..3607479552 100644 --- a/a68-mode.el +++ b/a68-mode.el @@ -354,7 +354,7 @@ with the equivalent upcased form." (defconst a68--bnf-grammar '((id) - (field-selector) + (declarer) (ids (id "-anchor-" id)) (fields (fields "," fields) (ids)) @@ -364,7 +364,7 @@ with the equivalent upcased form." (fargs (fargs "," fargs) (modal) (exp)) - (modal ("-mode-" mode-indication)) + (modal ("-mode-" type-decl**)) (specs (specs "," specs) (spec)) (exp (ids) @@ -372,6 +372,15 @@ 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) @@ -544,14 +553,18 @@ 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. + ;; defined mode indication, is defined as token, declarer or code. ;; 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 "-bold=-" declarer)) + (mode-definition (mode-indication "=" declarer-or-code)) (mode-indication ("-bold-")) + (declarer-or-code (declarer) + (code)) ;; Priority declarations ;; --------------------- ;; priority declaration : @@ -565,84 +578,10 @@ 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 "-op=-" priority-unit)) + (priority-definition (operator "=" 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 : @@ -769,15 +708,7 @@ with the equivalent upcased form." ;; Casts ;; ----- (cast (declarer "-cast-" enclosed-clause))) - "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.") + "Algol 68 BNF operator precedence grammar to use with SMIE") (defvar a68--smie-grammar-upper (smie-prec2->grammar @@ -897,25 +828,10 @@ standard prelude described in the Revised Report.") (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_]+") @@ -1037,26 +953,11 @@ standard prelude described in the Revised Report.") (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]*,"))