-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move specs into separate files
- Loading branch information
1 parent
256dcb1
commit 7c6a316
Showing
4 changed files
with
125 additions
and
146 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
spec = { | ||
"abstractStubFormatString" : """\ | ||
//{base}:top// | ||
//{base}:import// | ||
import java.util.*; | ||
public abstract class {base}{ext} /*{base}:class*/ {{ | ||
public static final String $className = "{base}"; | ||
public static {base} parse(Scan scn$, Trace trace$) {{ | ||
Token t$ = scn$.cur(); | ||
Token.Match match$ = t$.match; | ||
switch(match$) {{ | ||
{cases} | ||
default: | ||
throw new PLCCException( | ||
"Parse error", | ||
"{base} cannot begin with " + t$.errString() | ||
); | ||
}} | ||
}} | ||
//{base}// | ||
}} | ||
""", | ||
|
||
"stubFormatString" : """\ | ||
//{cls}:top// | ||
//{cls}:import// | ||
import java.util.*; | ||
// {ruleString} | ||
public class {cls}{ext} /*{cls}:class*/ {{ | ||
public static final String $className = "{cls}"; | ||
public static final String $ruleString = | ||
"{ruleString}"; | ||
{decls} | ||
public {cls}({params}) {{ | ||
//{cls}:init// | ||
{inits} | ||
}} | ||
public static {cls} parse(Scan scn$, Trace trace$) {{ | ||
if (trace$ != null) | ||
trace$ = trace$.nonterm("{lhs}", scn$.lno); | ||
{parse} | ||
}} | ||
//{cls}// | ||
}} | ||
""", | ||
"extendFormatString" : ' extends {cls}', | ||
"declFormatString" : 'public {fieldType} {field};', | ||
"initFormatString" : 'this.{field} = {field};', | ||
"paramFormatString" : '{fieldType} {field}', | ||
"semFlag" : 'semantics', | ||
"lineComment" : '//', | ||
"blockCommentStart" : "/*", | ||
"blockCommentEnd" : "*/", | ||
"destFlag" : 'destdir', | ||
"fileExt" : '.java' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
spec = { | ||
"abstractStubFormatString" : """\ | ||
#{base}:top# | ||
#{base}:import# | ||
class {base}({ext}): #{base}:class# | ||
className = "{base}" | ||
#{base}# | ||
""", | ||
|
||
"stubFormatString" : """\ | ||
#{cls}:top# | ||
#{cls}:import# | ||
# {ruleString} | ||
class {cls}({ext}): #{cls}:class# | ||
className = "{cls}" | ||
ruleString = "{ruleString}" | ||
{decls} | ||
def __init__({params}): | ||
#{cls}:init# | ||
{inits} | ||
#{cls}# | ||
""", | ||
"extendFormatString" : '{cls}', | ||
"declFormatString" : '{field} = None', | ||
"initFormatString" : 'self.{field} = {field}', | ||
"paramFormatString" : '{field}', | ||
"semFlag" : 'python_semantics', | ||
"lineComment" : '#', | ||
"blockCommentStart" : "'''", | ||
"blockCommentEnd" : "'''", | ||
"destFlag" : 'python_destdir', | ||
"fileExt" : '.py' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters