Skip to content

Commit

Permalink
Add Oberon language (github-linguist#4645)
Browse files Browse the repository at this point in the history
* Add Oberon language and .ob2 sample

.mod and .def extensions need to be deferred

* Update grammar list

---------

Co-authored-by: Colin Seymour <[email protected]>
  • Loading branch information
idrougge and lildude authored Mar 13, 2024
1 parent 82e2cc3 commit 4a807b4
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4751,6 +4751,13 @@ OCaml:
- ocamlscript
tm_scope: source.ocaml
language_id: 255
Oberon:
type: programming
extensions:
- ".ob2"
tm_scope: source.modula2
ace_mode: text
language_id: 677210597
ObjDump:
type: data
extensions:
Expand Down
124 changes: 124 additions & 0 deletions samples/Oberon/beNull.ob2
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
(** ƒ®«®¢­®© ¬®¤ã«ì á¡®à  áâ â¨á⨪¨ *)

MODULE beNull; (* Empty back-end *)

IMPORT pc :=pcK,
xfs:=xiFiles,
env:=xiEnv,
SYSTEM;

TYPE
CODE = POINTER TO code_rec;
code_rec = RECORD (pc.code_rec)
END;

PROCEDURE val(x: LONGINT): pc.VALUE;
VAR v: pc.VALUE;
BEGIN
v:=pc.value.new(env.null_pos,pc.ZZ_type);
v.set_integer(x);
RETURN v;
END val;

(*PROCEDURE rval(x: LONGREAL): pc.VALUE;
VAR v: pc.VALUE;
BEGIN
v:=pc.value.new(env.null_pos,pc.RR_type);
v.set_real(x);
RETURN v;
END rval;
*)
PROCEDURE (c: CODE) ini;
BEGIN
c.bits_per_loc :=8;
c.locs_per_word:=4;

c.FRETs:=pc.REALs+pc.WHOLEs+pc.CPLXs+
pc.TY_SET{pc.ty_boolean,pc.ty_enum,pc.ty_range,pc.ty_char}+
pc.TY_SET{pc.ty_array,pc.ty_loc}+
pc.TY_SET{pc.ty_opaque,pc.ty_pointer}+
pc.TY_SET{pc.ty_protection,pc.ty_proctype,pc.ty_record};

(* c.max_loc :=val(ASH(1,c.bits_per_loc)-1);
c.max_sint:=val(MAX(SHORTINT));
c.max_int :=val(MAX(INTEGER));
c.max_lint:=val(MAX(LONGINT));
c.min_sint:=val(MIN(SHORTINT));
c.min_int :=val(MIN(INTEGER));
c.min_lint:=val(MIN(LONGINT));
c.max_scard:=val(0);
c.max_scard.binary(pc.sb_minus,c.max_sint,c.min_sint);
c.max_card :=val(0);
c.max_card .binary(pc.sb_minus,c.max_int,c.min_int);
c.max_lcard:=val(0);
c.max_lcard.binary(pc.sb_minus,c.max_lint,c.min_lint);
c.max_char :=val(255);
c.max_real :=rval(MAX(REAL));
c.max_lreal:=rval(MAX(LONGREAL));
c.min_real :=rval(MIN(REAL));
c.min_lreal:=rval(MIN(LONGREAL));
*)
c.max_dim:=10;
c.max_ext_lev:=25;
c.def_storage:=TRUE;
c.max_sysflag:=pc.flag_c;

c.int16:=FALSE;
c.index16:=FALSE;
c.address16:=TRUE;
c.max_index:=val(MAX(LONGINT));
END ini;

PROCEDURE (c: CODE) exi;
BEGIN
END exi;

PROCEDURE (c: CODE) gen_code(cu: pc.Mno; main: BOOLEAN);
BEGIN
END gen_code;

PROCEDURE (c: CODE) allocate(cu: pc.Mno; main: BOOLEAN; src_time: SYSTEM.CARD32);
BEGIN
END allocate;

PROCEDURE (c: CODE) get_size(op: pc.SUB_MODE; t: pc.STRUCT): LONGINT;
BEGIN
RETURN -1;
END get_size;

PROCEDURE (c: CODE) inp_object(file: xfs.SymFile; o: pc.OBJECT; id: LONGINT);
BEGIN
END inp_object;

PROCEDURE (c: CODE) skip_object(file: xfs.SymFile; id: LONGINT);
BEGIN
END skip_object;

PROCEDURE (c: CODE) inp_struct(file: xfs.SymFile; s: pc.STRUCT; id: LONGINT);
BEGIN
END inp_struct;

PROCEDURE (c: CODE) skip_struct(file: xfs.SymFile; id: LONGINT);
BEGIN
END skip_struct;

PROCEDURE Set*;
VAR code: CODE;
BEGIN
env.config.NewOption("GENSTAT",FALSE,SYSTEM.VAL(env.CompilerOption,-1));
env.config.NewOption("GENSTATONLY",FALSE,SYSTEM.VAL(env.CompilerOption,-1));
env.config.NewEquation("STATEXT");
env.config.SetEquation("STATEXT","0st");
NEW(code);
pc.code:=code;
code.sym_ident:=pc.sym_C;
code.valid_idents := { pc.sym_C - pc.sym_base
, pc.sym_native - pc.sym_base
, pc.sym_native + 1 - pc.sym_base };
code.vers:="NULL";
env.config.Equation("OBJEXT",code.code_ext);
END Set;

END beNull.
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **OASv3-json:** [Nixinova/NovaGrammars](https://github.com/Nixinova/NovaGrammars)
- **OASv3-yaml:** [atom/language-yaml](https://github.com/atom/language-yaml)
- **OCaml:** [textmate/ocaml.tmbundle](https://github.com/textmate/ocaml.tmbundle)
- **Oberon:** [harogaston/Sublime-Modula-2](https://github.com/harogaston/Sublime-Modula-2)
- **ObjDump:** [nanoant/assembly.tmbundle](https://github.com/nanoant/assembly.tmbundle)
- **Object Data Instance Notation:** [Alhadis/language-etc](https://github.com/Alhadis/language-etc)
- **ObjectScript:** [intersystems-community/ObjectScript.tmBundle](https://github.com/intersystems-community/ObjectScript.tmBundle)
Expand Down

0 comments on commit 4a807b4

Please sign in to comment.