aboutsummaryrefslogtreecommitdiff
path: root/src/bnf-generate.c
blob: 267dc352cdfd3231cf6f39a7cc9d742f5f2b85d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdlib.h>
#include <stdio.h>

int
main (void)
{
  printf ("         <syntax> ::= 'https://docs.google.com/' <type> '/d/' <id> <opt-action> <opt-parameters>\n");

  printf ("           <type> ::= 'document' | 'spreadsheet' | 'presentation'\n");

  printf ("             <id> ::=");
  for (int i = 0; i < 33; ++i) {
    printf (" <id-char>");
  } printf (" |");
  for (int i = 0; i < 44; ++i) {
    printf (" <id-char>");
  } printf ("\n");

  printf ("        <id-char> ::= ");
  for (char c = '0'; c <= '9'; ++c)
    printf ("'%c' | ", c);
  for (char c = 'a'; c <= 'z'; ++c)
    printf ("'%c' | ", c);
  for (char c = 'A'; c <= 'Z'; ++c) {
    printf ("'%c' | ", c);
  } printf ("'-' | '_'\n");

  printf ("     <opt-action> ::= '' | '/' | '/copy' | '/edit' | '/export' | '/view' | '/preview'\n");

  printf (" <opt-parameters> ::= '' | '?' <parameter-chars>\n");

  printf ("<parameter-chars> ::= '' | <parameter-char> <parameter-chars>\n");

  printf (" <parameter-char> ::= ");
  for (char c = '!'; c <= '~'; ++c) {
    if (c != '!') printf (" | ");
    printf (c != '\'' ? "'%c'" : "\"%c\"", c);
  } printf ("\n");

  return EXIT_SUCCESS;
}