Support for multi=line comments, detects file type.
* Added support for multi-line comments to the JLPPegParser grammar implementation. * Added a Java sample file. * Updated test script to add convenience functions for the java test file and for using a TracingParseRunner for parse runs. * Added an option, `--css-file`, to allow the caller to specify their own css file. * Added basic logic to the Processor class to detect source file types and build a parser and a generator for that source type. Support currently exists for the following languages: C (.c, .h), C++ (.cpp, .c++, .hpp, .h++), Erlang (.erl), Groovy (.groovy), Java (.java), JavaScript (.js).
This commit is contained in:
26
resources/main/Test.java
Normal file
26
resources/main/Test.java
Normal file
@ -0,0 +1,26 @@
|
||||
package test;
|
||||
|
||||
import java.util.Array;
|
||||
|
||||
/** This is a test class. Mainly for testing my parser.
|
||||
* It should work. And now we are just filing space.
|
||||
* @author Jonathan Bernard
|
||||
* @copyright JDB Labs 2011 */
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
| @org test-ref
|
||||
| This is an embedded comment.
|
||||
| It spreads over at least 3 lines.
|
||||
| And this is the third line.
|
||||
*/
|
||||
|
||||
public static void main(String[] args) {
|
||||
/** Yes, this is a hello world example. */
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
|
||||
/// This is a single-line comment block. */ /** Other comment
|
||||
/// modifiers should not matter within this block.
|
||||
/// @org last-doc
|
||||
}
|
@ -1,21 +1,30 @@
|
||||
import com.jdblabs.jlp.*
|
||||
import org.parboiled.Parboiled
|
||||
import org.parboiled.parserunners.ReportingParseRunner
|
||||
import org.parboiled.parserunners.RecoveringParseRunner
|
||||
import org.parboiled.parserunners.*
|
||||
|
||||
"Making the standard parser."
|
||||
"---------------------------"
|
||||
|
||||
parser = Parboiled.createParser(JLPPegParser.class)
|
||||
parseRunner = new ReportingParseRunner(parser.SourceFile())
|
||||
jp = Parboiled.createParser(JLPPegParser.class)
|
||||
ep = Parboiled.createParser(JLPPegParser, '%%')
|
||||
jrpr = new ReportingParseRunner(jp.SourceFile())
|
||||
jtpr = new TracingParseRunner(jp.SourceFile())
|
||||
erpr = new ReportingParseRunner(ep.SourceFile())
|
||||
etpr = new TracingParseRunner(ep.SourceFile())
|
||||
|
||||
simpleTest = {
|
||||
vbsFile = new File('vbs_db_records.hrl')
|
||||
javaFile = new File('Test.java')
|
||||
docsDir = new File('jlp-docs')
|
||||
docsDir.mkdirs()
|
||||
|
||||
simpleTest = { parseRunner ->
|
||||
|
||||
println "Parsing the simple test into 'result'."
|
||||
println "--------------------------------------"
|
||||
|
||||
testLine = """%% This the first test line.
|
||||
%% Second Line
|
||||
Actual third line that screws stuff up.
|
||||
%% Third Line \n\n Fifth line \n\n %% Seventh line \n\n
|
||||
%% @author Eigth Line
|
||||
%% @Example Ninth Line
|
||||
@ -26,22 +35,35 @@ simpleTest = {
|
||||
simpleResult = parseRunner.run(testLine)
|
||||
}
|
||||
|
||||
vbsTest = {
|
||||
vbsTest = { parseRunner ->
|
||||
println "Parsing vbs_db_records.hrl into 'vbsResult'."
|
||||
println "--------------------------------------------"
|
||||
|
||||
vbsTestFile = new File('vbs_db_records.hrl')
|
||||
println "vbsTestFile is ${vbsTestFile.exists() ? 'present' : 'absent'}."
|
||||
vbsTestInput = vbsTestFile.text
|
||||
println "vbsFile is ${vbsFile.exists() ? 'present' : 'absent'}."
|
||||
vbsTestInput = vbsFile.text
|
||||
|
||||
vbsParsed = parseRunner.run(vbsTestInput)
|
||||
|
||||
vbsResult = LiterateMarkdownGenerator.generateDocuments(["vbs_db_records.hrl": vbsParsed.resultValue])."vbs_db_records.hrl"
|
||||
/*vbsResult = LiterateMarkdownGenerator.generateDocuments(["vbs_db_records.hrl": vbsParsed.resultValue])."vbs_db_records.hrl"
|
||||
|
||||
println "Writing to file 'vbs_db_records.html'."
|
||||
println "--------------------------------------"
|
||||
|
||||
(new File('vbs_db_records.html')).withWriter { out -> out.println vbsResult }
|
||||
|
||||
return [vbsParsed, vbsResult]
|
||||
return [vbsParsed, vbsResult]*/
|
||||
return vbsParsed
|
||||
}
|
||||
|
||||
javaTest = { parseRunner ->
|
||||
println "Parsing Test.java into 'javaResult'."
|
||||
println "------------------------------------"
|
||||
|
||||
println "javaFile is ${javaFile.exists() ? 'present' : 'absent'}."
|
||||
javaTestInput = javaFile.text
|
||||
|
||||
javaParsed = parseRunner.run(javaTestInput)
|
||||
javaSF = javaParsed.valueStack.peek()
|
||||
|
||||
return [javaParsed: javaParsed, javaSF: javaSF]
|
||||
}
|
||||
|
Reference in New Issue
Block a user