Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 9d1fd5d
  • /
  • parser.mly
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:95c44fc168bba3bb98c741f8c570e02083b1ab22
directory badge Iframe embedding
swh:1:dir:9d1fd5df45d8506277041474e22d5476fd33a31b
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
parser.mly
%{
let make_fun vars expr =
  List.fold_right (fun v e -> Syntax.Fun (v, e)) vars expr
%}
/* token definition */
%token LPAREN RPAREN
%token <int> NUMBER
%token <string> VAR
%token PLUS MINUS TIMES DIVIDE
%token FUN ARROW
%token SHIFT CONTROL SHIFT0 CONTROL0 RESET
%token EOF
/* End of File */

/* terminal symbol */
%type <Syntax.e> expr

/* start symbol */
%start expr

%nonassoc ARROW
%left PLUS MINUS
%left TIMES DIVIDE

/* Don't omitte '%%' */
%%

/* Write grammar rules */  
  
simple_expr:
| NUMBER
{ Syntax.Num ($1) }
| VAR
{ Syntax.Var ($1) }
| LPAREN expr RPAREN
{ $2 }

expr:
| simple_expr
{ $1 }
| expr PLUS expr
        { Syntax.Op ($1, Syntax.Plus, $3) }
| expr MINUS expr
        { Syntax.Op ($1, Syntax.Minus, $3) }
| expr TIMES expr
        { Syntax.Op ($1, Syntax.Times, $3) }
| expr DIVIDE expr
        { Syntax.Op ($1, Syntax.Divide, $3) }
| FUN VAR vars ARROW expr
{ Syntax.Fun ($2, make_fun $3 $5) }
| app
{ $1 }
| SHIFT VAR ARROW expr
{ Syntax.Shift ($2, $4) }
| CONTROL VAR ARROW expr
{ Syntax.Control ($2, $4) }
| SHIFT0 VAR ARROW expr
{ Syntax.Shift0 ($2, $4) }
| CONTROL0 VAR ARROW expr
{ Syntax.Control0 ($2, $4) }
| RESET simple_expr
{ Syntax.Reset ($2) }

vars:
|
  { [] }
| VAR vars
{ $1 :: $2 }

app:
| simple_expr simple_expr
{ Syntax.App ($1, $2) }
| app simple_expr
{ Syntax.App ($1, $2) }

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top