@Test public void testSubroutineDeclarations() throws IOException { String line = ""; List<String> source = new ArrayList<String>(); try (InputStream is = TextParserTest.class.getResourceAsStream("/all_sub_types.prg"); BufferedReader br = new BufferedReader(new InputStreamReader(is))) { assertThat(is).isNotNull(); while ((line = br.readLine()) != null) { source.add(line); } } CclScript cclScript = parser.parseCclScript("all_sub_types", source); assertThat(cclScript.getName()).isEqualTo("all_sub_types"); ScriptDocumentation documentation = cclScript.getScriptDocumentation(); List<RecordStructure> recordStructures = cclScript.getRecordStructures(); List<Subroutine> subroutines = cclScript.getSubroutines(); assertThat(documentation.getBoundTransaction()).isEqualTo(98765); assertThat(documentation.getDescription()).isEqualTo( "This is an example script with all types of subroutine declarations, predeclared, in-line and undeclared. It has arguments and a bound transaction."); assertThat(documentation.getScriptArguments().size()).isEqualTo(2); assertThat(documentation.getScriptArguments().get(0).getDescription()).isEqualTo("This is the first argument."); assertThat(documentation.getScriptArguments().get(1).getDescription()) .isEqualTo("This is the second argument."); assertThat(recordStructures.size()).isEqualTo(5); assertThat(recordStructures.get(0).getName()).isEqualTo("test1"); assertThat(recordStructures.get(0).getDescription()).isEqualTo(""); assertThat(recordStructures.get(0).getRootLevelMemberCount()).isEqualTo(2); assertThat(recordStructures.get(0).getRootLevelMember(0).getName()).isEqualTo("field1"); assertThat(recordStructures.get(0).getRootLevelMember(0).getDescription()).isEqualTo(""); assertThat(recordStructures.get(0).getRootLevelMember(1).getName()).isEqualTo("field2"); assertThat(recordStructures.get(0).getRootLevelMember(1).getDescription()).isEqualTo(""); assertThat(recordStructures.get(1).getStructureType()).isEqualTo(InterfaceStructureType.REPLY); assertThat(recordStructures.get(1).getName()).isEqualTo("test"); assertThat(recordStructures.get(1).getDescription()).isEqualTo(""); assertThat(recordStructures.get(1).getRootLevelMemberCount()).isEqualTo(3); assertThat(recordStructures.get(1).getRootLevelMember(0).getName()).isEqualTo("field"); assertThat(recordStructures.get(1).getRootLevelMember(1).getName()).isEqualTo("status_data"); assertThat(recordStructures.get(1).getRootLevelMember(2).getName()).isEqualTo("cclsource:test.inc"); assertThat(recordStructures.get(2).getStructureType()).isEqualTo(InterfaceStructureType.REQUEST); assertThat(recordStructures.get(2).getName()).isEqualTo("the_request"); assertThat(recordStructures.get(2).getDescription()).isEqualTo("This is the request record structure."); assertThat(recordStructures.get(2).getRootLevelMemberCount()).isEqualTo(4); assertThat(recordStructures.get(2).getRootLevelMember(0).getName()).isEqualTo("first_list"); assertThat(recordStructures.get(2).getRootLevelMember(1).getName()).isEqualTo("second_list"); assertThat(recordStructures.get(2).getRootLevelMember(2).getName()).isEqualTo("shared_name"); assertThat(recordStructures.get(2).getRootLevelMember(3).getName()).isEqualTo("shared_name_list"); assertThat(recordStructures.get(3).getStructureType()).isEqualTo(InterfaceStructureType.REPLY); assertThat(recordStructures.get(3).getName()).isEqualTo("the_reply"); assertThat(recordStructures.get(3).getDescription()).isEqualTo("What-what?"); assertThat(recordStructures.get(3).getRootLevelMemberCount()).isEqualTo(1); assertThat(recordStructures.get(3).getRootLevelMember(0).getName()).isEqualTo("success_ind"); assertThat(recordStructures.get(4).getStructureType()).isNull(); assertThat(recordStructures.get(4).getName()).isEqualTo("med_data"); assertThat(recordStructures.get(4).getDescription()).isEqualTo("This really doesn't have to do with anything"); assertThat(recordStructures.get(4).getRootLevelMemberCount()).isEqualTo(1); assertThat(recordStructures.get(4).getRootLevelMember(0).getName()).isEqualTo("char_field"); assertThat(subroutines.size()).isEqualTo(10); assertThat(subroutines.get(0).getName()).isEqualTo("declared_subroutine_doc"); assertThat(subroutines.get(0).getDescription()).isEqualTo("This is a declared subroutine with documentation."); assertThat(subroutines.get(0).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.I4)); assertThat(subroutines.get(0).getReturnDataDescription()).isEqualTo("Some I4 value."); assertThat(subroutines.get(1).getName()).isEqualTo("get_birth_dt_tm"); assertThat(subroutines.get(1).getDescription()).isEqualTo( "This is a simple subroutine declared in-line that has its documentation wrapped in leading stars."); assertThat(subroutines.get(1).<SimpleDataTyped> getReturnDataType()).isEqualTo(null); assertThat(subroutines.get(1).getReturnDataDescription()).isEmpty(); assertThat(subroutines.get(2).getName()).isEqualTo("declared_subroutine_no_doc"); assertThat(subroutines.get(2).getDescription()).isEmpty(); assertThat(subroutines.get(2).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.VC)); assertThat(subroutines.get(2).getReturnDataDescription()).isEmpty(); assertThat(subroutines.get(3).getName()).isEqualTo("get_last_name"); assertThat(subroutines.get(3).getDescription()).isEqualTo( "This is a subroutine declared in-line without leading stars in its documentation. It also has scope!"); assertThat(subroutines.get(3).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.VC)); assertThat(subroutines.get(3).getReturnDataDescription()).isEqualTo("The last name of the person found"); assertThat(subroutines.get(4).getName()).isEqualTo("undeclared_subroutine_no_doc"); assertThat(subroutines.get(4).getDescription()).isEmpty(); assertThat(subroutines.get(4).<SimpleDataTyped> getReturnDataType()).isEqualTo(Subroutine.UNKNOWN_RETURN_TYPE); assertThat(subroutines.get(4).getReturnDataDescription()).isEmpty(); assertThat(subroutines.get(5).getName()).isEqualTo("get_ssn"); assertThat(subroutines.get(5).getDescription()) .isEqualTo("This subroutine has no declaration, so the information about it will be severely limited."); assertThat(subroutines.get(5).<SimpleDataTyped> getReturnDataType()).isEqualTo(Subroutine.UNKNOWN_RETURN_TYPE); assertThat(subroutines.get(5).getReturnDataDescription()).isEqualTo("The given person's SSN."); assertThat(subroutines.get(6).getName()).isEqualTo("untyped_variables"); assertThat(subroutines.get(6).getDescription()).isEqualTo("a subroutine with untyped variables."); assertThat(subroutines.get(6).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.I2)); assertThat(subroutines.get(6).getArguments().size()).isEqualTo(3); assertThat(subroutines.get(6).getArguments().get(0).getName()).isEqualTo("one"); assertThat(subroutines.get(6).getArguments().get(0).isByRef()).isEqualTo(false); assertThat(subroutines.get(6).getArguments().get(0).getDataType()).isEqualTo(DataType.UNKNOWN); assertThat(subroutines.get(6).getArguments().get(1).getName()).isEqualTo("two"); assertThat(subroutines.get(6).getArguments().get(1).isByRef()).isEqualTo(false); assertThat(subroutines.get(6).getArguments().get(1).getDataType()).isEqualTo(DataType.UNKNOWN); assertThat(subroutines.get(6).getArguments().get(2).getName()).isEqualTo("three"); assertThat(subroutines.get(6).getArguments().get(2).isByRef()).isEqualTo(false); assertThat(subroutines.get(6).getArguments().get(2).getDataType()).isEqualTo(DataType.UNKNOWN); assertThat(subroutines.get(7).getName()).isEqualTo("untyped_variables_inline"); assertThat(subroutines.get(7).getDescription()).isEqualTo("an inline subroutine with untyped variables."); assertThat(subroutines.get(7).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.I2)); assertThat(subroutines.get(7).getArguments().size()).isEqualTo(3); assertThat(subroutines.get(7).getArguments().get(0).getName()).isEqualTo("one"); assertThat(subroutines.get(7).getArguments().get(0).isByRef()).isEqualTo(false); assertThat(subroutines.get(7).getArguments().get(0).getDataType()).isEqualTo(DataType.UNKNOWN); assertThat(subroutines.get(7).getArguments().get(1).getName()).isEqualTo("two"); assertThat(subroutines.get(7).getArguments().get(1).isByRef()).isEqualTo(false); assertThat(subroutines.get(7).getArguments().get(1).getDataType()).isEqualTo(DataType.UNKNOWN); assertThat(subroutines.get(7).getArguments().get(2).getName()).isEqualTo("three"); assertThat(subroutines.get(7).getArguments().get(2).isByRef()).isEqualTo(false); assertThat(subroutines.get(7).getArguments().get(2).getDataType()).isEqualTo(DataType.UNKNOWN); assertThat(subroutines.get(8).getName()).isEqualTo("commented_multiline"); assertThat(subroutines.get(8).getDescription()).isEqualTo("a multiline subroutine littered with comments."); assertThat(subroutines.get(8).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.W8)); assertThat(subroutines.get(8).getArguments().size()).isEqualTo(4); assertThat(subroutines.get(8).getArguments().get(0).getName()).isEqualTo("one"); assertThat(subroutines.get(8).getArguments().get(0).isByRef()).isEqualTo(true); assertThat(subroutines.get(8).getArguments().get(0).getDataType()).isEqualTo(DataType.VC); assertThat(subroutines.get(8).getArguments().get(1).getName()).isEqualTo("two"); assertThat(subroutines.get(8).getArguments().get(1).isByRef()).isEqualTo(false); assertThat(subroutines.get(8).getArguments().get(1).getDataType()).isEqualTo(DataType.I4); assertThat(subroutines.get(8).getArguments().get(2).getName()).isEqualTo("three"); assertThat(subroutines.get(8).getArguments().get(2).isByRef()).isEqualTo(false); assertThat(subroutines.get(8).getArguments().get(2).getDataType()).isEqualTo(DataType.F8); assertThat(subroutines.get(8).getArguments().get(3).getName()).isEqualTo("four"); assertThat(subroutines.get(8).getArguments().get(3).isByRef()).isEqualTo(false); assertThat(subroutines.get(8).getArguments().get(3).getDataType()).isEqualTo(DataType.DQ8); assertThat(subroutines.get(9).getName()).isEqualTo("commented_multiline_inline"); assertThat(subroutines.get(9).getDescription()) .isEqualTo("an inline multiline subroutine littered with comments."); assertThat(subroutines.get(9).<SimpleDataTyped> getReturnDataType()) .isEqualTo(new SimpleDataTyped(DataType.I4)); assertThat(subroutines.get(9).getArguments().size()).isEqualTo(4); assertThat(subroutines.get(9).getArguments().get(0).getName()).isEqualTo("one"); assertThat(subroutines.get(9).getArguments().get(0).isByRef()).isEqualTo(false); assertThat(subroutines.get(9).getArguments().get(0).getDataType()).isEqualTo(DataType.VC); assertThat(subroutines.get(9).getArguments().get(1).getName()).isEqualTo("two"); assertThat(subroutines.get(9).getArguments().get(1).isByRef()).isEqualTo(true); assertThat(subroutines.get(9).getArguments().get(1).getDataType()).isEqualTo(DataType.I4); assertThat(subroutines.get(9).getArguments().get(2).getName()).isEqualTo("three"); assertThat(subroutines.get(9).getArguments().get(2).isByRef()).isEqualTo(false); assertThat(subroutines.get(9).getArguments().get(2).getDataType()).isEqualTo(DataType.F8); assertThat(subroutines.get(9).getArguments().get(3).getName()).isEqualTo("four"); assertThat(subroutines.get(9).getArguments().get(3).isByRef()).isEqualTo(false); assertThat(subroutines.get(9).getArguments().get(3).getDataType()).isEqualTo(DataType.DQ8); }
public CclScript parseCclScript(final String scriptName, final List<String> source) { return parse(scriptName, source, new ScriptDocumentationFactory(), scriptFactory); }
TextParser { public CclScript parseCclScript(final String scriptName, final List<String> source) { return parse(scriptName, source, new ScriptDocumentationFactory(), scriptFactory); } }
TextParser { public CclScript parseCclScript(final String scriptName, final List<String> source) { return parse(scriptName, source, new ScriptDocumentationFactory(), scriptFactory); }  }
TextParser { public CclScript parseCclScript(final String scriptName, final List<String> source) { return parse(scriptName, source, new ScriptDocumentationFactory(), scriptFactory); }  CclScript parseCclScript(final String scriptName, final List<String> source); IncludeFile parseIncludeFile(final String includeName, final List<String> source); }
TextParser { public CclScript parseCclScript(final String scriptName, final List<String> source) { return parse(scriptName, source, new ScriptDocumentationFactory(), scriptFactory); }  CclScript parseCclScript(final String scriptName, final List<String> source); IncludeFile parseIncludeFile(final String includeName, final List<String> source);  }