From 440ec14e6f98603e5dce178e083dd932825ae506 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 19 Jan 2015 21:43:35 +0100 Subject: [PATCH] [DEV] change heritage order of lexer --- eci/Interpreter.h | 150 +++++++ eci/Lexer.cpp | 13 +- eci/Lexer.h | 34 +- eci/Type.h | 42 +- eci/Variable.h | 3 +- eci/lang/ParserCpp.cpp | 8 +- eci/lang/ParserCpp.h | 3 +- eci/lang/ParserJS.cpp | 8 +- eci/lang/ParserJS.h | 3 +- tests/00_assignment.c | 13 - tests/00_assignment.expect | 3 - tests/01_comment.c | 11 - tests/01_comment.expect | 7 - tests/02_printf.c | 13 - tests/02_printf.expect | 15 - tests/03_struct.c | 21 - tests/03_struct.expect | 2 - tests/04_for.c | 10 - tests/04_for.expect | 10 - tests/05_array.c | 16 - tests/05_array.expect | 10 - tests/06_case.c | 24 -- tests/06_case.expect | 8 - tests/07_function.c | 25 -- tests/07_function.expect | 4 - tests/08_while.c | 19 - tests/08_while.expect | 11 - tests/09_do_while.c | 20 - tests/09_do_while.expect | 11 - tests/10_pointer.c | 37 -- tests/10_pointer.expect | 7 - tests/11_precedence.c | 38 -- tests/11_precedence.expect | 15 - tests/12_hashdefine.c | 10 - tests/12_hashdefine.expect | 2 - tests/13_integer_literals.c | 16 - tests/13_integer_literals.expect | 5 - tests/14_if.c | 17 - tests/14_if.expect | 2 - tests/15_recursion.c | 16 - tests/15_recursion.expect | 10 - tests/16_nesting.c | 16 - tests/16_nesting.expect | 18 - tests/17_enum.c | 24 -- tests/17_enum.expect | 4 - tests/18_include.c | 7 - tests/18_include.expect | 3 - tests/18_include.h | 1 - tests/19_pointer_arithmetic.c | 24 -- tests/19_pointer_arithmetic.expect | 3 - tests/20_pointer_comparison.c | 20 - tests/20_pointer_comparison.expect | 6 - tests/21_char_array.c | 29 -- tests/21_char_array.expect | 7 - tests/22_floating_point.c | 45 --- tests/22_floating_point.expect | 16 - tests/23_type_coercion.c | 49 --- tests/23_type_coercion.expect | 15 - tests/24_math_library.c | 23 -- tests/24_math_library.expect | 18 - tests/25_quicksort.c | 80 ---- tests/25_quicksort.expect | 2 - tests/26_character_constants.c | 13 - tests/26_character_constants.expect | 8 - tests/27_sizeof.c | 12 - tests/27_sizeof.expect | 3 - tests/28_strings.c | 41 -- tests/28_strings.expect | 19 - tests/29_array_address.c | 8 - tests/29_array_address.expect | 1 - tests/30_hanoi.c | 125 ------ tests/30_hanoi.expect | 71 ---- tests/31_args.c | 12 - tests/31_args.expect | 6 - tests/32_led.c | 264 ------------- tests/32_led.expect | 4 - tests/33_ternary_op.c | 10 - tests/33_ternary_op.expect | 10 - tests/34_array_assignment.c | 18 - tests/34_array_assignment.expect | 2 - tests/35_sizeof.c | 9 - tests/35_sizeof.expect | 2 - tests/36_array_initialisers.c | 16 - tests/36_array_initialisers.expect | 20 - tests/37_sprintf.c | 12 - tests/37_sprintf.expect | 20 - tests/38_multiple_array_index.c | 29 -- tests/38_multiple_array_index.expect | 4 - tests/39_typedef.c | 26 -- tests/39_typedef.expect | 3 - tests/40_stdio.c | 47 --- tests/40_stdio.expect | 27 -- tests/41_hashif.c | 80 ---- tests/41_hashif.expect | 6 - tests/42_function_pointer.c | 15 - tests/43_void_param.c | 10 - tests/43_void_param.expect | 1 - tests/44_scoped_declarations.c | 12 - tests/44_scoped_declarations.expect | 1 - tests/45_empty_for.c | 16 - tests/45_empty_for.expect | 10 - tests/46_grep.c | 562 --------------------------- tests/47_switch_return.c | 23 -- tests/47_switch_return.expect | 4 - tests/48_nested_break.c | 24 -- tests/48_nested_break.expect | 1 - tests/49_bracket_evaluation.c | 21 - tests/49_bracket_evaluation.expect | 1 - tests/50_logical_second_arg.c | 27 -- tests/50_logical_second_arg.expect | 20 - tests/51_static.c | 26 -- tests/51_static.expect | 8 - tests/52_unnamed_enum.c | 24 -- tests/52_unnamed_enum.expect | 9 - tests/54_goto.c | 52 --- tests/54_goto.expect | 8 - tests/55_section.c | 12 - tests/Makefile | 73 ---- tests/cpp/000-declare_variable.cpp | 3 + tests/js/000-declare_variable.js | 3 + 120 files changed, 226 insertions(+), 2770 deletions(-) delete mode 100644 tests/00_assignment.c delete mode 100644 tests/00_assignment.expect delete mode 100644 tests/01_comment.c delete mode 100644 tests/01_comment.expect delete mode 100644 tests/02_printf.c delete mode 100644 tests/02_printf.expect delete mode 100644 tests/03_struct.c delete mode 100644 tests/03_struct.expect delete mode 100644 tests/04_for.c delete mode 100644 tests/04_for.expect delete mode 100644 tests/05_array.c delete mode 100644 tests/05_array.expect delete mode 100644 tests/06_case.c delete mode 100644 tests/06_case.expect delete mode 100644 tests/07_function.c delete mode 100644 tests/07_function.expect delete mode 100644 tests/08_while.c delete mode 100644 tests/08_while.expect delete mode 100644 tests/09_do_while.c delete mode 100644 tests/09_do_while.expect delete mode 100644 tests/10_pointer.c delete mode 100644 tests/10_pointer.expect delete mode 100644 tests/11_precedence.c delete mode 100644 tests/11_precedence.expect delete mode 100644 tests/12_hashdefine.c delete mode 100644 tests/12_hashdefine.expect delete mode 100644 tests/13_integer_literals.c delete mode 100644 tests/13_integer_literals.expect delete mode 100644 tests/14_if.c delete mode 100644 tests/14_if.expect delete mode 100644 tests/15_recursion.c delete mode 100644 tests/15_recursion.expect delete mode 100644 tests/16_nesting.c delete mode 100644 tests/16_nesting.expect delete mode 100644 tests/17_enum.c delete mode 100644 tests/17_enum.expect delete mode 100644 tests/18_include.c delete mode 100644 tests/18_include.expect delete mode 100644 tests/18_include.h delete mode 100644 tests/19_pointer_arithmetic.c delete mode 100644 tests/19_pointer_arithmetic.expect delete mode 100644 tests/20_pointer_comparison.c delete mode 100644 tests/20_pointer_comparison.expect delete mode 100644 tests/21_char_array.c delete mode 100644 tests/21_char_array.expect delete mode 100644 tests/22_floating_point.c delete mode 100644 tests/22_floating_point.expect delete mode 100644 tests/23_type_coercion.c delete mode 100644 tests/23_type_coercion.expect delete mode 100644 tests/24_math_library.c delete mode 100644 tests/24_math_library.expect delete mode 100644 tests/25_quicksort.c delete mode 100644 tests/25_quicksort.expect delete mode 100644 tests/26_character_constants.c delete mode 100644 tests/26_character_constants.expect delete mode 100644 tests/27_sizeof.c delete mode 100644 tests/27_sizeof.expect delete mode 100644 tests/28_strings.c delete mode 100644 tests/28_strings.expect delete mode 100644 tests/29_array_address.c delete mode 100644 tests/29_array_address.expect delete mode 100644 tests/30_hanoi.c delete mode 100644 tests/30_hanoi.expect delete mode 100644 tests/31_args.c delete mode 100644 tests/31_args.expect delete mode 100644 tests/32_led.c delete mode 100644 tests/32_led.expect delete mode 100644 tests/33_ternary_op.c delete mode 100644 tests/33_ternary_op.expect delete mode 100644 tests/34_array_assignment.c delete mode 100644 tests/34_array_assignment.expect delete mode 100644 tests/35_sizeof.c delete mode 100644 tests/35_sizeof.expect delete mode 100644 tests/36_array_initialisers.c delete mode 100644 tests/36_array_initialisers.expect delete mode 100644 tests/37_sprintf.c delete mode 100644 tests/37_sprintf.expect delete mode 100644 tests/38_multiple_array_index.c delete mode 100644 tests/38_multiple_array_index.expect delete mode 100644 tests/39_typedef.c delete mode 100644 tests/39_typedef.expect delete mode 100644 tests/40_stdio.c delete mode 100644 tests/40_stdio.expect delete mode 100644 tests/41_hashif.c delete mode 100644 tests/41_hashif.expect delete mode 100644 tests/42_function_pointer.c delete mode 100644 tests/43_void_param.c delete mode 100644 tests/43_void_param.expect delete mode 100644 tests/44_scoped_declarations.c delete mode 100644 tests/44_scoped_declarations.expect delete mode 100644 tests/45_empty_for.c delete mode 100644 tests/45_empty_for.expect delete mode 100644 tests/46_grep.c delete mode 100644 tests/47_switch_return.c delete mode 100644 tests/47_switch_return.expect delete mode 100644 tests/48_nested_break.c delete mode 100644 tests/48_nested_break.expect delete mode 100644 tests/49_bracket_evaluation.c delete mode 100644 tests/49_bracket_evaluation.expect delete mode 100644 tests/50_logical_second_arg.c delete mode 100644 tests/50_logical_second_arg.expect delete mode 100644 tests/51_static.c delete mode 100644 tests/51_static.expect delete mode 100644 tests/52_unnamed_enum.c delete mode 100644 tests/52_unnamed_enum.expect delete mode 100644 tests/54_goto.c delete mode 100644 tests/54_goto.expect delete mode 100644 tests/55_section.c delete mode 100644 tests/Makefile create mode 100644 tests/cpp/000-declare_variable.cpp create mode 100644 tests/js/000-declare_variable.js diff --git a/eci/Interpreter.h b/eci/Interpreter.h index 8004be4..aa42485 100644 --- a/eci/Interpreter.h +++ b/eci/Interpreter.h @@ -14,6 +14,156 @@ #include namespace eci { + namespace interpreter { + enum type { + typeBlock, //!< block area definition + typeType, //!< type definition + typeVariable, //!< new variable use + typeVariableDeclaration, //!< new variable definition + typeFunction, //!< function definition + typeClass, //!< Class definition + typeNamespace, //!< Namespace definition + typeCondition, //!< Classicle condition (with else) + typeFor, //!< classicle C cycle (init, inc, condition) + typeWhile, //!< Call a cycle (option action previous condition or condition previous action) + typeOperator, //!< Call operator "xx" ex : "*" "++" "=" "==" + typeReserveId = 5000, + }; + class Element : public std::enable_shared_from_this { + protected: + int32_t m_tockenId; + public: + int32_t getTockenId() { + return m_tockenId; + } + public: + Element(int32_t _tockenId=-1) : + m_tockenId(_tockenId) { + + } + virtual ~Element() {} + }; + class Block : public Element { + protected: + std::vector> m_actions; + public: + Block() : + Element(interpreter::typeBlock) { + + } + virtual ~Block() {} + }; + class Type : public Element { + protected: + + public: + Type() : + Element(interpreter::typeType) { + + } + virtual ~Type() {} + }; + class Variable : public Element { + protected: + + public: + Variable() : + Element(interpreter::typeVariable) { + + } + virtual ~Variable() {} + }; + class VariableDeclaration : public Element { + protected: + + public: + VariableDeclaration() : + Element(interpreter::typeVariableDeclaration) { + + } + virtual ~VariableDeclaration() {} + }; + class Function : public Element { + protected: + + public: + Function() : + Element(interpreter::typeFunction) { + + } + virtual ~Function() {} + }; + class Class : public Element { + protected: + + public: + Class() : + Element(interpreter::typeClass) { + + } + virtual ~Class() {} + }; + class Namespace : public Element { + protected: + + public: + Namespace() : + Element(interpreter::typeNamespace) { + + } + virtual ~Namespace() {} + }; + class Condition : public Element { + protected: + std::shared_ptr m_condition; + std::shared_ptr m_block; + std::shared_ptr m_blockElse; + public: + Condition() : + Element(interpreter::typeCondition) { + + } + virtual ~Condition() {} + + }; + class For : public Element { + protected: + std::shared_ptr m_init; + std::shared_ptr m_condition; + std::shared_ptr m_increment; + std::shared_ptr m_block; + public: + For() : + Element(interpreter::typeFor) { + + } + virtual ~For() {} + + }; + class While : public Element { + protected: + bool m_conditionAtStart; + std::shared_ptr m_condition; + std::shared_ptr m_action; + public: + While() : + Element(interpreter::typeWhile) { + + } + virtual ~While() {} + }; + class Operator : public Element { + protected: + std::string m_operator; + public: + Operator() : + Element(interpreter::typeOperator) { + + } + virtual ~Operator() {} + }; + + } class Interpreter { public: Interpreter(); diff --git a/eci/Lexer.cpp b/eci/Lexer.cpp index c827175..ed6ab10 100644 --- a/eci/Lexer.cpp +++ b/eci/Lexer.cpp @@ -6,6 +6,7 @@ * @license APACHE-2 (see license file) */ +#include #include #include @@ -26,10 +27,10 @@ void eci::Lexer::append(int32_t _tokenId, const std::string& _regularExpression) } } -void eci::Lexer::appendSection(int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop) { +void eci::Lexer::appendSection(int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop, const std::string& _type) { ECI_INFO("CPP lexer add section [" << _tokenId << "] : '" << _tockenStart << "' .. '" << _tockenStop << "'"); try { - m_searchList.push_back(std::make_shared(_tokenId, _tockenStart, _tockenStop)); + m_searchList.push_back(std::make_shared(_tokenId, _tockenStart, _tockenStop, _type)); } catch (std::exception e){ ECI_ERROR(" create reg exp : '" << _tockenStart << "' .. '" << _tockenStop << "' : what:" << e.what()); } @@ -44,10 +45,10 @@ void eci::Lexer::appendSub(int32_t _tokenIdParrent, int32_t _tokenId, const std: } } -void eci::Lexer::appendSubSection(int32_t _tokenIdParrent, int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop) { +void eci::Lexer::appendSubSection(int32_t _tokenIdParrent, int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop, const std::string& _type) { ECI_INFO("CPP lexer add section sub : [" << _tokenId << "] [" << _tokenIdParrent << "] '" << _tockenStart << "' .. '" << _tockenStop << "'"); try { - m_searchList.push_back(std::make_shared(_tokenId, _tokenIdParrent, _tockenStart, _tockenStop)); + m_searchList.push_back(std::make_shared(_tokenId, _tokenIdParrent, _tockenStart, _tockenStop, _type)); } catch (std::exception e){ ECI_ERROR(" create reg exp : '" << _tockenStart << "' .. '" << _tockenStop << "' : what:" << e.what()); } @@ -176,9 +177,9 @@ void eci::Lexer::TypeSection::parseSectionCurrent(std::vectorgetStartPos(); int32_t stopPos = _data[iii]->getStopPos(); - std::shared_ptr newContainer = std::make_shared(m_tockenId, startPos, stopPos); + std::shared_ptr newContainer = std::make_shared(m_tockenId, startPos, stopPos, type); ECI_VERBOSE(" Agregate: " << startId << " -> " << iii); - newContainer->m_list.insert(newContainer->m_list.begin(), _data.begin()+startId, _data.begin()+iii+1); + newContainer->m_list.insert(newContainer->m_list.begin(), _data.begin()+startId+1, _data.begin()+iii); ECI_VERBOSE(" list size=" << newContainer->m_list.size() << " old=" << _data.size()); _data.erase(_data.begin()+startId, _data.begin()+iii+1); ECI_VERBOSE(" list size=" << newContainer->m_list.size() << " old=" << _data.size()); diff --git a/eci/Lexer.h b/eci/Lexer.h index 0013df8..5c94d30 100644 --- a/eci/Lexer.h +++ b/eci/Lexer.h @@ -14,22 +14,19 @@ #include #include #include +#include namespace eci { - class LexerNode { + class LexerNode : public interpreter::Element { public: LexerNode(int32_t _tockenId=-1, int32_t _startPos=-1, int32_t _stopPos=-1) : - m_tockenId(_tockenId), + interpreter::Element(_tockenId), m_startPos(_startPos), m_stopPos(_stopPos) { } virtual ~LexerNode() {}; - int32_t m_tockenId; - int32_t getTockenId() { - return m_tockenId; - } int32_t m_startPos; int32_t getStartPos() { return m_startPos; @@ -43,16 +40,21 @@ namespace eci { } }; class LexerNodeContainer : public LexerNode { + private: + std::string m_type; public: - LexerNodeContainer(int32_t _tockenId=-1, int32_t _startPos=-1, int32_t _stopPos=-1) : + LexerNodeContainer(int32_t _tockenId=-1, int32_t _startPos=-1, int32_t _stopPos=-1, const std::string& _type="") : LexerNode(_tockenId, _startPos, _stopPos) { - + m_type = _type; } virtual ~LexerNodeContainer() {}; std::vector> m_list; virtual bool isNodeContainer() { return true; } + const std::string& getType() const { + return m_type; + } }; class LexerResult { private: @@ -121,10 +123,12 @@ namespace eci { public: int32_t tockenStart; int32_t tockenStop; - TypeSection(int32_t _tockenId, int32_t _tockenStart=-1, int32_t _tockenStop=-1) : + std::string type; + TypeSection(int32_t _tockenId, int32_t _tockenStart=-1, int32_t _tockenStop=-1, const std::string& _type="") : Type(_tockenId), tockenStart(_tockenStart), - tockenStop(_tockenStop) { + tockenStop(_tockenStop), + type(_type) { m_regexValue = "tok=" + etk::to_string(tockenStart) + " -> tok=" + etk::to_string(tockenStop); } virtual int32_t getType() { @@ -153,8 +157,8 @@ namespace eci { class TypeSubSection : public TypeSection { public: int32_t parrent; - TypeSubSection(int32_t _tockenId, int32_t _tokenIdParrent=-1, int32_t _tockenStart=-1, int32_t _tockenStop=-1) : - TypeSection(_tockenId, _tockenStart, _tockenStop), + TypeSubSection(int32_t _tockenId, int32_t _tokenIdParrent=-1, int32_t _tockenStart=-1, int32_t _tockenStop=-1, const std::string& _type="") : + TypeSection(_tockenId, _tockenStart, _tockenStop, _type), parrent(_tokenIdParrent) {} virtual int32_t getType() { return TYPE_SUB_SECTION; @@ -179,8 +183,9 @@ namespace eci { * @param[in] _tokenId Tocken id value. * @param[in] _tockenStart Tocken start. * @param[in] _tockenStop Tocken stop. + * @param[in] _type register type when we parse it ... */ - void appendSection(int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop); + void appendSection(int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop, const std::string& _type); /** * @brief Append a Token recognition (sub parsing). * @param[in] _tokenIdParrent parrent Tocken id value. @@ -194,8 +199,9 @@ namespace eci { * @param[in] _tokenId Tocken id value. * @param[in] _tockenStart Tocken start. * @param[in] _tockenStop Tocken stop. + * @param[in] _type register type when we parse it ... */ - void appendSubSection(int32_t _tokenIdParrent, int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop); + void appendSubSection(int32_t _tokenIdParrent, int32_t _tokenId, int32_t _tockenStart, int32_t _tockenStop, const std::string& _type); LexerResult interprete(const std::string& _data); }; diff --git a/eci/Type.h b/eci/Type.h index 524f512..ea2bf85 100644 --- a/eci/Type.h +++ b/eci/Type.h @@ -10,23 +10,27 @@ #define __ECI_TYPE_H__ #include +#include +#include +#include namespace eci { - class Type : public std::enable_shared_from_this { + class Variable; + class Type : public std::enable_shared_from_this { protected: std::string m_signature; // !!! <== specific au language ... public: Type() {}; - ~Type() {}; - virtual std::shared_ptr operator(const std::shared_ptr& _this, - const std::string& _operatorName, - const std::shared_ptr& _obj) { + virtual ~Type() {}; + virtual std::shared_ptr callOperator(const std::shared_ptr& _this, + const std::string& _operatorName, + const std::shared_ptr& _obj) { ECI_ERROR("call unknow operator : '" << _operatorName << "'"); return nullptr; } - virtual std::vector> call(const std::shared_ptr& _this, - const std::string& _name, - const std::vector>& _objList) { + virtual std::vector> callFunction(const std::shared_ptr& _this, + const std::string& _name, + const std::vector>& _objList) { ECI_ERROR("call unknow function : '" << _name << "' with _input.size()=" << _objList.size()); return std::vector>(); }; @@ -35,15 +39,27 @@ namespace eci { ECI_ERROR("try get unknow Variable : '" << _name << "'"); return nullptr; }; - virtual std::shared_ptr create(const std::vector>& _obj); - virtual std::shared_ptr clone(const std::vector>& _obj); + virtual std::shared_ptr create(const std::vector>& _objList) { + return nullptr; + } + virtual void destroy(std::shared_ptr& _obj) { + if (_obj != nullptr) { + // TODO : mark as destroyed ... + } + } + virtual std::shared_ptr clone(const std::shared_ptr& _obj) { + return nullptr; + } + virtual std::shared_ptr cast(const std::shared_ptr& _obj, const eci::Type& _type) { + return nullptr; + } }; class TypeNatif : public Type { protected: // name , opertor * / += / ++ ... - std::map, std::shared_ptr _variable>> m_operatorList; + std::map(const std::shared_ptr&)>> m_operatorList; // name , function to call - std::map>, std::vector> _variable>> m_functionList; + std::map>(const std::vector>&)>> m_functionList; // @@ -55,7 +71,7 @@ namespace eci { template<> class TypeBase { - } + }; } #endif \ No newline at end of file diff --git a/eci/Variable.h b/eci/Variable.h index 41c2ab4..9e4a79c 100644 --- a/eci/Variable.h +++ b/eci/Variable.h @@ -12,13 +12,14 @@ #include #include #include +#include namespace eci { class Variable : public std::enable_shared_from_this { public: Variable(); - ~Variable(); + virtual ~Variable(); private: enum eci::visibility m_visibility; bool m_const; diff --git a/eci/lang/ParserCpp.cpp b/eci/lang/ParserCpp.cpp index 7a20cbe..c2a78a1 100644 --- a/eci/lang/ParserCpp.cpp +++ b/eci/lang/ParserCpp.cpp @@ -48,9 +48,9 @@ eci::ParserCpp::ParserCpp() { m_lexer.append(tokenCppAssignation, "(\\+=|-=|\\*=|/=|=|\\*|/|--|-|\\+\\+|\\+|&)"); m_lexer.append(tokenCppString, "\\w+"); m_lexer.append(tokenCppSeparator, "(;|,|::|:)"); - m_lexer.appendSection(tokenCppSectionBrace, tokenCppBraceIn, tokenCppBraceOut); - m_lexer.appendSection(tokenCppSectionPthese, tokenCppPtheseIn, tokenCppPtheseOut); - m_lexer.appendSection(tokenCppSectionHook, tokenCppHookIn, tokenCppHookOut); + m_lexer.appendSection(tokenCppSectionBrace, tokenCppBraceIn, tokenCppBraceOut, "{}"); + m_lexer.appendSection(tokenCppSectionPthese, tokenCppPtheseIn, tokenCppPtheseOut, "()"); + m_lexer.appendSection(tokenCppSectionHook, tokenCppHookIn, tokenCppHookOut, "[]"); } eci::ParserCpp::~ParserCpp() { @@ -66,7 +66,7 @@ static void printNode(const std::string& _data, const std::vectorisNodeContainer() == true) { std::shared_ptr sec = std::dynamic_pointer_cast(it); if (sec != nullptr) { - ECI_INFO(offset << " " << it->getStartPos() << "->" << it->getStopPos() << " (container)"); + ECI_INFO(offset << " " << sec->getStartPos() << "->" << sec->getStopPos() << " container: " << sec->getType()); printNode(_data, sec->m_list, _level+1); } } else { diff --git a/eci/lang/ParserCpp.h b/eci/lang/ParserCpp.h index 654e059..fda7b9c 100644 --- a/eci/lang/ParserCpp.h +++ b/eci/lang/ParserCpp.h @@ -10,11 +10,12 @@ #define __ECI_PARSER_CPP_H__ #include +#include namespace eci { enum cppTokenList { - tokenCppCommentMultiline, + tokenCppCommentMultiline = interpreter::typeReserveId, tokenCppCommentSingleLine, tokenCppPreProcessor, tokenCppPreProcessorIf, diff --git a/eci/lang/ParserJS.cpp b/eci/lang/ParserJS.cpp index 56740fe..c463bea 100644 --- a/eci/lang/ParserJS.cpp +++ b/eci/lang/ParserJS.cpp @@ -30,9 +30,9 @@ eci::ParserJS::ParserJS() { m_lexer.append(tokenJSAssignation, "(\\+=|-=|\\*=|/=|=|\\*|/|--|-|\\+\\+|\\+|&)"); m_lexer.append(tokenJSString, "\\w+"); m_lexer.append(tokenJSSeparator, "(;|,)"); - m_lexer.appendSection(tokenJSSectionBrace, tokenJSBraceIn, tokenJSBraceOut); - m_lexer.appendSection(tokenJSSectionPthese, tokenJSPtheseIn, tokenJSPtheseOut); - m_lexer.appendSection(tokenJSSectionHook, tokenJSHookIn, tokenJSHookOut); + m_lexer.appendSection(tokenJSSectionBrace, tokenJSBraceIn, tokenJSBraceOut, "{}"); + m_lexer.appendSection(tokenJSSectionPthese, tokenJSPtheseIn, tokenJSPtheseOut, "()"); + m_lexer.appendSection(tokenJSSectionHook, tokenJSHookIn, tokenJSHookOut, "[]"); } eci::ParserJS::~ParserJS() { @@ -48,7 +48,7 @@ static void printNode(const std::string& _data, const std::vectorisNodeContainer() == true) { std::shared_ptr sec = std::dynamic_pointer_cast(it); if (sec != nullptr) { - ECI_INFO(offset << " " << it->getStartPos() << "->" << it->getStopPos() << " (container)"); + ECI_INFO(offset << " " << sec->getStartPos() << "->" << sec->getStopPos() << " container: " << sec->getType()); printNode(_data, sec->m_list, _level+1); } } else { diff --git a/eci/lang/ParserJS.h b/eci/lang/ParserJS.h index cf04abe..d3de398 100644 --- a/eci/lang/ParserJS.h +++ b/eci/lang/ParserJS.h @@ -10,11 +10,12 @@ #define __ECI_PARSER_JS_H__ #include +#include namespace eci { enum jsTokenList { - tokenJSCommentMultiline, + tokenJSCommentMultiline = interpreter::typeReserveId, tokenJSCommentSingleLine, tokenJSStringDoubleQuote, diff --git a/tests/00_assignment.c b/tests/00_assignment.c deleted file mode 100644 index 56738ba..0000000 --- a/tests/00_assignment.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -int a; -a = 42; -printf("%d\n", a); - -int b = 64; -printf("%d\n", b); - -int c = 12, d = 34; -printf("%d, %d\n", c, d); - -void main() {} diff --git a/tests/00_assignment.expect b/tests/00_assignment.expect deleted file mode 100644 index d4407f3..0000000 --- a/tests/00_assignment.expect +++ /dev/null @@ -1,3 +0,0 @@ -42 -64 -12, 34 diff --git a/tests/01_comment.c b/tests/01_comment.c deleted file mode 100644 index 952ab54..0000000 --- a/tests/01_comment.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -printf("Hello 1\n"); -printf("Hello 2\n"); /* this is a comment */ printf("Hello 3\n"); -printf("Hello 4\n"); -// this is also a comment sayhello(); -printf("Hello 5\n"); -printf("Hello 6\n"); /* this is a second comment */ printf("Hello 7\n"); - - -void main() {} diff --git a/tests/01_comment.expect b/tests/01_comment.expect deleted file mode 100644 index c8d7b96..0000000 --- a/tests/01_comment.expect +++ /dev/null @@ -1,7 +0,0 @@ -Hello 1 -Hello 2 -Hello 3 -Hello 4 -Hello 5 -Hello 6 -Hello 7 diff --git a/tests/02_printf.c b/tests/02_printf.c deleted file mode 100644 index f779c1e..0000000 --- a/tests/02_printf.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -printf("Hello world\n"); - -int Count; -for (Count = -5; Count <= 5; Count++) - printf("Count = %d\n", Count); - -printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there"); -printf("Character 'A' is '%c'\n", 65); -printf("Character 'a' is '%c'\n", 'a'); - -void main() {} diff --git a/tests/02_printf.expect b/tests/02_printf.expect deleted file mode 100644 index f67a0f6..0000000 --- a/tests/02_printf.expect +++ /dev/null @@ -1,15 +0,0 @@ -Hello world -Count = -5 -Count = -4 -Count = -3 -Count = -2 -Count = -1 -Count = 0 -Count = 1 -Count = 2 -Count = 3 -Count = 4 -Count = 5 -String 'hello', 'there' is 'hello', 'there' -Character 'A' is 'A' -Character 'a' is 'a' diff --git a/tests/03_struct.c b/tests/03_struct.c deleted file mode 100644 index 079622d..0000000 --- a/tests/03_struct.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -struct fred -{ - int boris; - int natasha; -}; - -struct fred bloggs; - -bloggs.boris = 12; -bloggs.natasha = 34; - -printf("%d\n", bloggs.boris); -printf("%d\n", bloggs.natasha); - -//struct fred jones[2]; -//jones[0].boris = 12; -//jones[0].natasha = 34; - -void main() {} diff --git a/tests/03_struct.expect b/tests/03_struct.expect deleted file mode 100644 index 8e994dd..0000000 --- a/tests/03_struct.expect +++ /dev/null @@ -1,2 +0,0 @@ -12 -34 diff --git a/tests/04_for.c b/tests/04_for.c deleted file mode 100644 index de563b5..0000000 --- a/tests/04_for.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int Count; - -for (Count = 1; Count <= 10; Count++) -{ - printf("%d\n", Count); -} - -void main() {} diff --git a/tests/04_for.expect b/tests/04_for.expect deleted file mode 100644 index f00c965..0000000 --- a/tests/04_for.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 diff --git a/tests/05_array.c b/tests/05_array.c deleted file mode 100644 index 03dac05..0000000 --- a/tests/05_array.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int Count; -int Array[10]; - -for (Count = 1; Count <= 10; Count++) -{ - Array[Count-1] = Count * Count; -} - -for (Count = 0; Count < 10; Count++) -{ - printf("%d\n", Array[Count]); -} - -void main() {} diff --git a/tests/05_array.expect b/tests/05_array.expect deleted file mode 100644 index bc7257c..0000000 --- a/tests/05_array.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -4 -9 -16 -25 -36 -49 -64 -81 -100 diff --git a/tests/06_case.c b/tests/06_case.c deleted file mode 100644 index 1858205..0000000 --- a/tests/06_case.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int Count; - -for (Count = 0; Count < 4; Count++) -{ - printf("%d\n", Count); - switch (Count) - { - case 1: - printf("%d\n", 1); - break; - - case 2: - printf("%d\n", 2); - break; - - default: - printf("%d\n", 0); - break; - } -} - -void main() {} diff --git a/tests/06_case.expect b/tests/06_case.expect deleted file mode 100644 index fab2c20..0000000 --- a/tests/06_case.expect +++ /dev/null @@ -1,8 +0,0 @@ -0 -0 -1 -1 -2 -2 -3 -0 diff --git a/tests/07_function.c b/tests/07_function.c deleted file mode 100644 index 0501380..0000000 --- a/tests/07_function.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -int myfunc(int x) -{ - return x * x; -} - -printf("%d\n", myfunc(3)); -printf("%d\n", myfunc(4)); - -void vfunc(int a) -{ - printf("a=%d\n", a); -} - -vfunc(1234); - -void qfunc() -{ - printf("qfunc()\n"); -} - -qfunc(); - -void main() {} diff --git a/tests/07_function.expect b/tests/07_function.expect deleted file mode 100644 index 8ffb0a7..0000000 --- a/tests/07_function.expect +++ /dev/null @@ -1,4 +0,0 @@ -9 -16 -a=1234 -qfunc() diff --git a/tests/08_while.c b/tests/08_while.c deleted file mode 100644 index aee79ba..0000000 --- a/tests/08_while.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -int a; -int p; -int t; - -a = 1; -p = 0; -t = 0; - -while (a < 100) -{ - printf("%d\n", a); - t = a; - a = t + p; - p = t; -} - -void main() {} diff --git a/tests/08_while.expect b/tests/08_while.expect deleted file mode 100644 index 702d4c0..0000000 --- a/tests/08_while.expect +++ /dev/null @@ -1,11 +0,0 @@ -1 -1 -2 -3 -5 -8 -13 -21 -34 -55 -89 diff --git a/tests/09_do_while.c b/tests/09_do_while.c deleted file mode 100644 index e55b83a..0000000 --- a/tests/09_do_while.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -int a; -int p; -int t; - -a = 1; -p = 0; -t = 0; - -do -{ - printf("%d\n", a); - t = a; - a = t + p; - p = t; -} while (a < 100); - - -void main() {} diff --git a/tests/09_do_while.expect b/tests/09_do_while.expect deleted file mode 100644 index 702d4c0..0000000 --- a/tests/09_do_while.expect +++ /dev/null @@ -1,11 +0,0 @@ -1 -1 -2 -3 -5 -8 -13 -21 -34 -55 -89 diff --git a/tests/10_pointer.c b/tests/10_pointer.c deleted file mode 100644 index 1bd40e3..0000000 --- a/tests/10_pointer.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -int a; -int *b; -int c; - -a = 42; -b = &a; -printf("a = %d\n", *b); - -struct ziggy -{ - int a; - int b; - int c; -} bolshevic; - -bolshevic.a = 12; -bolshevic.b = 34; -bolshevic.c = 56; - -printf("bolshevic.a = %d\n", bolshevic.a); -printf("bolshevic.b = %d\n", bolshevic.b); -printf("bolshevic.c = %d\n", bolshevic.c); - -struct ziggy *tsar = &bolshevic; - -printf("tsar->a = %d\n", tsar->a); -printf("tsar->b = %d\n", tsar->b); -printf("tsar->c = %d\n", tsar->c); - -/* -b = &(bolshevic.b); -printf("bolshevic.b = %d\n", *b); -*/ - -void main() {} diff --git a/tests/10_pointer.expect b/tests/10_pointer.expect deleted file mode 100644 index 97116c0..0000000 --- a/tests/10_pointer.expect +++ /dev/null @@ -1,7 +0,0 @@ -a = 42 -bolshevic.a = 12 -bolshevic.b = 34 -bolshevic.c = 56 -tsar->a = 12 -tsar->b = 34 -tsar->c = 56 diff --git a/tests/11_precedence.c b/tests/11_precedence.c deleted file mode 100644 index f7a4bda..0000000 --- a/tests/11_precedence.c +++ /dev/null @@ -1,38 +0,0 @@ -#include - -int a; -int b; -int c; -int d; -int e; -int f; -int x; -int y; - -a = 12; -b = 34; -c = 56; -d = 78; -e = 0; -f = 1; - -printf("%d\n", c + d); -printf("%d\n", (y = c + d)); -/* printf("%d\n", a ? b+c : c+d); -printf("%d\n", a ? b+c : c+d); -printf("%d\n", a || b ? b+c : c+d); */ -printf("%d\n", e || e && f); -printf("%d\n", e || f && f); -printf("%d\n", e && e || f); -printf("%d\n", e && f || f); -printf("%d\n", a && f | f); -printf("%d\n", a | b ^ c & d); -printf("%d, %d\n", a == a, a == b); -printf("%d, %d\n", a != a, a != b); -printf("%d\n", a != b && c != d); -printf("%d\n", a + b * c / f); -printf("%d\n", a + b * c / f); -printf("%d\n", (4 << 4)); -printf("%d\n", (64 >> 4)); - -void main() {} diff --git a/tests/11_precedence.expect b/tests/11_precedence.expect deleted file mode 100644 index b692396..0000000 --- a/tests/11_precedence.expect +++ /dev/null @@ -1,15 +0,0 @@ -134 -134 -0 -1 -1 -1 -1 -46 -1, 0 -0, 1 -1 -1916 -1916 -64 -4 diff --git a/tests/12_hashdefine.c b/tests/12_hashdefine.c deleted file mode 100644 index 6ffaf3f..0000000 --- a/tests/12_hashdefine.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -#define FRED 12 -#define BLOGGS(x) (12*(x)) - -printf("%d\n", FRED); -printf("%d, %d, %d\n", BLOGGS(1), BLOGGS(2), BLOGGS(3)); - - -void main() {} diff --git a/tests/12_hashdefine.expect b/tests/12_hashdefine.expect deleted file mode 100644 index 99f2ed5..0000000 --- a/tests/12_hashdefine.expect +++ /dev/null @@ -1,2 +0,0 @@ -12 -12, 24, 36 diff --git a/tests/13_integer_literals.c b/tests/13_integer_literals.c deleted file mode 100644 index f021de2..0000000 --- a/tests/13_integer_literals.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int a = 24680; -int b = 01234567; -int c = 0x2468ac; -int d = 0x2468AC; -int e = 0b010101010101; - -printf("%d\n", a); -printf("%d\n", b); -printf("%d\n", c); -printf("%d\n", d); -printf("%d\n", e); - - -void main() {} diff --git a/tests/13_integer_literals.expect b/tests/13_integer_literals.expect deleted file mode 100644 index f5aca06..0000000 --- a/tests/13_integer_literals.expect +++ /dev/null @@ -1,5 +0,0 @@ -24680 -342391 -2386092 -2386092 -1365 diff --git a/tests/14_if.c b/tests/14_if.c deleted file mode 100644 index bb56ef4..0000000 --- a/tests/14_if.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int a = 1; - -if (a) - printf("a is true\n"); -else - printf("a is false\n"); - -int b = 0; -if (b) - printf("b is true\n"); -else - printf("b is false\n"); - - -void main() {} diff --git a/tests/14_if.expect b/tests/14_if.expect deleted file mode 100644 index c32c415..0000000 --- a/tests/14_if.expect +++ /dev/null @@ -1,2 +0,0 @@ -a is true -b is false diff --git a/tests/15_recursion.c b/tests/15_recursion.c deleted file mode 100644 index 4733c8f..0000000 --- a/tests/15_recursion.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int factorial(int i) -{ - if (i < 2) - return i; - else - return i * factorial(i - 1); -} - -int Count; - -for (Count = 1; Count <= 10; Count++) - printf("%d\n", factorial(Count)); - -void main() {} diff --git a/tests/15_recursion.expect b/tests/15_recursion.expect deleted file mode 100644 index db47b28..0000000 --- a/tests/15_recursion.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -6 -24 -120 -720 -5040 -40320 -362880 -3628800 diff --git a/tests/16_nesting.c b/tests/16_nesting.c deleted file mode 100644 index 90a62bf..0000000 --- a/tests/16_nesting.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int x, y, z; - -for (x = 0; x < 2; x++) -{ - for (y = 0; y < 3; y++) - { - for (z = 0; z < 3; z++) - { - printf("%d %d %d\n", x, y, z); - } - } -} - -void main() {} diff --git a/tests/16_nesting.expect b/tests/16_nesting.expect deleted file mode 100644 index 625ee13..0000000 --- a/tests/16_nesting.expect +++ /dev/null @@ -1,18 +0,0 @@ -0 0 0 -0 0 1 -0 0 2 -0 1 0 -0 1 1 -0 1 2 -0 2 0 -0 2 1 -0 2 2 -1 0 0 -1 0 1 -1 0 2 -1 1 0 -1 1 1 -1 1 2 -1 2 0 -1 2 1 -1 2 2 diff --git a/tests/17_enum.c b/tests/17_enum.c deleted file mode 100644 index f53c88c..0000000 --- a/tests/17_enum.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -enum fred -{ - a, - b, - c, - d, - e = 54, - f = 73, - g, - h -}; - -enum fred frod; - -printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h); -printf("%d\n", frod); -frod = 12; -printf("%d\n", frod); -frod = e; -printf("%d\n", frod); - -void main() {} diff --git a/tests/17_enum.expect b/tests/17_enum.expect deleted file mode 100644 index 0c17a2d..0000000 --- a/tests/17_enum.expect +++ /dev/null @@ -1,4 +0,0 @@ -0 1 2 3 54 73 74 75 -0 -12 -54 diff --git a/tests/18_include.c b/tests/18_include.c deleted file mode 100644 index f2bfcc6..0000000 --- a/tests/18_include.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -printf("including\n"); -#include "18_include.h" -printf("done\n"); - -void main() {} diff --git a/tests/18_include.expect b/tests/18_include.expect deleted file mode 100644 index 87729df..0000000 --- a/tests/18_include.expect +++ /dev/null @@ -1,3 +0,0 @@ -including -included -done diff --git a/tests/18_include.h b/tests/18_include.h deleted file mode 100644 index 01f894d..0000000 --- a/tests/18_include.h +++ /dev/null @@ -1 +0,0 @@ -printf("included\n"); diff --git a/tests/19_pointer_arithmetic.c b/tests/19_pointer_arithmetic.c deleted file mode 100644 index 96c7e6a..0000000 --- a/tests/19_pointer_arithmetic.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int a; -int *b; -int *c; - -a = 42; -b = &a; -c = NULL; - -printf("%d\n", *b); - -if (b == NULL) - printf("b is NULL\n"); -else - printf("b is not NULL\n"); - -if (c == NULL) - printf("c is NULL\n"); -else - printf("c is not NULL\n"); - - -void main() {} diff --git a/tests/19_pointer_arithmetic.expect b/tests/19_pointer_arithmetic.expect deleted file mode 100644 index 0cf781b..0000000 --- a/tests/19_pointer_arithmetic.expect +++ /dev/null @@ -1,3 +0,0 @@ -42 -b is not NULL -c is NULL diff --git a/tests/20_pointer_comparison.c b/tests/20_pointer_comparison.c deleted file mode 100644 index bab1d5e..0000000 --- a/tests/20_pointer_comparison.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -int a; -int b; -int *d; -int *e; -d = &a; -e = &b; -a = 12; -b = 34; -printf("%d\n", *d); -printf("%d\n", *e); -printf("%d\n", d == e); -printf("%d\n", d != e); -d = e; -printf("%d\n", d == e); -printf("%d\n", d != e); - - -void main() {} diff --git a/tests/20_pointer_comparison.expect b/tests/20_pointer_comparison.expect deleted file mode 100644 index 5d1e5f5..0000000 --- a/tests/20_pointer_comparison.expect +++ /dev/null @@ -1,6 +0,0 @@ -12 -34 -0 -1 -1 -0 diff --git a/tests/21_char_array.c b/tests/21_char_array.c deleted file mode 100644 index 0f158cd..0000000 --- a/tests/21_char_array.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -int x = 'a'; -char y = x; - -char *a = "hello"; - -printf("%s\n", a); - -int c; -c = *a; - -char *b; -for (b = a; *b != 0; b++) - printf("%c: %d\n", *b, *b); - -char destarray[10]; -char *dest = &destarray[0]; -char *src = a; - -while (*src != 0) - *dest++ = *src++; - -*dest = 0; - -printf("copied string is %s\n", destarray); - - -void main() {} diff --git a/tests/21_char_array.expect b/tests/21_char_array.expect deleted file mode 100644 index dbc6068..0000000 --- a/tests/21_char_array.expect +++ /dev/null @@ -1,7 +0,0 @@ -hello -h: 104 -e: 101 -l: 108 -l: 108 -o: 111 -copied string is hello diff --git a/tests/22_floating_point.c b/tests/22_floating_point.c deleted file mode 100644 index 37754a4..0000000 --- a/tests/22_floating_point.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include - -// variables -float a = 12.34 + 56.78; -printf("%f\n", a); - -// infix operators -printf("%f\n", 12.34 + 56.78); -printf("%f\n", 12.34 - 56.78); -printf("%f\n", 12.34 * 56.78); -printf("%f\n", 12.34 / 56.78); - -// comparison operators -printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78); -printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34); -printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34); - -// assignment operators -a = 12.34; -a += 56.78; -printf("%f\n", a); - -a = 12.34; -a -= 56.78; -printf("%f\n", a); - -a = 12.34; -a *= 56.78; -printf("%f\n", a); - -a = 12.34; -a /= 56.78; -printf("%f\n", a); - -// prefix operators -printf("%f\n", +12.34); -printf("%f\n", -12.34); - -// type coercion -a = 2; -printf("%f\n", a); -printf("%f\n", sin(2)); - -void main() {} diff --git a/tests/22_floating_point.expect b/tests/22_floating_point.expect deleted file mode 100644 index 282d089..0000000 --- a/tests/22_floating_point.expect +++ /dev/null @@ -1,16 +0,0 @@ -69.120000 -69.120000 --44.440000 -700.665200 -0.217330 -1 1 0 0 0 1 -0 1 1 1 0 0 -0 0 0 1 1 1 -69.120000 --44.440000 -700.665200 -0.217330 -12.340000 --12.340000 -2.000000 -0.909297 diff --git a/tests/23_type_coercion.c b/tests/23_type_coercion.c deleted file mode 100644 index 9076952..0000000 --- a/tests/23_type_coercion.c +++ /dev/null @@ -1,49 +0,0 @@ -#include - -void charfunc(char a) -{ - printf("char: %c\n", a); -} - -void intfunc(int a) -{ - printf("int: %d\n", a); -} - -void floatfunc(float a) -{ - printf("float: %f\n", a); -} - -charfunc('a'); -charfunc(98); -charfunc(99.0); - -intfunc('a'); -intfunc(98); -intfunc(99.0); - -floatfunc('a'); -floatfunc(98); -floatfunc(99.0); - -printf("%c %d %f\n", 'a', 'b', 'c'); -printf("%c %d %f\n", 97, 98, 99); -printf("%c %d %f\n", 97.0, 98.0, 99.0); - -char b = 97; -char c = 97.0; - -printf("%d %d\n", b, c); - -int d = 'a'; -int e = 97.0; - -printf("%d %d\n", d, e); - -float f = 'a'; -float g = 97; - -printf("%f %f\n", f, g); - -void main() {} diff --git a/tests/23_type_coercion.expect b/tests/23_type_coercion.expect deleted file mode 100644 index a4c5b68..0000000 --- a/tests/23_type_coercion.expect +++ /dev/null @@ -1,15 +0,0 @@ -char: a -char: b -char: c -int: 97 -int: 98 -int: 99 -float: 97.000000 -float: 98.000000 -float: 99.000000 -a 98 99.000000 -a 98 99.000000 -a 98 99.000000 -97 97 -97 97 -97.000000 97.000000 diff --git a/tests/24_math_library.c b/tests/24_math_library.c deleted file mode 100644 index 892c4b8..0000000 --- a/tests/24_math_library.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -printf("%f\n", sin(0.12)); -printf("%f\n", cos(0.12)); -printf("%f\n", tan(0.12)); -printf("%f\n", asin(0.12)); -printf("%f\n", acos(0.12)); -printf("%f\n", atan(0.12)); -printf("%f\n", sinh(0.12)); -printf("%f\n", cosh(0.12)); -printf("%f\n", tanh(0.12)); -printf("%f\n", exp(0.12)); -printf("%f\n", fabs(-0.12)); -printf("%f\n", log(0.12)); -printf("%f\n", log10(0.12)); -printf("%f\n", pow(0.12, 0.12)); -printf("%f\n", sqrt(0.12)); -printf("%f\n", round(12.34)); -printf("%f\n", ceil(12.34)); -printf("%f\n", floor(12.34)); - -void main() {} diff --git a/tests/24_math_library.expect b/tests/24_math_library.expect deleted file mode 100644 index 99f7299..0000000 --- a/tests/24_math_library.expect +++ /dev/null @@ -1,18 +0,0 @@ -0.119712 -0.992809 -0.120579 -0.120290 -1.450506 -0.119429 -0.120288 -1.007209 -0.119427 -1.127497 -0.120000 --2.120264 --0.920819 -0.775357 -0.346410 -12.000000 -13.000000 -12.000000 diff --git a/tests/25_quicksort.c b/tests/25_quicksort.c deleted file mode 100644 index 724d9c5..0000000 --- a/tests/25_quicksort.c +++ /dev/null @@ -1,80 +0,0 @@ -#include - -int array[16]; - -//Swap integer values by array indexes -void swap(int a, int b) -{ - int tmp = array[a]; - array[a] = array[b]; - array[b] = tmp; -} - -//Partition the array into two halves and return the -//index about which the array is partitioned -int partition(int left, int right) -{ - int pivotIndex = left; - int pivotValue = array[pivotIndex]; - int index = left; - int i; - - swap(pivotIndex, right); - for(i = left; i < right; i++) - { - if(array[i] < pivotValue) - { - swap(i, index); - index += 1; - } - } - swap(right, index); - - return index; -} - -//Quicksort the array -void quicksort(int left, int right) -{ - if(left >= right) - return; - - int index = partition(left, right); - quicksort(left, index - 1); - quicksort(index + 1, right); -} - -void main() -{ - int i; - - array[0] = 62; - array[1] = 83; - array[2] = 4; - array[3] = 89; - array[4] = 36; - array[5] = 21; - array[6] = 74; - array[7] = 37; - array[8] = 65; - array[9] = 33; - array[10] = 96; - array[11] = 38; - array[12] = 53; - array[13] = 16; - array[14] = 74; - array[15] = 55; - - for (i = 0; i < 16; i++) - printf("%d ", array[i]); - - printf("\n"); - - quicksort(0, 15); - - for (i = 0; i < 16; i++) - printf("%d ", array[i]); - - printf("\n"); -} - diff --git a/tests/25_quicksort.expect b/tests/25_quicksort.expect deleted file mode 100644 index 2d39cd3..0000000 --- a/tests/25_quicksort.expect +++ /dev/null @@ -1,2 +0,0 @@ -62 83 4 89 36 21 74 37 65 33 96 38 53 16 74 55 -4 16 21 33 36 37 38 53 55 62 65 74 74 83 89 96 diff --git a/tests/26_character_constants.c b/tests/26_character_constants.c deleted file mode 100644 index 6553f76..0000000 --- a/tests/26_character_constants.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -printf("%d\n", '\1'); -printf("%d\n", '\10'); -printf("%d\n", '\100'); -printf("%d\n", '\x01'); -printf("%d\n", '\x0e'); -printf("%d\n", '\x10'); -printf("%d\n", '\x40'); -printf("test \x407\n"); - - -void main() {} diff --git a/tests/26_character_constants.expect b/tests/26_character_constants.expect deleted file mode 100644 index 53e27d0..0000000 --- a/tests/26_character_constants.expect +++ /dev/null @@ -1,8 +0,0 @@ -1 -8 -64 -1 -14 -16 -64 -test @7 diff --git a/tests/27_sizeof.c b/tests/27_sizeof.c deleted file mode 100644 index 52703aa..0000000 --- a/tests/27_sizeof.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -char a; -int b; -double c; - -printf("%d\n", sizeof(a)); -printf("%d\n", sizeof(b)); -printf("%d\n", sizeof(c)); - - -void main() {} diff --git a/tests/27_sizeof.expect b/tests/27_sizeof.expect deleted file mode 100644 index 7329e00..0000000 --- a/tests/27_sizeof.expect +++ /dev/null @@ -1,3 +0,0 @@ -1 -4 -8 diff --git a/tests/28_strings.c b/tests/28_strings.c deleted file mode 100644 index d173060..0000000 --- a/tests/28_strings.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include - -char a[10]; - -strcpy(a, "hello"); -printf("%s\n", a); - -strncpy(a, "gosh", 2); -printf("%s\n", a); - -printf("%d\n", strcmp(a, "apple") > 0); -printf("%d\n", strcmp(a, "goere") > 0); -printf("%d\n", strcmp(a, "zebra") < 0); - -printf("%d\n", strlen(a)); - -strcat(a, "!"); -printf("%s\n", a); - -printf("%d\n", strncmp(a, "apple", 2) > 0); -printf("%d\n", strncmp(a, "goere", 2) == 0); -printf("%d\n", strncmp(a, "goerg", 2) == 0); -printf("%d\n", strncmp(a, "zebra", 2) < 0); - -printf("%s\n", index(a, 'o')); -printf("%s\n", rindex(a, 'l')); -printf("%d\n", rindex(a, 'x') == NULL); - -memset(&a[1], 'r', 4); -printf("%s\n", a); - -memcpy(&a[2], a, 2); -printf("%s\n", a); - -printf("%d\n", memcmp(a, "apple", 4) > 0); -printf("%d\n", memcmp(a, "grgr", 4) == 0); -printf("%d\n", memcmp(a, "zebra", 4) < 0); - - -void main() {} diff --git a/tests/28_strings.expect b/tests/28_strings.expect deleted file mode 100644 index fd9217a..0000000 --- a/tests/28_strings.expect +++ /dev/null @@ -1,19 +0,0 @@ -hello -gollo -1 -1 -1 -5 -gollo! -1 -1 -1 -1 -ollo! -lo! -1 -grrrr! -grgrr! -1 -1 -1 diff --git a/tests/29_array_address.c b/tests/29_array_address.c deleted file mode 100644 index a8562af..0000000 --- a/tests/29_array_address.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -char a[10]; -strcpy(a, "abcdef"); -printf("%s\n", &a[1]); - -void main() {} diff --git a/tests/29_array_address.expect b/tests/29_array_address.expect deleted file mode 100644 index 9bc8683..0000000 --- a/tests/29_array_address.expect +++ /dev/null @@ -1 +0,0 @@ -bcdef diff --git a/tests/30_hanoi.c b/tests/30_hanoi.c deleted file mode 100644 index 5ca6667..0000000 --- a/tests/30_hanoi.c +++ /dev/null @@ -1,125 +0,0 @@ -/* example from http://barnyard.syr.edu/quickies/hanoi.c */ - -/* hanoi.c: solves the tower of hanoi problem. (Programming exercise.) */ -/* By Terry R. McConnell (12/2/97) */ -/* Compile: cc -o hanoi hanoi.c */ - -/* This program does no error checking. But then, if it's right, -it's right ... right ? */ - - -/* The original towers of hanoi problem seems to have been originally posed -by one M. Claus in 1883. There is a popular legend that goes along with -it that has been often repeated and paraphrased. It goes something like this: -In the great temple at Benares there are 3 golden spikes. On one of them, -God placed 64 disks increasing in size from bottom to top, at the beginning -of time. Since then, and to this day, the priest on duty constantly transfers -disks, one at a time, in such a way that no larger disk is ever put on top -of a smaller one. When the disks have been transferred entirely to another -spike the Universe will come to an end in a large thunderclap. - -This paraphrases the original legend due to DeParville, La Nature, Paris 1884, -Part I, 285-286. For this and further information see: Mathematical -Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967, -303-305. -* -* -*/ - -#include -#include - -#define TRUE 1 -#define FALSE 0 - -#define N 4 /* This is the number of "disks" on tower A initially. */ - /* Taken to be 64 in the legend. The number of moves - required, in general, is 2^N - 1. For N = 64, this is - 18,446,744,073,709,551,615 */ - -int A[N], B[N], C[N]; /* These are the three towers. For example if the -state of A is 0,1,3,4, that means that there are three discs on A of sizes -1, 3, and 4. (Think of right as being the "down" direction.) */ - -void Hanoi(int,int*,int*,int*); - -/* Print the current configuration of A, B, and C to the screen */ - -void -PrintAll() -{ - int i; - - printf("A: "); - for(i=0;i - -int main(int argc, char **argv) -{ - int Count; - - printf("hello world %d\n", argc); - for (Count = 0; Count < argc; Count++) - printf("arg %d: %s\n", Count, argv[Count]); - - return 0; -} diff --git a/tests/31_args.expect b/tests/31_args.expect deleted file mode 100644 index bf25112..0000000 --- a/tests/31_args.expect +++ /dev/null @@ -1,6 +0,0 @@ -hello world 5 -arg 0: - -arg 1: arg1 -arg 2: arg2 -arg 3: arg3 -arg 4: arg4 diff --git a/tests/32_led.c b/tests/32_led.c deleted file mode 100644 index d1a28b6..0000000 --- a/tests/32_led.c +++ /dev/null @@ -1,264 +0,0 @@ -/* example from http://barnyard.syr.edu/quickies/led.c */ - -/* led.c: print out number as if on 7 line led display. I.e., write integer - given on command line like this: - _ _ _ - | _| _| |_| |_ - | |_ _| | _| etc. - - We assume the terminal behaves like a classical teletype. So the top - lines of all digits have to be printed first, then the middle lines of - all digits, etc. - - By Terry R. McConnell - - compile: cc -o led led.c - - If you just want to link in the subroutine print_led that does all the - work, compile with -DNO_MAIN, and declare the following in any source file - that uses the call: - - extern void print_led(unsigned long x, char *buf); - - Bug: you cannot call repeatedly to print more than one number to a line. - That would require curses or some other terminal API that allows moving the - cursor to a previous line. - - */ - - - -#include -#include - -#define MAX_DIGITS 32 -#define NO_MAIN - - -/* Print the top line of the digit d into buffer. - Does not null terminate buffer. */ - -void topline(int d, char *p){ - - *p++ = ' '; - switch(d){ - - /* all these have _ on top line */ - - case 0: - case 2: - case 3: - case 5: - case 7: - case 8: - case 9: - *p++ = '_'; - break; - default: - *p++=' '; - - } - *p++=' '; -} - -/* Print the middle line of the digit d into the buffer. - Does not null terminate. */ - -void midline(int d, char *p){ - - switch(d){ - - /* those that have leading | on middle line */ - - case 0: - case 4: - case 5: - case 6: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - } - switch(d){ - - /* those that have _ on middle line */ - - case 2: - case 3: - case 4: - case 5: - case 6: - case 8: - case 9: - *p++='_'; - break; - default: - *p++=' '; - - } - switch(d){ - - /* those that have closing | on middle line */ - - case 0: - case 1: - case 2: - case 3: - case 4: - case 7: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - - } -} - -/* Print the bottom line of the digit d. Does not null terminate. */ - -void botline(int d, char *p){ - - - switch(d){ - - /* those that have leading | on bottom line */ - - case 0: - case 2: - case 6: - case 8: - *p++='|'; - break; - default: - *p++=' '; - } - switch(d){ - - /* those that have _ on bottom line */ - - case 0: - case 2: - case 3: - case 5: - case 6: - case 8: - *p++='_'; - break; - default: - *p++=' '; - - } - switch(d){ - - /* those that have closing | on bottom line */ - - case 0: - case 1: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - - } -} - -/* Write the led representation of integer to string buffer. */ - -void print_led(unsigned long x, char *buf) -{ - - int i=0,n; - static int d[MAX_DIGITS]; - - - /* extract digits from x */ - - n = ( x == 0L ? 1 : 0 ); /* 0 is a digit, hence a special case */ - - while(x){ - d[n++] = (int)(x%10L); - if(n >= MAX_DIGITS)break; - x = x/10L; - } - - /* print top lines of all digits */ - - for(i=n-1;i>=0;i--){ - topline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; /* move teletype to next line */ - - /* print middle lines of all digits */ - - for(i=n-1;i>=0;i--){ - midline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; - - /* print bottom lines of all digits */ - - for(i=n-1;i>=0;i--){ - botline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; - *buf='\0'; -} - -int main() -{ - char buf[5*MAX_DIGITS]; - print_led(1234567, buf); - printf("%s\n",buf); - - return 0; -} - -#ifndef NO_MAIN -int main(int argc, char **argv) -{ - - int i=0,n; - long x; - static int d[MAX_DIGITS]; - char buf[5*MAX_DIGITS]; - - if(argc != 2){ - fprintf(stderr,"led: usage: led integer\n"); - return 1; - } - - /* fetch argument from command line */ - - x = atol(argv[1]); - - /* sanity check */ - - if(x<0){ - fprintf(stderr,"led: %d must be non-negative\n",x); - return 1; - } - - print_led(x,buf); - printf("%s\n",buf); - - return 0; - -} -#endif diff --git a/tests/32_led.expect b/tests/32_led.expect deleted file mode 100644 index c53b58a..0000000 --- a/tests/32_led.expect +++ /dev/null @@ -1,4 +0,0 @@ - _ _ _ _ - | _| _| |_| |_ |_ | - | |_ _| | _| |_| | - diff --git a/tests/33_ternary_op.c b/tests/33_ternary_op.c deleted file mode 100644 index 5c1cead..0000000 --- a/tests/33_ternary_op.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int Count; - -for (Count = 0; Count < 10; Count++) -{ - printf("%d\n", (Count < 5) ? (Count*Count) : (Count * 3)); -} - -void main() {} diff --git a/tests/33_ternary_op.expect b/tests/33_ternary_op.expect deleted file mode 100644 index 45ea507..0000000 --- a/tests/33_ternary_op.expect +++ /dev/null @@ -1,10 +0,0 @@ -0 -1 -4 -9 -16 -15 -18 -21 -24 -27 diff --git a/tests/34_array_assignment.c b/tests/34_array_assignment.c deleted file mode 100644 index afe544e..0000000 --- a/tests/34_array_assignment.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -int a[4]; - -a[0] = 12; -a[1] = 23; -a[2] = 34; -a[3] = 45; - -printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]); - -int b[4]; - -b = a; - -printf("%d %d %d %d\n", b[0], b[1], b[2], b[3]); - -void main() {} diff --git a/tests/34_array_assignment.expect b/tests/34_array_assignment.expect deleted file mode 100644 index 9736bf5..0000000 --- a/tests/34_array_assignment.expect +++ /dev/null @@ -1,2 +0,0 @@ -12 23 34 45 -12 23 34 45 diff --git a/tests/35_sizeof.c b/tests/35_sizeof.c deleted file mode 100644 index 87c783a..0000000 --- a/tests/35_sizeof.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -char a; -short b; - -printf("%d %d\n", sizeof(char), sizeof(a)); -printf("%d %d\n", sizeof(short), sizeof(b)); - -void main() {} diff --git a/tests/35_sizeof.expect b/tests/35_sizeof.expect deleted file mode 100644 index 534fb83..0000000 --- a/tests/35_sizeof.expect +++ /dev/null @@ -1,2 +0,0 @@ -1 1 -2 2 diff --git a/tests/36_array_initialisers.c b/tests/36_array_initialisers.c deleted file mode 100644 index ce8695b..0000000 --- a/tests/36_array_initialisers.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int Count; - -int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 }; - -for (Count = 0; Count < 10; Count++) - printf("%d: %d\n", Count, Array[Count]); - -int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, }; - -for (Count = 0; Count < 10; Count++) - printf("%d: %d\n", Count, Array2[Count]); - - -void main() {} diff --git a/tests/36_array_initialisers.expect b/tests/36_array_initialisers.expect deleted file mode 100644 index 3ac6c77..0000000 --- a/tests/36_array_initialisers.expect +++ /dev/null @@ -1,20 +0,0 @@ -0: 12 -1: 34 -2: 56 -3: 78 -4: 90 -5: 123 -6: 456 -7: 789 -8: 8642 -9: 9753 -0: 12 -1: 34 -2: 56 -3: 78 -4: 90 -5: 123 -6: 456 -7: 789 -8: 8642 -9: 9753 diff --git a/tests/37_sprintf.c b/tests/37_sprintf.c deleted file mode 100644 index 839a4d8..0000000 --- a/tests/37_sprintf.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -char Buf[100]; -int Count; - -for (Count = 1; Count <= 20; Count++) -{ - sprintf(Buf, "->%02d<-\n", Count); - printf("%s", Buf); -} - -void main() {} diff --git a/tests/37_sprintf.expect b/tests/37_sprintf.expect deleted file mode 100644 index a643da8..0000000 --- a/tests/37_sprintf.expect +++ /dev/null @@ -1,20 +0,0 @@ -->01<- -->02<- -->03<- -->04<- -->05<- -->06<- -->07<- -->08<- -->09<- -->10<- -->11<- -->12<- -->13<- -->14<- -->15<- -->16<- -->17<- -->18<- -->19<- -->20<- diff --git a/tests/38_multiple_array_index.c b/tests/38_multiple_array_index.c deleted file mode 100644 index 383d3ee..0000000 --- a/tests/38_multiple_array_index.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -int a[4][4]; -int b = 0; -int x; -int y; - -for (x = 0; x < 4; x++) -{ - for (y = 0; y < 4; y++) - { - b++; - a[x][y] = b; - } -} - - - -for (x = 0; x < 4; x++) -{ - printf("x=%d: ", x); - for (y = 0; y < 4; y++) - { - printf("%d ", a[x][y]); - } - printf("\n"); -} - -void main() {} diff --git a/tests/38_multiple_array_index.expect b/tests/38_multiple_array_index.expect deleted file mode 100644 index 747ad75..0000000 --- a/tests/38_multiple_array_index.expect +++ /dev/null @@ -1,4 +0,0 @@ -x=0: 1 2 3 4 -x=1: 5 6 7 8 -x=2: 9 10 11 12 -x=3: 13 14 15 16 diff --git a/tests/39_typedef.c b/tests/39_typedef.c deleted file mode 100644 index e36791c..0000000 --- a/tests/39_typedef.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -typedef int MyInt; - -MyInt a = 1; -printf("%d\n", a); - -struct FunStruct -{ - int i; - int j; -}; - -typedef struct FunStruct MyFunStruct; - -MyFunStruct b; -b.i = 12; -b.j = 34; -printf("%d,%d\n", b.i, b.j); - -typedef MyFunStruct *MoreFunThanEver; - -MoreFunThanEver c = &b; -printf("%d,%d\n", c->i, c->j); - -void main() {} diff --git a/tests/39_typedef.expect b/tests/39_typedef.expect deleted file mode 100644 index b9050a9..0000000 --- a/tests/39_typedef.expect +++ /dev/null @@ -1,3 +0,0 @@ -1 -12,34 -12,34 diff --git a/tests/40_stdio.c b/tests/40_stdio.c deleted file mode 100644 index 546ca52..0000000 --- a/tests/40_stdio.c +++ /dev/null @@ -1,47 +0,0 @@ -#include - -FILE *f = fopen("fred.txt", "w"); -fwrite("hello\nhello\n", 1, 12, f); -fclose(f); - -char freddy[7]; -f = fopen("fred.txt", "r"); -if (fread(freddy, 1, 6, f) != 6) - printf("couldn't read fred.txt\n"); - -freddy[6] = '\0'; -fclose(f); - -printf("%s", freddy); - -char InChar; -char ShowChar; -f = fopen("fred.txt", "r"); -while ( (InChar = fgetc(f)) != EOF) -{ - ShowChar = InChar; - if (ShowChar < ' ') - ShowChar = '.'; - - printf("ch: %d '%c'\n", InChar, ShowChar); -} -fclose(f); - -f = fopen("fred.txt", "r"); -while ( (InChar = getc(f)) != EOF) -{ - ShowChar = InChar; - if (ShowChar < ' ') - ShowChar = '.'; - - printf("ch: %d '%c'\n", InChar, ShowChar); -} -fclose(f); - -f = fopen("fred.txt", "r"); -while (fgets(freddy, sizeof(freddy), f) != NULL) - printf("x: %s", freddy); - -fclose(f); - -void main() {} diff --git a/tests/40_stdio.expect b/tests/40_stdio.expect deleted file mode 100644 index e08167a..0000000 --- a/tests/40_stdio.expect +++ /dev/null @@ -1,27 +0,0 @@ -hello -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -ch: 104 'h' -ch: 101 'e' -ch: 108 'l' -ch: 108 'l' -ch: 111 'o' -ch: 10 '.' -x: hello -x: hello diff --git a/tests/41_hashif.c b/tests/41_hashif.c deleted file mode 100644 index b1883c0..0000000 --- a/tests/41_hashif.c +++ /dev/null @@ -1,80 +0,0 @@ -#include - -printf("#include test\n"); - -#if 1 - #if 0 - printf("a\n"); - #else - printf("b\n"); - #endif -#else - #if 0 - printf("c\n"); - #else - printf("d\n"); - #endif -#endif - -#if 0 - #if 1 - printf("e\n"); - #else - printf("f\n"); - #endif -#else - #if 1 - printf("g\n"); - #else - printf("h\n"); - #endif -#endif - -#define DEF - -#ifdef DEF - #ifdef DEF - printf("i\n"); - #else - printf("j\n"); - #endif -#else - #ifdef DEF - printf("k\n"); - #else - printf("l\n"); - #endif -#endif - -#ifndef DEF - #ifndef DEF - printf("m\n"); - #else - printf("n\n"); - #endif -#else - #ifndef DEF - printf("o\n"); - #else - printf("p\n"); - #endif -#endif - -#define ONE 1 -#define ZERO 0 - -#if ONE - #if ZERO - printf("q\n"); - #else - printf("r\n"); - #endif -#else - #if ZERO - printf("s\n"); - #else - printf("t\n"); - #endif -#endif - -void main() {} diff --git a/tests/41_hashif.expect b/tests/41_hashif.expect deleted file mode 100644 index 5fd414b..0000000 --- a/tests/41_hashif.expect +++ /dev/null @@ -1,6 +0,0 @@ -#include test -b -g -i -p -r diff --git a/tests/42_function_pointer.c b/tests/42_function_pointer.c deleted file mode 100644 index ce39708..0000000 --- a/tests/42_function_pointer.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -int fred(int p) -{ - printf("yo %d\n", p); - return 42; -} - -int (*f)(int) = &fred; - -int main() -{ - printf("%d\n", (*f)(24)); - return 0; -} diff --git a/tests/43_void_param.c b/tests/43_void_param.c deleted file mode 100644 index 4803d94..0000000 --- a/tests/43_void_param.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -void fred(void) -{ - printf("yo\n"); -} - -fred(); - -void main() {} diff --git a/tests/43_void_param.expect b/tests/43_void_param.expect deleted file mode 100644 index 092bfb9..0000000 --- a/tests/43_void_param.expect +++ /dev/null @@ -1 +0,0 @@ -yo diff --git a/tests/44_scoped_declarations.c b/tests/44_scoped_declarations.c deleted file mode 100644 index 50337ef..0000000 --- a/tests/44_scoped_declarations.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -int a; - -for (a = 0; a < 2; a++) -{ - int b = a; -} - -printf("it's all good\n"); - -void main() {} diff --git a/tests/44_scoped_declarations.expect b/tests/44_scoped_declarations.expect deleted file mode 100644 index 231ccc0..0000000 --- a/tests/44_scoped_declarations.expect +++ /dev/null @@ -1 +0,0 @@ -it's all good diff --git a/tests/45_empty_for.c b/tests/45_empty_for.c deleted file mode 100644 index 28d0b6c..0000000 --- a/tests/45_empty_for.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int main() -{ - int Count = 0; - - for (;;) - { - Count++; - printf("%d\n", Count); - if (Count >= 10) - break; - } - - return 0; -} diff --git a/tests/45_empty_for.expect b/tests/45_empty_for.expect deleted file mode 100644 index f00c965..0000000 --- a/tests/45_empty_for.expect +++ /dev/null @@ -1,10 +0,0 @@ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 diff --git a/tests/46_grep.c b/tests/46_grep.c deleted file mode 100644 index b142f98..0000000 --- a/tests/46_grep.c +++ /dev/null @@ -1,562 +0,0 @@ -/* - * The information in this document is subject to change - * without notice and should not be construed as a commitment - * by Digital Equipment Corporation or by DECUS. - * - * Neither Digital Equipment Corporation, DECUS, nor the authors - * assume any responsibility for the use or reliability of this - * document or the described software. - * - * Copyright (C) 1980, DECUS - * - * General permission to copy or modify, but not for profit, is - * hereby granted, provided that the above copyright notice is - * included and reference made to the fact that reproduction - * privileges were granted by DECUS. - */ -#include - -/* - * grep - * - * Runs on the Decus compiler or on vms, On vms, define as: - * grep :== "$disk:[account]grep" (native) - * grep :== "$disk:[account]grep grep" (Decus) - * See below for more information. - */ - -#if 0 -char *documentation[] = { -"grep searches a file for a given pattern. Execute by", -" grep [flags] regular_expression file_list\n", -"Flags are single characters preceeded by '-':", -" -c Only a count of matching lines is printed", -" -f Print file name for matching lines switch, see below", -" -n Each line is preceeded by its line number", -" -v Only print non-matching lines\n", -"The file_list is a list of files (wildcards are acceptable on RSX modes).", -"\nThe file name is normally printed if there is a file given.", -"The -f flag reverses this action (print name no file, not if more).\n", -0 }; - -char *patdoc[] = { -"The regular_expression defines the pattern to search for. Upper- and", -"lower-case are always ignored. Blank lines never match. The expression", -"should be quoted to prevent file-name translation.", -"x An ordinary character (not mentioned below) matches that character.", -"'\\' The backslash quotes any character. \"\\$\" matches a dollar-sign.", -"'^' A circumflex at the beginning of an expression matches the", -" beginning of a line.", -"'$' A dollar-sign at the end of an expression matches the end of a line.", -"'.' A period matches any character except \"new-line\".", -"':a' A colon matches a class of characters described by the following", -"':d' character. \":a\" matches any alphabetic, \":d\" matches digits,", -"':n' \":n\" matches alphanumerics, \": \" matches spaces, tabs, and", -"': ' other control characters, such as new-line.", -"'*' An expression followed by an asterisk matches zero or more", -" occurrances of that expression: \"fo*\" matches \"f\", \"fo\"", -" \"foo\", etc.", -"'+' An expression followed by a plus sign matches one or more", -" occurrances of that expression: \"fo+\" matches \"fo\", etc.", -"'-' An expression followed by a minus sign optionally matches", -" the expression.", -"'[]' A string enclosed in square brackets matches any character in", -" that string, but no others. If the first character in the", -" string is a circumflex, the expression matches any character", -" except \"new-line\" and the characters in the string. For", -" example, \"[xyz]\" matches \"xx\" and \"zyx\", while \"[^xyz]\"", -" matches \"abc\" but not \"axb\". A range of characters may be", -" specified by two characters separated by \"-\". Note that,", -" [a-z] matches alphabetics, while [z-a] never matches.", -"The concatenation of regular expressions is a regular expression.", -0}; -#endif - -#define LMAX 512 -#define PMAX 256 - -#define CHAR 1 -#define BOL 2 -#define EOL 3 -#define ANY 4 -#define CLASS 5 -#define NCLASS 6 -#define STAR 7 -#define PLUS 8 -#define MINUS 9 -#define ALPHA 10 -#define DIGIT 11 -#define NALPHA 12 -#define PUNCT 13 -#define RANGE 14 -#define ENDPAT 15 - -int cflag=0, fflag=0, nflag=0, vflag=0, nfile=0, debug=0; - -char *pp, lbuf[LMAX], pbuf[PMAX]; - -char *cclass(); -char *pmatch(); - - -/*** Display a file name *******************************/ -void file(char *s) -{ - printf("File %s:\n", s); -} - -/*** Report unopenable file ****************************/ -void cant(char *s) -{ - fprintf(stderr, "%s: cannot open\n", s); -} - -/*** Give good help ************************************/ -void help(char **hp) -{ - char **dp; - - for (dp = hp; *dp; ++dp) - printf("%s\n", *dp); -} - -/*** Display usage summary *****************************/ -void usage(char *s) -{ - fprintf(stderr, "?GREP-E-%s\n", s); - fprintf(stderr, - "Usage: grep [-cfnv] pattern [file ...]. grep ? for help\n"); - exit(1); -} - -/*** Compile the pattern into global pbuf[] ************/ -void compile(char *source) -{ - char *s; /* Source string pointer */ - char *lp; /* Last pattern pointer */ - int c; /* Current character */ - int o; /* Temp */ - char *spp; /* Save beginning of pattern */ - - s = source; - if (debug) - printf("Pattern = \"%s\"\n", s); - pp = pbuf; - while (c = *s++) { - /* - * STAR, PLUS and MINUS are special. - */ - if (c == '*' || c == '+' || c == '-') { - if (pp == pbuf || - (o=pp[-1]) == BOL || - o == EOL || - o == STAR || - o == PLUS || - o == MINUS) - badpat("Illegal occurrance op.", source, s); - store(ENDPAT); - store(ENDPAT); - spp = pp; /* Save pattern end */ - while (--pp > lp) /* Move pattern down */ - *pp = pp[-1]; /* one byte */ - *pp = (c == '*') ? STAR : - (c == '-') ? MINUS : PLUS; - pp = spp; /* Restore pattern end */ - continue; - } - /* - * All the rest. - */ - lp = pp; /* Remember start */ - switch(c) { - - case '^': - store(BOL); - break; - - case '$': - store(EOL); - break; - - case '.': - store(ANY); - break; - - case '[': - s = cclass(source, s); - break; - - case ':': - if (*s) { - switch(tolower(c = *s++)) { - - case 'a': - case 'A': - store(ALPHA); - break; - - case 'd': - case 'D': - store(DIGIT); - break; - - case 'n': - case 'N': - store(NALPHA); - break; - - case ' ': - store(PUNCT); - break; - - default: - badpat("Unknown : type", source, s); - - } - break; - } - else badpat("No : type", source, s); - - case '\\': - if (*s) - c = *s++; - - default: - store(CHAR); - store(tolower(c)); - } - } - store(ENDPAT); - store(0); /* Terminate string */ - if (debug) { - for (lp = pbuf; lp < pp;) { - if ((c = (*lp++ & 0377)) < ' ') - printf("\\%o ", c); - else printf("%c ", c); - } - printf("\n"); - } -} - -/*** Compile a class (within []) ***********************/ -char *cclass(char *source, char *src) -/* char *source; // Pattern start -- for error msg. */ -/* char *src; // Class start */ -{ - char *s; /* Source pointer */ - char *cp; /* Pattern start */ - int c; /* Current character */ - int o; /* Temp */ - - s = src; - o = CLASS; - if (*s == '^') { - ++s; - o = NCLASS; - } - store(o); - cp = pp; - store(0); /* Byte count */ - while ((c = *s++) && c!=']') { - if (c == '\\') { /* Store quoted char */ - if ((c = *s++) == '\0') /* Gotta get something */ - badpat("Class terminates badly", source, s); - else store(tolower(c)); - } - else if (c == '-' && - (pp - cp) > 1 && *s != ']' && *s != '\0') { - c = pp[-1]; /* Range start */ - pp[-1] = RANGE; /* Range signal */ - store(c); /* Re-store start */ - c = *s++; /* Get end char and*/ - store(tolower(c)); /* Store it */ - } - else { - store(tolower(c)); /* Store normal char */ - } - } - if (c != ']') - badpat("Unterminated class", source, s); - if ((c = (pp - cp)) >= 256) - badpat("Class too large", source, s); - if (c == 0) - badpat("Empty class", source, s); - *cp = c; - return(s); -} - -/*** Store an entry in the pattern buffer **************/ -void store(int op) -{ - if (pp >= &pbuf[PMAX]) - error("Pattern too complex\n"); - *pp++ = op; -} - -/*** Report a bad pattern specification ****************/ -void badpat(char *message, char *source, char *stop) -/* char *message; // Error message */ -/* char *source; // Pattern start */ -/* char *stop; // Pattern end */ -{ - fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source); - fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n", - stop-source, stop[-1]); - error("?GREP-E-Bad pattern\n"); -} - -/*** Scan the file for the pattern in pbuf[] ***********/ -void grep(FILE *fp, char *fn) -/* FILE *fp; // File to process */ -/* char *fn; // File name (for -f option) */ -{ - int lno, count, m; - - lno = 0; - count = 0; - while (fgets(lbuf, LMAX, fp)) { - ++lno; - m = match(); - if ((m && !vflag) || (!m && vflag)) { - ++count; - if (!cflag) { - if (fflag && fn) { - file(fn); - fn = 0; - } - if (nflag) - printf("%d\t", lno); - printf("%s\n", lbuf); - } - } - } - if (cflag) { - if (fflag && fn) - file(fn); - printf("%d\n", count); - } -} - -/*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/ -void match() -{ - char *l; /* Line pointer */ - - for (l = lbuf; *l; ++l) { - if (pmatch(l, pbuf)) - return(1); - } - return(0); -} - -/*** Match partial line with pattern *******************/ -char *pmatch(char *line, char *pattern) -/* char *line; // (partial) line to match */ -/* char *pattern; // (partial) pattern to match */ -{ - char *l; /* Current line pointer */ - char *p; /* Current pattern pointer */ - char c; /* Current character */ - char *e; /* End for STAR and PLUS match */ - int op; /* Pattern operation */ - int n; /* Class counter */ - char *are; /* Start of STAR match */ - - l = line; - if (debug > 1) - printf("pmatch(\"%s\")\n", line); - p = pattern; - while ((op = *p++) != ENDPAT) { - if (debug > 1) - printf("byte[%d] = 0%o, '%c', op = 0%o\n", - l-line, *l, *l, op); - switch(op) { - - case CHAR: - if (tolower(*l++) != *p++) - return(0); - break; - - case BOL: - if (l != lbuf) - return(0); - break; - - case EOL: - if (*l != '\0') - return(0); - break; - - case ANY: - if (*l++ == '\0') - return(0); - break; - - case DIGIT: - if ((c = *l++) < '0' || (c > '9')) - return(0); - break; - - case ALPHA: - c = tolower(*l++); - if (c < 'a' || c > 'z') - return(0); - break; - - case NALPHA: - c = tolower(*l++); - if (c >= 'a' && c <= 'z') - break; - else if (c < '0' || c > '9') - return(0); - break; - - case PUNCT: - c = *l++; - if (c == 0 || c > ' ') - return(0); - break; - - case CLASS: - case NCLASS: - c = tolower(*l++); - n = *p++ & 0377; - do { - if (*p == RANGE) { - p += 3; - n -= 2; - if (c >= p[-2] && c <= p[-1]) - break; - } - else if (c == *p++) - break; - } while (--n > 1); - if ((op == CLASS) == (n <= 1)) - return(0); - if (op == CLASS) - p += n - 2; - break; - - case MINUS: - e = pmatch(l, p); /* Look for a match */ - while (*p++ != ENDPAT); /* Skip over pattern */ - if (e) /* Got a match? */ - l = e; /* Yes, update string */ - break; /* Always succeeds */ - - case PLUS: /* One or more ... */ - if ((l = pmatch(l, p)) == 0) - return(0); /* Gotta have a match */ - case STAR: /* Zero or more ... */ - are = l; /* Remember line start */ - while (*l && (e = pmatch(l, p))) - l = e; /* Get longest match */ - while (*p++ != ENDPAT); /* Skip over pattern */ - while (l >= are) { /* Try to match rest */ - if (e = pmatch(l, p)) - return(e); - --l; /* Nope, try earlier */ - } - return(0); /* Nothing else worked */ - - default: - printf("Bad op code %d\n", op); - error("Cannot happen -- match\n"); - } - } - return(l); -} - -/*** Report an error ***********************************/ -void error(char *s) -{ - fprintf(stderr, "%s", s); - exit(1); -} - -/*** Main program - parse arguments & grep *************/ -int main(int argc, char **argv) -{ - char *p; - int c, i; - int gotpattern; - - FILE *f; - - if (argc <= 1) - usage("No arguments"); - if (argc == 2 && argv[1][0] == '?' && argv[1][1] == 0) { - help(documentation); - help(patdoc); - return; - } - nfile = argc-1; - gotpattern = 0; - for (i=1; i < argc; ++i) { - p = argv[i]; - if (*p == '-') { - ++p; - while (c = *p++) { - switch(tolower(c)) { - - case '?': - help(documentation); - break; - - case 'C': - case 'c': - ++cflag; - break; - - case 'D': - case 'd': - ++debug; - break; - - case 'F': - case 'f': - ++fflag; - break; - - case 'n': - case 'N': - ++nflag; - break; - - case 'v': - case 'V': - ++vflag; - break; - - default: - usage("Unknown flag"); - } - } - argv[i] = 0; - --nfile; - } else if (!gotpattern) { - compile(p); - argv[i] = 0; - ++gotpattern; - --nfile; - } - } - if (!gotpattern) - usage("No pattern"); - if (nfile == 0) - grep(stdin, 0); - else { - fflag = fflag ^ (nfile > 0); - for (i=1; i < argc; ++i) { - if (p = argv[i]) { - if ((f=fopen(p, "r")) == NULL) - cant(p); - else { - grep(f, p); - fclose(f); - } - } - } - } -} - diff --git a/tests/47_switch_return.c b/tests/47_switch_return.c deleted file mode 100644 index 2fdb8bd..0000000 --- a/tests/47_switch_return.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -void fred(int x) -{ - switch (x) - { - case 1: printf("1\n"); return; - case 2: printf("2\n"); break; - case 3: printf("3\n"); return; - } - - printf("out\n"); -} - -int main() -{ - fred(1); - fred(2); - fred(3); - - return 0; -} - diff --git a/tests/47_switch_return.expect b/tests/47_switch_return.expect deleted file mode 100644 index b6deb7e..0000000 --- a/tests/47_switch_return.expect +++ /dev/null @@ -1,4 +0,0 @@ -1 -2 -out -3 diff --git a/tests/48_nested_break.c b/tests/48_nested_break.c deleted file mode 100644 index 4b01a99..0000000 --- a/tests/48_nested_break.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int a; -char b; - -a = 0; -while (a < 2) -{ - printf("%d", a++); - break; - - b = 'A'; - while (b < 'C') - { - printf("%c", b++); - } - printf("e"); -} -printf("\n"); - -int main() -{ - return 0; -} diff --git a/tests/48_nested_break.expect b/tests/48_nested_break.expect deleted file mode 100644 index 573541a..0000000 --- a/tests/48_nested_break.expect +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/49_bracket_evaluation.c b/tests/49_bracket_evaluation.c deleted file mode 100644 index b4303c6..0000000 --- a/tests/49_bracket_evaluation.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -struct point -{ - double x; - double y; -}; - -struct point point_array[100]; - -int main() -{ - int my_point = 10; - - point_array[my_point].x = 12.34; - point_array[my_point].y = 56.78; - - printf("%f, %f\n", point_array[my_point].x, point_array[my_point].y); - - return 0; -} diff --git a/tests/49_bracket_evaluation.expect b/tests/49_bracket_evaluation.expect deleted file mode 100644 index 1da66db..0000000 --- a/tests/49_bracket_evaluation.expect +++ /dev/null @@ -1 +0,0 @@ -12.340000, 56.780000 diff --git a/tests/50_logical_second_arg.c b/tests/50_logical_second_arg.c deleted file mode 100644 index f4be825..0000000 --- a/tests/50_logical_second_arg.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -int fred() -{ - printf("fred\n"); - return 0; -} - -int joe() -{ - printf("joe\n"); - return 1; -} - -int main() -{ - printf("%d\n", fred() && joe()); - printf("%d\n", fred() || joe()); - printf("%d\n", joe() && fred()); - printf("%d\n", joe() || fred()); - printf("%d\n", fred() && (1 + joe())); - printf("%d\n", fred() || (0 + joe())); - printf("%d\n", joe() && (0 + fred())); - printf("%d\n", joe() || (1 + fred())); - - return 0; -} diff --git a/tests/50_logical_second_arg.expect b/tests/50_logical_second_arg.expect deleted file mode 100644 index d6174ae..0000000 --- a/tests/50_logical_second_arg.expect +++ /dev/null @@ -1,20 +0,0 @@ -fred -0 -fred -joe -1 -joe -fred -0 -joe -1 -fred -0 -fred -joe -1 -joe -fred -0 -joe -1 diff --git a/tests/51_static.c b/tests/51_static.c deleted file mode 100644 index 3e93ba9..0000000 --- a/tests/51_static.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -static int fred = 1234; -static int joe; - -void henry() -{ - static int fred = 4567; - - printf("%d\n", fred); - fred++; -} - -void main() -{ - printf("%d\n", fred); - henry(); - henry(); - henry(); - henry(); - printf("%d\n", fred); - fred = 8901; - joe = 2345; - printf("%d\n", fred); - printf("%d\n", joe); -} diff --git a/tests/51_static.expect b/tests/51_static.expect deleted file mode 100644 index 18224fa..0000000 --- a/tests/51_static.expect +++ /dev/null @@ -1,8 +0,0 @@ -1234 -4567 -4568 -4569 -4570 -1234 -8901 -2345 diff --git a/tests/52_unnamed_enum.c b/tests/52_unnamed_enum.c deleted file mode 100644 index 7e99bfd..0000000 --- a/tests/52_unnamed_enum.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -enum fred { a, b, c }; - -printf("a=%d\n", a); -printf("b=%d\n", b); -printf("c=%d\n", c); - -enum fred d; - -typedef enum { e, f, g } h; -typedef enum { i, j, k } m; - -printf("e=%d\n", e); -printf("f=%d\n", f); -printf("g=%d\n", g); - -printf("i=%d\n", i); -printf("j=%d\n", j); -printf("k=%d\n", k); - -void main() -{ -} diff --git a/tests/52_unnamed_enum.expect b/tests/52_unnamed_enum.expect deleted file mode 100644 index 84f2ac8..0000000 --- a/tests/52_unnamed_enum.expect +++ /dev/null @@ -1,9 +0,0 @@ -a=0 -b=1 -c=2 -e=0 -f=1 -g=2 -i=0 -j=1 -k=2 diff --git a/tests/54_goto.c b/tests/54_goto.c deleted file mode 100644 index 65ee7e2..0000000 --- a/tests/54_goto.c +++ /dev/null @@ -1,52 +0,0 @@ -#include - -void fred() -{ - printf("In fred()\n"); - goto done; - printf("In middle\n"); -done: - printf("At end\n"); -} - -void joe() -{ - int b = 5678; - - printf("In joe()\n"); - - { - int c = 1234; - printf("c = %d\n", c); - goto outer; - printf("uh-oh\n"); - } - -outer: - - printf("done\n"); -} - -void henry() -{ - int a; - - printf("In henry()\n"); - goto inner; - - { - int b; -inner: - b = 1234; - printf("b = %d\n", b); - } - - printf("done\n"); -} - -void main() -{ - fred(); - joe(); - henry(); -} diff --git a/tests/54_goto.expect b/tests/54_goto.expect deleted file mode 100644 index 8e553fa..0000000 --- a/tests/54_goto.expect +++ /dev/null @@ -1,8 +0,0 @@ -In fred() -At end -In joe() -c = 1234 -done -In henry() -b = 1234 -done diff --git a/tests/55_section.c b/tests/55_section.c deleted file mode 100644 index 55ce31f..0000000 --- a/tests/55_section.c +++ /dev/null @@ -1,12 +0,0 @@ -//#include - -int main(int argc, char* argv[]) { - int32_t aaa = 0; - int32_t bbb = 0; - if ( aaa == bbb && (aaa & bbb) != 0) { - for (int32_t iii=0; iii< 562; ++iii) { - aaa+= 1.0; - } - } - return -1; -} diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index e7dd4e3..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -TESTS= 00_assignment.test \ - 01_comment.test \ - 02_printf.test \ - 03_struct.test \ - 04_for.test \ - 05_array.test \ - 06_case.test \ - 07_function.test \ - 08_while.test \ - 09_do_while.test \ - 10_pointer.test \ - 11_precedence.test \ - 12_hashdefine.test \ - 13_integer_literals.test \ - 14_if.test \ - 15_recursion.test \ - 16_nesting.test \ - 17_enum.test \ - 18_include.test \ - 19_pointer_arithmetic.test \ - 20_pointer_comparison.test \ - 21_char_array.test \ - 22_floating_point.test \ - 23_type_coercion.test \ - 24_math_library.test \ - 25_quicksort.test \ - 26_character_constants.test \ - 28_strings.test \ - 29_array_address.test \ - 30_hanoi.test \ - 31_args.test \ - 32_led.test \ - 33_ternary_op.test \ - 34_array_assignment.test \ - 35_sizeof.test \ - 36_array_initialisers.test \ - 37_sprintf.test \ - 38_multiple_array_index.test \ - 39_typedef.test \ - 40_stdio.test \ - 41_hashif.test \ - 43_void_param.test \ - 44_scoped_declarations.test \ - 45_empty_for.test \ - 47_switch_return.test \ - 48_nested_break.test \ - 49_bracket_evaluation.test \ - 50_logical_second_arg.test \ - 51_static.test \ - 52_unnamed_enum.test \ - 54_goto.test - -%.test: %.expect %.c - @echo Test: $*... - @if [ "x`echo $* | grep args`" != "x" ]; \ - then \ - ../eci $*.c - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ - else \ - ../eci $*.c 2>&1 >$*.output; \ - fi - @if [ "x`diff -qbu $*.expect $*.output`" != "x" ]; \ - then \ - echo "error in test $*"; \ - diff -u $*.expect $*.output; \ - rm -f $*.output; \ - exit 1; \ - fi; \ - rm -f $*.output - -all: test - -test: $(TESTS) - @echo "test passed" diff --git a/tests/cpp/000-declare_variable.cpp b/tests/cpp/000-declare_variable.cpp new file mode 100644 index 0000000..cd5aa6c --- /dev/null +++ b/tests/cpp/000-declare_variable.cpp @@ -0,0 +1,3 @@ +/* @copyright Edouard DUPIN */ +// Declare variable +int plop; diff --git a/tests/js/000-declare_variable.js b/tests/js/000-declare_variable.js new file mode 100644 index 0000000..2233a45 --- /dev/null +++ b/tests/js/000-declare_variable.js @@ -0,0 +1,3 @@ +/* @copyright Edouard DUPIN */ +// Declare variable +var plop;