diff --git a/vm-ubuntu-24.04/p4-logo.png b/vm-ubuntu-24.04/p4-logo.png deleted file mode 100644 index cc36615ba..000000000 Binary files a/vm-ubuntu-24.04/p4-logo.png and /dev/null differ diff --git a/vm-ubuntu-24.04/p4-logo.png.license b/vm-ubuntu-24.04/p4-logo.png.license deleted file mode 100644 index 447195ddf..000000000 --- a/vm-ubuntu-24.04/p4-logo.png.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2018 Nate Foster - -SPDX-License-Identifier: Apache-2.0 diff --git a/vm-ubuntu-26.04/p4.vim b/vm-ubuntu-26.04/p4.vim new file mode 100644 index 000000000..d1707e7c0 --- /dev/null +++ b/vm-ubuntu-26.04/p4.vim @@ -0,0 +1,135 @@ +" SPDX-FileCopyrightText: 2014 Barefoot Networks, Inc. +" SPDX-License-Identifier: Apache-2.0 +" Vim syntax file +" Language: P4_16 +" Maintainer: Antonin Bas, Barefoot Networks Inc +" Latest Revision: 5 August 2014 +" Updated By: Gyanesh Patra, Unicamp University +" Latest Revision: 12 April 2016 +" Updated Again By: Robert MacDavid, Princeton University +" Latest Revision: 12 June 2017 + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Use case sensitive matching of keywords +syn case match + +syn keyword p4ObjectKeyword action apply control default +syn keyword p4ObjectKeyword enum extern exit +syn keyword p4ObjectKeyword header header_union +syn keyword p4ObjectKeyword match_kind +syn keyword p4ObjectKeyword package parser +syn keyword p4ObjectKeyword state struct switch size +syn keyword p4ObjectKeyword table transition tuple typedef +syn keyword p4ObjectKeyword verify + +" Tables +syn keyword p4ObjectAttributeKeyword key actions default_action entries +syn keyword p4ObjectAttributeKeyword implementation +" Counters and meters +syn keyword p4ObjectAttributeKeyword counters meters +" Var Attributes +syn keyword p4ObjectKeyword const in out inout + + +syn keyword p4Annotation @name @tableonly @defaultonly +syn keyword p4Annotation @globalname @atomic @hidden + + +syn keyword p4MatchTypeKeyword exact ternary lpm range + +syn keyword p4TODO contained FIXME TODO +syn match p4Comment '\/\/.*' contains=p4TODO +syn region p4BlockComment start='\/\*' end='\*\/' contains=p4TODO keepend + +syn match p4Preprocessor '#(include|define|undef|if|ifdef) .*$' +syn match p4Preprocessor '#(if|ifdef|ifndef|elif|else) .*$' +syn match p4Preprocessor '#(endif|defined|line|file) .*$' +syn match p4Preprocessor '#(error|warning) .*$' + +syn keyword p4Type bit bool int varbit void error + +" Integer Literals + +syn match p4Int '[0-9][0-9_]*' +syn match p4Indentifier '[A-Za-z_][A-Za-z0-9_]*' +syn match p4HexadecimalInt '0[Xx][0-9a-fA-F]\+' +syn match p4DecimalInt '0[dD][0-9_]\+' +syn match p4OctalInt '0[oO][0-7_]\+' +syn match p4BinaryInt '0[bB][01_]\+' + + +syn region p4SizedType start='(bit|int|varbit)\<' end='\>' +syn match p4UserType '[A-Za-z_][A-Za-z0-9_]*[_][t]\W' +syn keyword p4Operators and or not &&& mask + + +" Header Methods +syn keyword p4Primitive isValid setValid setInvalid +" Table Methods +syn keyword p4Primitive hit action_run +" Packet_in methods +syn keyword p4Primitive extract lookahead advance length +" Packet_out methods +syn keyword p4Primitive emit +" Known parser states +syn keyword p4Primitive accept reject +" Misc +syn keyword p4Primitive NoAction + + +syn keyword p4Conditional if else select +syn keyword p4Statement return + +" Don't Care +syn keyword p4Constant _ +" Error +syn keyword p4Constant NoError PacketTooShort NoMatch StackOutOfBounds +syn keyword p4Constant OverwritingHeader HeaderTooShort ParserTiimeout +" Boolean +syn keyword p4Boolean false true + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Apply highlight groups to syntax groups defined above +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_p4_syntax_inits") + if version <= 508 + let did_p4_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink p4ObjectKeyword Repeat + HiLink p4UserType Type + HiLink p4ObjectAttributeKeyword Keyword + HiLink p4TypeAttribute StorageClass + HiLink p4Annotation Special + HiLink p4MatchTypeKeyword Keyword + HiLink p4TODO Todo + HiLink p4Comment Comment + HiLink p4BlockComment Comment + HiLink p4Preprocessor PreProc + HiLink p4SizedType Type + HiLink p4Type Type + HiLink p4DecimalInt Number + HiLink p4HexadecimalInt Number + HiLink p4OctalInt Number + HiLink p4BinaryInt Number + HiLink p4Int Number + HiLink p4Operators Operator + HiLink p4Primitive Function + HiLink p4Conditional Conditional + HiLink p4Statement Statement + HiLink p4Constant Constant + HiLink p4Boolean Boolean + + delcommand HiLink +endif + +let b:current_syntax = "p4" diff --git a/vm-ubuntu-26.04/p4_16-mode.el b/vm-ubuntu-26.04/p4_16-mode.el new file mode 100644 index 000000000..b9db28bf0 --- /dev/null +++ b/vm-ubuntu-26.04/p4_16-mode.el @@ -0,0 +1,289 @@ +;;; p4_16-mode.el --- Support for the P4_16 programming language +;; SPDX-FileCopyrightText: 2016 Barefoot Networks, Inc. +;; SPDX-License-Identifier: Apache-2.0 + +;; Author: Vladimir Gurevich +;; Maintainer: Vladimir Gurevich +;; Created: 15 April 2017 +;; Version: 0.2 +;; Keywords: languages p4_16 +;; Homepage: https://p4.org + +;; This file is not part of GNU Emacs. + +;; This file is free software… + +;; This mode has preliminary support for P4_16. It covers the core language, +;; but it is not clear yet, how we can highlight the identifiers, defined +;; for a particular architecture. Core library definitions are included + +;; Placeholder for user customization code +(defvar p4_16-mode-hook nil) + +(defun p4_16-electric-brace (arg) + "Insert a brace." + (interactive "*P") + (self-insert-command (prefix-numeric-value arg)) + (save-excursion + (move-beginning-of-line nil) + (indent-for-tab-command))) + +;; Define the keymap (for now it is pretty much default) +(defvar p4_16-mode-map + (let ((map (make-keymap))) + (define-key map "\C-j" 'newline-and-indent) + (define-key map "{" 'p4_16-electric-brace) + (define-key map "}" 'p4_16-electric-brace) + (define-key map "\C-c\C-c" 'comment-region) + map) + "Keymap for P4_16 major mode") + +;; Syntactic HighLighting + +;; Main keywords (declarations and operators) +(setq p4_16-keywords + '("action" "apply" + "control" + "default" + "else" "enum" "extern" "exit" + "header" "header_union" + "if" + "match_kind" + "package" "parser" + "return" + "select" "state" "struct" "switch" + "table" "transition" "tuple" "typedef" "type" + "verify" + )) + +(setq p4_16-annotations + '("@name" "@metadata" "@alias" + )) + +(setq p4_16-attributes + '("const" "in" "inout" "out" + ;; Tables + "key" "actions" "default_action" "entries" "implementation" + "counters" "meters" + )) + +(setq p4_16-variables + '("packet_in" "packet_out" + )) + +(setq p4_16-operations + '("&&&" ".." "++" "?" ":")) + +(setq p4_16-constants + '( + ;;; Don't care + "_" + ;;; bool + "false" "true" + ;;; error + "NoError" "PacketTooShort" "NoMatch" "StackOutOfBounds" + "OverwritingHeader" "HeaderTooShort" "ParserTiimeout" + ;;; match_kind + "exact" "ternary" "lpm" "range" + ;;; We can add constants for supported architectures here + )) + +(setq p4_16-types + '("bit" "bool" "int" "varbit" "void" "error" + )) + +(setq p4_16-primitives + '( + ;;; Header methods + "isValid" "setValid" "setInvalid" + ;;; Table Methods + "hit" "action_run" + ;;; packet_in methods + "extract" "lookahead" "advance" "length" + ;;; packet_out methods + "emit" + ;;; Known parser states + "accept" "reject" + ;;; misc + "NoAction" + )) + +(setq p4_16-cpp + '("#include" + "#define" "#undef" + "#if" "#ifdef" "#ifndef" + "#elif" "#else" + "#endif" + "defined" + "#line" "#file")) + +(setq p4_16-cppwarn + '("#error" "#warning")) + +;; Optimize the strings +(setq p4_16-keywords-regexp (regexp-opt p4_16-keywords 'words)) +(setq p4_16-annotations-regexp (regexp-opt p4_16-annotations 1)) +(setq p4_16-attributes-regexp (regexp-opt p4_16-attributes 'words)) +(setq p4_16-variables-regexp (regexp-opt p4_16-variables 'words)) +(setq p4_16-operations-regexp (regexp-opt p4_16-operations 'words)) +(setq p4_16-constants-regexp (regexp-opt p4_16-constants 'words)) +(setq p4_16-types-regexp (regexp-opt p4_16-types 'words)) +(setq p4_16-primitives-regexp (regexp-opt p4_16-primitives 'words)) +(setq p4_16-cpp-regexp (regexp-opt p4_16-cpp 1)) +(setq p4_16-cppwarn-regexp (regexp-opt p4_16-cppwarn 1)) + + +;; create the list for font-lock. +;; each category of keyword is given a particular face +(defconst p4_16-font-lock-keywords + (list + (cons p4_16-cpp-regexp font-lock-preprocessor-face) + (cons p4_16-cppwarn-regexp font-lock-warning-face) + (cons p4_16-types-regexp font-lock-type-face) + (cons p4_16-constants-regexp font-lock-constant-face) + (cons p4_16-attributes-regexp font-lock-builtin-face) + (cons p4_16-variables-regexp font-lock-variable-name-face) + ;;; This is a special case to distinguish the method from the keyword + (cons "\\.apply" font-lock-function-name-face) + (cons p4_16-primitives-regexp font-lock-function-name-face) + (cons p4_16-operations-regexp font-lock-builtin-face) + (cons p4_16-keywords-regexp font-lock-keyword-face) + (cons p4_16-annotations-regexp font-lock-keyword-face) + (cons "\\(\\w*_t +\\)" font-lock-type-face) + (cons "[^A-Z_][A-Z] " font-lock-type-face) ;; Total hack for templates + (cons "<[A-Z, ]*>" font-lock-type-face) + (cons "\\(<[^>]+>\\)" font-lock-string-face) + (cons "\\([^_A-Za-z]\\([0-9]+w\\)?0x[0-9A-Fa-f]+\\)" font-lock-constant-face) + (cons "\\([^_A-Za-z]\\([0-9]+w\\)?0b[01]+\\)" font-lock-constant-face) + (cons "\\([^_A-Za-z][+-]?\\([0-9]+w\\)?[0-9]+\\)" font-lock-constant-face) + ;;(cons "\\(\\w*\\)" font-lock-variable-name-face) + ) + "Default Highlighting Expressions for P4_16") + +(defvar p4_16-mode-syntax-table + (let ((st (make-syntax-table))) + (modify-syntax-entry ?_ "w" st) + (modify-syntax-entry ?/ ". 124b" st) + (modify-syntax-entry ?* ". 23" st) + (modify-syntax-entry ?\n "> b" st) + st) + "Syntax table for p4_16-mode") + +;;; Indentation +(defvar p4_16-indent-offset 4 + "Indentation offset for `p4_16-mode'.") + +(defun p4_16-indent-line () + "Indent current line for any balanced-paren-mode'." + (interactive) + (let ((indent-col 0) + (indentation-increasers "[{(]") + (indentation-decreasers "[})]") + ) + (save-excursion + (beginning-of-line) + (condition-case nil + (while t + (backward-up-list 1) + (when (looking-at indentation-increasers) + (setq indent-col (+ indent-col p4_16-indent-offset)))) + (error nil))) + (save-excursion + (back-to-indentation) + (when (and (looking-at indentation-decreasers) + (>= indent-col p4_16-indent-offset)) + (setq indent-col (- indent-col p4_16-indent-offset)))) + (indent-line-to indent-col))) + +;;; Imenu support +(require 'imenu) + +;; regex to optionally match a name annotation, e.g. like this example: +;; @name(".process_replication.nop") +(setq opt-name-annotation-regex + "\\(@name[(] *\"[A-Za-z0-9_. ]+\" *[)]\\)\?") + +(setq p4_16-imenu-generic-expression + (list + (list "Controls" + (concat "^ *" + opt-name-annotation-regex + " *control +\\([A-Za-z0-9_]*\\)") + 2) + (list "Externs" + (concat "^ *" + opt-name-annotation-regex + " *extern +\\([A-Za-z0-9_]*\\) *\\([A-Za-z0-9_]*\\)") + 3) + (list "Tables" + (concat "^ *" + opt-name-annotation-regex + " *table +\\([A-Za-z0-9_]*\\)") + 2) + (list "Actions" + (concat "^ *" + opt-name-annotation-regex + " *action +\\([A-Za-z0-9_]*\\)") + 2) + (list "Parsers" + (concat "^ *" + opt-name-annotation-regex + " *parser +\\([A-Za-z0-9_]*\\)") + 2) + (list "Parser States" + (concat "^ *" + opt-name-annotation-regex + " *state +\\([A-Za-z0-9_]*\\)") + 2) + (list "Headers" + (concat "^ *" + opt-name-annotation-regex + " *header +\\([A-Za-z0-9_]*\\)") + 2) + (list "Header Unions" + (concat "^ *" + opt-name-annotation-regex + " *header_union +\\([A-Za-z0-9_]*\\)") + 2) + (list "Structs" + (concat "^ *" + opt-name-annotation-regex + " *struct +\\([A-Za-z0-9_]*\\)") + 2) + )) + +;;; Cscope Support +(require 'xcscope) + +;; The following version was generated by Google AI assistant with the +;; original version p4_16-mode as input, with the request that it be +;; updated to work with Emacs version 30. Further questioning about +;; how far back in Emacs versions this ought to work claimed it should +;; work back to Emacs 25 and Emacs 24.x for some x > 0. +;; Put everything together +;;;###autoload +(define-derived-mode p4_16-mode prog-mode "P4_16" + "Major mode for editing P4_16 programs." + :syntax-table p4_16-mode-syntax-table + + ;; Comments + (setq-local comment-start "// ") + (setq-local comment-end "") + + ;; Font-lock (Syntax Highlighting) + (setq font-lock-defaults '(p4_16-font-lock-keywords)) + + ;; Indentation + (setq-local indent-line-function #'p4_16-indent-line) + (setq-local indent-tabs-mode nil) + + ;; Imenu + (setq imenu-generic-expression p4_16-imenu-generic-expression) + (imenu-add-to-menubar "P4_16") + + ;; Cscope minor mode + (when (fboundp 'cscope-minor-mode) + (cscope-minor-mode))) + +;; The most important line +(provide 'p4_16-mode)