aboutsummaryrefslogtreecommitdiff
path: root/source/main.elna
blob: f6b213f843250b982676d1e7cfc0ee04957e8cd1 (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
(* This Source Code Form is subject to the terms of the Mozilla Public License,
  v. 2.0. If a copy of the MPL was not distributed with this file, You can
  obtain one at https://mozilla.org/MPL/2.0/. *)
program()
import sys.posix.stdio, std, elna.lexer, elna.ast, elna.parser

var
  sample_source_text := "program() Here.a few (* documentation block *) or #size if '\\n' `У` \"некоторая строка\" 23 -- End line comment\0"

begin
  elna_lexer_transitions();

  block local_main
  var
    global_cursor := elna_lexer_cursor_make(sample_source_text)
    parser := elna_parser_make(@global_cursor)
    tree := elna_parser_program(@parser)
  begin
    if std_slist_empty(@parser.diagnostics) then
      fputs("int main(){ return 0; }\n\0".ptr, stdout_())
    else
      fputs("Parsing failed.\n\0".ptr, stderr_())
    end;
  end
end.