
org.textmapper.tool.templates.java.ltp Maven / Gradle / Ivy
${template main-}
${file opts.prefix+'Lexer.java'}${call java_lexer.unit}${end-}
${if parser-}
${file opts.prefix+'Parser.java'}${call java_parser.unit}${end-}
${if opts.gentree-}
${file opts.prefix+'Tree.java'}${call java_tree.unit}${end-}
${end-}
${if opts.genbison-}
${file opts.prefix.toLowerCase()+'.y'}${call bison.unit('$$')}${end-}
${end-}
${if opts.genast-}
${call java_ast.unit-}
${end-}
${if opts.genmain-}
${file opts.prefix+'Main.java'}${call java_main.unit}${end-}
${end-}
${end-}
${end}
${template lexerAction(rule)-}
${call java_lexer.lexerAction('token.value', 'token.symbol') for rule-}
${end}
${template parserAction(rule)-}
${rule->java_parser.parserAction()-}
${end}
${template astAction(code)-}
${eval code, '#[generated action for '+self+']'-}
${end}
${query symText(property) =
self.rightOffset == -1
? (property == 'value' ? 'null' : '-1')
: (self.isLeft ? 'tmLeft' : 'tmStack[tmHead' + (self.rightOffset > 0 ? ' - ' + self.rightOffset : '') + ']')
+ '.' + property }
${template symAccess(property)-}
${assert ['value', 'line', 'column', 'offset', 'endline', 'endcolumn', 'endoffset'].contains(property)-}
${if property == 'value'-}
${symbol->type() ? '((' + symbol->type() + ')' + self->symText(property) + ')' : self->symText(property) -}
${else-}
${self->symText(property)-}
${end-}
${end}
${template imports-}
${end}
${template classcode-}
private static final boolean DEBUG_SYNTAX = false;
${end}
${query package() = opts.package ? opts.package : 'com.test' }
${cached query type() = context.opts.genast ? self->java_ast.type() : self.type is LiRawAstType ? self.type : null }
${query escapeJavaReserved() =
[
'String', 'Integer', 'Long', 'Boolean', 'LinkedHashMap', 'HashMap', 'Map',
'List', 'ArrayList', 'LinkedList', 'TextSource', 'Node',
'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'continue', 'const',
'default', 'do', 'double', 'else', 'enum', 'extends', 'false', 'final', 'finally', 'float', 'for',
'goto', 'if', 'implements', 'import', 'instanceof', 'int', 'interface', 'long', 'native', 'new',
'null', 'package', 'private', 'protected', 'public', 'return', 'short', 'static', 'strictfp',
'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'true', 'try', 'void',
'volatile', 'while'
].contains(self) ? '_' + self : self }
${template header-}
${if opts.genCopyright && syntax.copyrightHeader-}
/**
${foreach line in util.shiftRightWithSpaces(syntax.copyrightHeader, 1).split('\n')-}
*${line}
${end-}
*/
${end-}
${end}
${query symbolClassName() = 'Span'}
${query err_location(symvar,lexervar) = self->util.location(', ' + symvar + '.', '', '')}
${template err_location_safe(symvar,lexervar)-}
${foreach l in self->util.locationList()-}
, ${symvar} == null ? ${lexervar}.get${util.toFirstUpper(l.startsWith('end') ? l.substring(3) : l)}() : ${symvar}.${l}${end-}
${end}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy