9eb80e91a6
* 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).
70 lines
2.1 KiB
Groovy
70 lines
2.1 KiB
Groovy
import com.jdblabs.jlp.*
|
|
import org.parboiled.Parboiled
|
|
import org.parboiled.parserunners.*
|
|
|
|
"Making the standard parser."
|
|
"---------------------------"
|
|
|
|
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())
|
|
|
|
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
|
|
%% Markdown lines (tenth line)
|
|
%% Still markdown (eleventh line)
|
|
Twelfth line is a code line"""
|
|
|
|
simpleResult = parseRunner.run(testLine)
|
|
}
|
|
|
|
vbsTest = { parseRunner ->
|
|
println "Parsing vbs_db_records.hrl into 'vbsResult'."
|
|
println "--------------------------------------------"
|
|
|
|
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"
|
|
|
|
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
|
|
}
|
|
|
|
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]
|
|
}
|