c2v icon indicating copy to clipboard operation
c2v copied to clipboard

unexpected token `*`, expecting `,` Translating `OpenDoas` "timestamp.c"

Open ThisNekoGuy opened this issue 3 years ago • 1 comments
trafficstars

Translating timestamp.c from the Arch Linux opendoas repo throws an "unexpected token" error.

v version: 0.3.0 3ad22eb

C to V translator 0.3.1
  translating timestamp.c     ... timestamp.v:34:24: error: unexpected token `*`, expecting `,`
   32 | fn strtoul( &i8,  &&u8,  int) u32
   33 | 
   34 | fn strtoul(__nptr Char *restrict, __endptr Char **restrict, __base int) u32
      |                        ^
   35 | 
   36 | fn strtoull( &i8,  &&u8,  int) i64

Internal vfmt error while formatting file: timestamp.v.
Encountered a total of: 1 errors.
 took   206 ms ; output .v file: timestamp.v
Translated   1 files in   206 ms.

Steps to reproduce:

  1. git clone https://github.com/Duncaen/OpenDoas/
  2. Enter the project directory
  3. Place this c2v.toml in the root project directory and the libopendoas directory:
[project]
uses_sdl = false
output_dirname = "c2v_out.dir"
additional_flags = "-I. -I.. -I../.. -I./libopenbsd"
  1. Run ./configure --with-timestamp
  2. Run v translate *

System Info: OS: Arch Linux x86_64

ThisNekoGuy avatar Aug 25 '22 00:08 ThisNekoGuy

This can also be reproduced by attempting to translate sudo, using the same versions (using sudo's default project configure settings):

c2v.toml

(Would be great if there was an official scaffolding tool to make doing this not a pain)

[project]
uses_sdl = false
output_dirname = "c2v_out.dir"
additional_flags = "-I. -I.. -I../.. -I../../.. -I../../../.. -I../../../../.. -I./src -I../src -I../../src -I../../../src -I../../../../src -I../../../../../src -I./include -I../include -I../../include -I../../../include -I../../../../include -I../../../../../include"
v translate *
C to V translator 0.3.1
"src" is a directory, processing all C files in it recursively...

  translating ./apparmor.c    ... Reformatted file: /mnt/extraStorage/Development/sudo/src/c2v_out.dir/apparmor.v
 took    22 ms ; output .v file: ./c2v_out.dir/apparmor.v
  translating ./conversation.c ... c2v_out.dir/conversation.v:6:22: error: unexpected token `*`, expecting `,`
    4 | fn vfprintf( &C.FILE,  &i8,  va_list) int
    5 | 
    6 | fn vfprintf(__s FILE *restrict, __format Char *restrict, __arg va_list) int
      |                      ^
    7 | 
    8 | fn fileno(__stream &C.FILE) int

Internal vfmt error while formatting file: /mnt/extraStorage/Development/sudo/src/./c2v_out.dir/conversation.v.
Encountered a total of: 1 errors.
 took   249 ms ; output .v file: ./c2v_out.dir/conversation.v
  translating ./copy_file.c   ... 

Unhandled expr() node {PredefinedExpr} (ast line nr node.ast_line_nr "./copy_file.c"):
{PredefinedExpr} name:"__func__" value:"" loc:Loc{
    offset: 0
    file: ''
    line: 0
    col: 0
    tok_len: 0
    included_from: IncludedFrom{
        file: ''
    }
    spelling_loc: IncludedFrom{
        file: ''
    }
    range: Range{
        begin: Begin{
            spelling_loc: IncludedFrom{
                file: ''
            }
        }
    }
}  #c: 1 typ:"const char[17]"
/tmp/v_1000/../../../../../../usr/lib/vlang/vlib/builtin/builtin.c.v:639: at print_backtrace: Backtrace
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:1778: by main__C2V_expr
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:1653: by main__C2V_expr
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:1661: by main__C2V_expr
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:364: by main__C2V_fn_call
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:1681: by main__C2V_expr
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:1031: by main__C2V_statement
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:982: by main__C2V_statements
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:480: by main__C2V_fn_decl
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:2047: by main__C2V_top_level
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:2004: by main__C2V_translate_file
/tmp/v_1000/../../../../../../home/neko-san/.vmodules/c2v/c2v.v:1932: by main__main
/tmp/v_1000/../../../../../../tmp/v_1000/c2v.tmp.c:17582: by main
C2V command: '/home/neko-san/.vmodules/c2v/c2v' 'aclocal.m4' 'autogen.sh' 'c2v.toml' 'config.h' 'config.h.in' 'config.log' 'config.status' 'configure' 'configure-help.txt' 'configure.ac' 'docker' 'docs' 'etc' 'examples' 'include' 'INSTALL.configure' 'INSTALL.md' 'lib' 'libtool' 'LICENSE.md' 'logsrvd' 'm4' 'Makefile' 'Makefile.in' 'MANIFEST' 'NEWS' 'pathnames.h' 'pathnames.h.in' 'plugins' 'po' 'README.LDAP.md' 'README.md' 'scripts' 'src'
C2V failed to translate the C files. Please report it via GitHub.

ThisNekoGuy avatar Aug 25 '22 01:08 ThisNekoGuy