Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text mate generator #1206

Draft
wants to merge 11 commits into
base: dev
Choose a base branch
from
34 changes: 34 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,40 @@ object vercors extends Module {
}
}

object textMateGenerator extends VercorsModule {

def base = T {
settings.src / "parsers" / "antlr4"
}

override def key: String = "textMateGenerator"

override def deps: T[Agg[Dep]] = Agg(ivy"org.antlr:antlr4-runtime:4.8", ivy"com.lihaoyi::upickle:3.1.3")

override def bareResources =
T.sources(
base() / "SpecLexer.g4",
base() / "LangPVLLexer.g4",
base() / "LexerAdaptor.java",
)

override def moduleDeps = Seq(hre)

object antlrGrammarParser extends parsers.GenModule {
override def base = T {
settings.src / "textMateGenerator" / "antlr4"
}

override def lexer: String = "ANTLRv4Lexer.g4"

override def parser: String = "ANTLRv4Parser.g4"

override def deps: Seq[String] = Seq("LexBasic.g4")
}

override def generatedSources = T { Seq(antlrGrammarParser.generate()) }
}

object rewrite extends VercorsModule {
def key = "rewrite"
def deps = Agg(
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/antlr4/LLVMSpecParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LangLLVMSpecParser, SpecParser;

langExpr: expression;
langId: Identifier;
langConstInt: Constant;
langConstInt: IntegerConstant;
langType: type;
langStatement: EOF EOF;
langStatic: EOF EOF;
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/antlr4/LangPVLLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ HEX_DIGIT
;

mode DEFAULT_MODE;
Identifier : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
Identifier : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;

COMMENT : '/*' .*? '*/' -> skip;
LINE_COMMENT : '//' .*? ('\n'|EOF) -> skip;
Expand Down
6 changes: 3 additions & 3 deletions src/parsers/antlr4/SpecLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ VAL_FALSE: 'false';
VAL_PACKAGE: 'package';
*/

NEVER: EOF '=';
NEVER: EOF '=' <category=meta>;

// Must be able to contain identifiers from any frontend, so it's fine to over-approximate valid identifiers a bit.
LANG_ID_ESCAPE: '`' ~[`]+ '`';
Expand All @@ -46,7 +46,7 @@ VAL_SET: 'set';
VAL_BAG: 'bag';
VAL_POINTER: 'pointer';
VAL_MAP: 'map';
VAL_OPTION: 'option';
VAL_OPTION options { category=spec_type_cons } : 'option';
VAL_EITHER: 'either';
VAL_TUPLE: 'tuple';
VAL_TYPE: 'type';
Expand Down Expand Up @@ -122,7 +122,7 @@ VAL_PERM_VAL: 'perm';
VAL_PERM: 'Perm';
VAL_POINTS_TO: 'PointsTo';
VAL_RUNNING: 'running';
VAL_SOME: 'Some';
VAL_SOME: 'Some';
VAL_LEFT: 'Left';
VAL_RIGHT: 'Right';
VAL_VALUE: 'Value';
Expand Down
Loading
Loading