All Downloads are FREE. Search and download functionalities are using the official Maven repository.

s.hnbt.0.0.1.source-code.StringParser.g4 Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
/** A grand parser for Java String literals, excluding quotes. */
parser grammar StringParser;

options {tokenVocab = StringLexer;}

@header {
package me.kenzierocks.hnbt.grammar;

import me.kenzierocks.hnbt.util.StringUtil;
}

stringNoQuotes
    returns [String unescaped]
    locals [StringBuilder str]
    @init {
        $str = new StringBuilder();
    }
    @after {
        $unescaped = $str.toString();
    }
    : ( esc=EscapeSequence {$str.append(StringUtil.unescapeEscapeSequence($esc.text));}
      | uesc=UnicodeEscape {$str.append(StringUtil.unescapeUnicodeEscape($uesc.text));}
      | oesc=OctalEscape {$str.append(StringUtil.unescapeOctalEscape($oesc.text));}
      | raw=RawInputCharacter {$str.append($raw.text);}
      )*
    ;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy