mirror of
https://github.com/acpica/acpica/
synced 2025-02-24 09:24:08 +03:00
iASL: add line continuation support for DT compiler flex/bison
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
This commit is contained in:
parent
361d88d1dd
commit
313a092645
@ -1311,6 +1311,11 @@ char *
|
||||
AcpiUtStrdup(
|
||||
char *String);
|
||||
|
||||
char *
|
||||
AcpiUtStrcat(
|
||||
char *String1,
|
||||
char *String2);
|
||||
|
||||
|
||||
/*
|
||||
* asluuid - UUID support
|
||||
|
@ -1078,3 +1078,30 @@ AcpiUtStrdup(
|
||||
strcpy (NewString, String);
|
||||
return (NewString);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiUtStrcat
|
||||
*
|
||||
* PARAMETERS: String1
|
||||
* String2
|
||||
*
|
||||
* RETURN: New string with String1 concatenated with String2
|
||||
*
|
||||
* DESCRIPTION: Concatenate string1 and string2
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
char *
|
||||
AcpiUtStrcat(
|
||||
char *String1,
|
||||
char *String2)
|
||||
{
|
||||
UINT32 String1Length = strlen (String1);
|
||||
char *NewString = (char *) UtLocalCalloc (strlen (String1) + strlen (String2) + 1);
|
||||
|
||||
strcpy (NewString, String1);
|
||||
strcpy (NewString + String1Length, String2);
|
||||
return (NewString);
|
||||
}
|
||||
|
@ -179,21 +179,38 @@ int DtCompilerParserByteOffset = 0;
|
||||
|
||||
/* Indicates a state used for parsing multiline C comments */
|
||||
%x ML_COMMENT
|
||||
%x DATA_STATE
|
||||
|
||||
WhiteSpace [ \t\v\r]+
|
||||
NewLines [\n]+
|
||||
|
||||
/* Avoid ", \n, and [] as a part of data. These are not valid characters of data */
|
||||
Data [^ ":\n\[\]]([^":\n\[\]]*[^" :\n\[\]])?
|
||||
/* Avoid ", \n, and [] as a part of label name. These are not valid characters of a label name */
|
||||
LabelName [^ ":\n\[\]]([^":\n\[\]]*[^" :\n\[\]])?
|
||||
|
||||
/* Avoid ", \n, \\, and [] as a part of data. These are not valid characters of data */
|
||||
Data [^ \\":\n\[\]]([^":\n\[\]\\]*[^" :\n\[\]\\])?
|
||||
|
||||
Text [^ ":\n][^":\n]*
|
||||
Comment \[{Text}\]
|
||||
BitLenComment \[[:xdigit:]+\]
|
||||
Comment \[[^\n\[\]]*\]
|
||||
CommentField {LabelName}{WhiteSpace}*:{WhiteSpace}{Comment}?$
|
||||
|
||||
|
||||
%%
|
||||
|
||||
{WhiteSpace} /* Ignore */
|
||||
{BitLenComment} /* Ignore */ { printf ("Bit length comment detected\n"); }
|
||||
{Comment} /* Ignore */ { printf ("Comment detected\n"); }
|
||||
<DATA_STATE>{WhiteSpace}"\\\n" {
|
||||
DbgPrint(ASL_PARSE_OUTPUT,"Continuation matched\n");
|
||||
return (DT_PARSEOP_LINE_CONTINUATION);
|
||||
}
|
||||
|
||||
":" {
|
||||
DbgPrint(ASL_PARSE_OUTPUT, ": Matched\n");
|
||||
BEGIN (DATA_STATE);
|
||||
return (':');
|
||||
}
|
||||
|
||||
<INITIAL,DATA_STATE>{WhiteSpace} { DbgPrint(ASL_PARSE_OUTPUT,"Whitespace matched\n"); }
|
||||
|
||||
<INITIAL,DATA_STATE>{Comment} { DbgPrint(ASL_PARSE_OUTPUT,"Comment matched\n"); }
|
||||
|
||||
"/*" { BEGIN (ML_COMMENT); }
|
||||
<ML_COMMENT>"*/" { BEGIN (INITIAL); }
|
||||
@ -202,28 +219,47 @@ BitLenComment \[[:xdigit:]+\]
|
||||
"//".* /* Ignore */
|
||||
|
||||
|
||||
{Data} {
|
||||
char *s;
|
||||
int size = strlen (DtCompilerParsertext);
|
||||
s=UtLocalCacheCalloc (size + 1);
|
||||
AcpiUtSafeStrncpy (s, DtCompilerParsertext, size + 1);
|
||||
DtCompilerParserlval.s = s;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "Data: %s\n", s);
|
||||
return (DT_PARSEOP_DATA);
|
||||
}
|
||||
<DATA_STATE>{Data} {
|
||||
char *s;
|
||||
int size = strlen (DtCompilerParsertext);
|
||||
s=UtLocalCacheCalloc (size + 1);
|
||||
AcpiUtSafeStrncpy (s, DtCompilerParsertext, size + 1);
|
||||
DtCompilerParserlval.s = s;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "Data: %s\n", s);
|
||||
return (DT_PARSEOP_DATA);
|
||||
}
|
||||
|
||||
\"{Text}\" { // remove outer quotes from the string, they are unnecessary
|
||||
char *s;
|
||||
int size = strlen (DtCompilerParsertext);
|
||||
s=UtLocalCacheCalloc (size - 1);
|
||||
AcpiUtSafeStrncpy (s, DtCompilerParsertext + 1, size - 1);
|
||||
DtCompilerParserlval.s = s;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "String Data: %s\n", s);
|
||||
return (DT_PARSEOP_STRING_DATA);
|
||||
}
|
||||
{CommentField} /* ignore */
|
||||
|
||||
{LabelName} {
|
||||
char *s;
|
||||
int size = strlen (DtCompilerParsertext);
|
||||
s=UtLocalCacheCalloc (size + 1);
|
||||
AcpiUtSafeStrncpy (s, DtCompilerParsertext, size + 1);
|
||||
DtCompilerParserlval.s = s;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "Label: %s\n", s);
|
||||
return (DT_PARSEOP_LABEL);
|
||||
}
|
||||
|
||||
|
||||
<DATA_STATE>\"{Text}?\" { // remove outer quotes from the string, they are unnecessary
|
||||
char *s;
|
||||
int size = strlen (DtCompilerParsertext);
|
||||
s=UtLocalCacheCalloc (size - 1);
|
||||
AcpiUtSafeStrncpy (s, DtCompilerParsertext + 1, size - 1);
|
||||
DtCompilerParserlval.s = s;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "String Data: %s\n", s);
|
||||
BEGIN (INITIAL);
|
||||
return (DT_PARSEOP_STRING_DATA);
|
||||
}
|
||||
|
||||
|
||||
<INITIAL,DATA_STATE>{NewLines} {
|
||||
DbgPrint(ASL_PARSE_OUTPUT,
|
||||
"Newline matched (data state). Current line number: %u\n",DtCompilerParserlineno);
|
||||
BEGIN (INITIAL); DtCompilerParsercolumn = 1;
|
||||
}
|
||||
|
||||
":" { return (':'); }
|
||||
{NewLines} { DtCompilerParsercolumn = 1; return ('\n'); } /* helps with ambiguity for labels that aren't associated to data */
|
||||
|
||||
%%
|
||||
|
||||
|
@ -206,10 +206,15 @@ extern UINT64 DtCompilerParserlineno; /* Current line number */
|
||||
}
|
||||
|
||||
|
||||
%type <f> Table
|
||||
%token <s> DT_PARSEOP_DATA
|
||||
%token <s> DT_PARSEOP_STRING_DATA
|
||||
%type <s> Data
|
||||
%type <f> Table
|
||||
%token <s> DT_PARSEOP_DATA
|
||||
%token <s> DT_PARSEOP_LABEL
|
||||
%token <s> DT_PARSEOP_STRING_DATA
|
||||
%token <s> DT_PARSEOP_LINE_CONTINUATION
|
||||
%type <s> Data
|
||||
%type <s> Datum
|
||||
%type <s> MultiLineData
|
||||
%type <s> MultiLineDataList
|
||||
|
||||
|
||||
%%
|
||||
@ -225,15 +230,30 @@ FieldList
|
||||
;
|
||||
|
||||
Field
|
||||
: DT_PARSEOP_DATA ':' '\n' /* ignore this field, it has no valid data */
|
||||
| DT_PARSEOP_DATA ':' Data '\n' { DtCreateField ($1, $3, (@3).first_line, (@1).first_byte_offset, (@1).first_column, (@3).first_column); }
|
||||
: DT_PARSEOP_LABEL ':' Data { DtCreateField ($1, $3, (@3).first_line, (@1).first_byte_offset, (@1).first_column, (@3).first_column); }
|
||||
;
|
||||
|
||||
Data
|
||||
: DT_PARSEOP_DATA { DbgPrint (ASL_PARSE_OUTPUT, "parser data: [%s]", DtCompilerParserlval.s); $$ = AcpiUtStrdup(DtCompilerParserlval.s); }
|
||||
| DT_PARSEOP_STRING_DATA { DbgPrint (ASL_PARSE_OUTPUT, "parser string data: [%s]", DtCompilerParserlval.s); $$ = AcpiUtStrdup(DtCompilerParserlval.s); }
|
||||
: MultiLineDataList { $$ = $1; }
|
||||
| Datum { $$ = $1; }
|
||||
| Datum MultiLineDataList { $$ = $1; } /* combine the string with strcat */
|
||||
;
|
||||
|
||||
MultiLineDataList
|
||||
: MultiLineDataList MultiLineData { $$ = AcpiUtStrcat(AcpiUtStrcat($1, " "), $2); } /* combine the strings with strcat */
|
||||
| MultiLineData { $$ = $1; }
|
||||
;
|
||||
|
||||
MultiLineData
|
||||
: DT_PARSEOP_LINE_CONTINUATION Datum { DbgPrint (ASL_PARSE_OUTPUT, "line continuation detected\n"); $$ = $2; }
|
||||
;
|
||||
|
||||
Datum
|
||||
: DT_PARSEOP_DATA { DbgPrint (ASL_PARSE_OUTPUT, "parser data: [%s]\n", DtCompilerParserlval.s); $$ = AcpiUtStrdup(DtCompilerParserlval.s); }
|
||||
| DT_PARSEOP_STRING_DATA { DbgPrint (ASL_PARSE_OUTPUT, "parser string data: [%s]\n", DtCompilerParserlval.s); $$ = AcpiUtStrdup(DtCompilerParserlval.s); }
|
||||
;
|
||||
|
||||
|
||||
%%
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user