diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-17 17:38:57 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-17 17:38:57 +0000 |
commit | 73e70e48560ca6a90ff6854d12fe0be46c825015 (patch) | |
tree | 6ad455e02075b30200c574c190d66c14f85fbec7 /c_parser | |
parent | 95293c6e1c24a04a1d3659e987ad505f1ff77387 (diff) | |
download | Compiler-73e70e48560ca6a90ff6854d12fe0be46c825015.tar.gz Compiler-73e70e48560ca6a90ff6854d12fe0be46c825015.zip |
Fixed case for empty param list in function
Diffstat (limited to 'c_parser')
-rw-r--r-- | c_parser/include/ast_function.hpp | 2 | ||||
-rw-r--r-- | c_parser/src/c_parser.y | 3 | ||||
-rw-r--r-- | c_parser/test/out/02.diff.txt | 8 | ||||
-rw-r--r-- | c_parser/test/out/02.stderr.txt | 1 | ||||
-rw-r--r-- | c_parser/test/out/02.stdout.xml | 7 |
5 files changed, 11 insertions, 10 deletions
diff --git a/c_parser/include/ast_function.hpp b/c_parser/include/ast_function.hpp index 1086f49..085957c 100644 --- a/c_parser/include/ast_function.hpp +++ b/c_parser/include/ast_function.hpp @@ -33,6 +33,8 @@ private: mutable std::vector<const ast_Base*> param_list; public: + ast_ParamList() {} + ast_ParamList(const ast_Base* param) { param_list.push_back(param); } diff --git a/c_parser/src/c_parser.y b/c_parser/src/c_parser.y index 6d5db38..86594aa 100644 --- a/c_parser/src/c_parser.y +++ b/c_parser/src/c_parser.y @@ -52,7 +52,8 @@ EXT_DECLARATION : DECLARATION { $$ = $1; } FUNC_DEF : DECLARATION_SPEC T_IDENTIFIER T_LRB PARAMETER_LIST T_RRB COMPOUND_STATEMENT { $$ = new ast_Function(*$2, $4, $6); } ; -PARAMETER_LIST : PARAMETER { $$ = new ast_ParamList($1); } +PARAMETER_LIST : { $$ = new ast_ParamList(); } + | PARAMETER { $$ = new ast_ParamList($1); } | PARAMETER_LIST T_CMA PARAMETER { $$->push($3); } ; diff --git a/c_parser/test/out/02.diff.txt b/c_parser/test/out/02.diff.txt index 09321ae..e69de29 100644 --- a/c_parser/test/out/02.diff.txt +++ b/c_parser/test/out/02.diff.txt @@ -1,8 +0,0 @@ -1,7d0 -< <?xml version="1.0"?> -< <Program> -< <Function id="f"> -< <Scope> -< </Scope> -< </Function> -< </Program> diff --git a/c_parser/test/out/02.stderr.txt b/c_parser/test/out/02.stderr.txt index 6200509..e69de29 100644 --- a/c_parser/test/out/02.stderr.txt +++ b/c_parser/test/out/02.stderr.txt @@ -1 +0,0 @@ -Parse error : syntax error diff --git a/c_parser/test/out/02.stdout.xml b/c_parser/test/out/02.stdout.xml index e69de29..bc37d7a 100644 --- a/c_parser/test/out/02.stdout.xml +++ b/c_parser/test/out/02.stdout.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Program> +<Function id="f"> +<Scope> +</Scope> +</Function> +</Program> |