View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000616 | file | General | public | 2025-01-17 14:46 | 2025-01-17 14:46 |
Reporter | jamesodhunt | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Summary | 0000616: Recognise yacc(1) / bison(1) grammar files | ||||
Description | The `file(1)` command doesn't currently recognise yacc/bison grammar files. The minimal attached patch adds basic support. | ||||
Steps To Reproduce | Before this patch is applied (current `file(1)` behaviour): ```bash $ file *.y a.y: ASCII text b.y: C source, ASCII text c.y: ASCII text d.y: C source, ASCII text e.y: C source, ASCII text ``` After this patch is applied: ```bash a.y: yacc(1) or bison(1) grammar file, ASCII text b.y: yacc(1) or bison(1) grammar file with C prologue with token declarations with associativity/precedence declarations, ASCII text c.y: yacc(1) or bison(1) grammar file with token declarations, ASCII text d.y: yacc(1) or bison(1) grammar file with C prologue with token declarations, ASCII text e.y: yacc(1) or bison(1) grammar file with C prologue with token declarations with associativity/precedence declarations, ASCII text ``` | ||||
Tags | No tags attached. | ||||
|
0001-magic-Add-detection-for-yacc-bison.patch (2,131 bytes)
From e02107e1b7edfdf23d2f27003daf78a4039068b2 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" <jamesodhunt@gmail.com> Date: Fri, 17 Jan 2025 14:37:46 +0000 Subject: [PATCH] magic: Add detection for yacc / bison Recognised `yacc(1)` / `bison(1)` `*.y` grammar files. For information on the grammar file format, see: ```sh $ info bison grammar ``` > **Note:** > > If you are running on Debian, Ubuntu or a derivative, > you may need to install the `bison(1)` documentation > package for the above to work: > > ```sh > $ sudo apt -y install bison-doc > ``` Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com> --- magic/Magdir/yacc | 24 ++++++++++++++++++++++++ magic/Makefile.am | 1 + 2 files changed, 25 insertions(+) create mode 100644 magic/Magdir/yacc diff --git a/magic/Magdir/yacc b/magic/Magdir/yacc new file mode 100644 index 00000000..7aaac663 --- /dev/null +++ b/magic/Magdir/yacc @@ -0,0 +1,24 @@ +#------------------------------------------------------------------------------- +# file(1) magic for yacc(1) / bison(1) LALR(1) parser generator source files. +# +# For information on the grammar file format, run the `info(1)` command as: +# +# ```sh +# $ info bison grammar +# ``` +# +# Note: +# +# If you are running on Debian, Ubuntu or a derivative, you may need +# to install the `bison(1)` documentation package for the above to work: +# +# ```sh +# $ sudo apt -y install bison-doc +# ``` +#------------------------------------------------------------------------------- + +0 regex %%\n yacc(1) or bison(1) grammar file +!:ext y +>0 regex %\\{ with C prologue +>0 regex %token with token declarations +>0 regex %(left|right|nonassoc|precedence) with associativity/precedence declarations diff --git a/magic/Makefile.am b/magic/Makefile.am index e0f90343..3895a215 100644 --- a/magic/Makefile.am +++ b/magic/Makefile.am @@ -348,6 +348,7 @@ $(MAGIC_FRAGMENT_DIR)/xenix \ $(MAGIC_FRAGMENT_DIR)/xilinx \ $(MAGIC_FRAGMENT_DIR)/xo65 \ $(MAGIC_FRAGMENT_DIR)/xwindows \ +$(MAGIC_FRAGMENT_DIR)/yacc \ $(MAGIC_FRAGMENT_DIR)/yara \ $(MAGIC_FRAGMENT_DIR)/zfs \ $(MAGIC_FRAGMENT_DIR)/zilog \ -- 2.48.1 |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-01-17 14:46 | jamesodhunt | New Issue | |
2025-01-17 14:46 | jamesodhunt | File Added: 0001-magic-Add-detection-for-yacc-bison.patch |