antlr-ng
Version:
Next generation ANTLR Tool
63 lines (62 loc) • 2.12 kB
TypeScript
import { ActionAST } from "../tool/ast/ActionAST.js";
import { AttributeDict } from "../tool/AttributeDict.js";
import { Grammar } from "../tool/Grammar.js";
/**
* Parse args, return values, locals
* ```
* rule[arg1, arg2, ..., argN] returns [ret1, ..., retN]
* ```
* Text is target language dependent. Java/C#/C/C++ would use "int i" but ruby/python would use "i". Languages with
* postfix types like Go, Swift use "x : T" notation or "T x".
*/
export declare class ScopeParser {
/**
* Given an arg or retval scope definition list like
* ```
* Map<String, String>, int[] j3, char *foo32[3]
* ```
* or
* ```
* int i=3, j=a[34]+20
* ```
* convert to an attribute scope.
*
* @param action The action node that contains the decl.
* @param s The decl to parse.
* @param g The grammar.
*
* @returns The attribute scope.
*/
static parseTypedArgList(action: ActionAST | null, s: string, g: Grammar): AttributeDict;
private static parse;
/**
* For decls like "String foo" or "char *foo32[]" compute the ID and type declarations. Also handle "int x=3"
* and 'T t = new T("foo")' but if the separator is ',' you cannot use ',' in the init value
* unless you escape use "\," escape.
*
* @param action The action node that contains the decl.
* @param decl The decl to parse.
* @param g The grammar.
*
* @returns The attribute definition.
*/
private static parseAttributeDef;
private static parsePrefixDecl;
private static parsePostfixDecl;
/**
* Given an argument list like
* ```
* x, (*a).foo(21,33), 3.2+1, '\n',
* "a,oo\nick", {bl, "abc"eck}, ["cat\n,", x, 43]
* ```
* convert to a list of attributes. Allow nested square brackets etc...
* Set separatorChar to ';' or ',' or whatever you want.
*
* @param s The argument list to parse.
* @param separatorChar The separator character.
*
* @returns The list of attributes.
*/
private static splitDecls;
private static splitArgumentList;
}