mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
New file.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1882 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
05f694ad66
commit
9150d93f9c
2 changed files with 278 additions and 0 deletions
148
Source/stringsfile.l
Normal file
148
Source/stringsfile.l
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
%{
|
||||||
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include "stringsfile.tab.h"
|
||||||
|
|
||||||
|
#ifdef sfwrap
|
||||||
|
#undef sfwrap
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int sfwrap()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
quote \"
|
||||||
|
semicolen \;
|
||||||
|
equals \=
|
||||||
|
label [a-zA-Z][a-zA-Z0-9_]*
|
||||||
|
quoted [^"]*\"
|
||||||
|
whitespace [ \t\n]
|
||||||
|
startComment \/\*
|
||||||
|
endComment \*\/
|
||||||
|
|
||||||
|
|
||||||
|
%x QUOTE COMMENT
|
||||||
|
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
<COMMENT>{endComment} { BEGIN INITIAL; }
|
||||||
|
|
||||||
|
<COMMENT>. ;
|
||||||
|
|
||||||
|
<QUOTE>{quoted} {
|
||||||
|
if (sfleng == 1)
|
||||||
|
{
|
||||||
|
BEGIN INITIAL;
|
||||||
|
sflval.obj = [[[NSString alloc] init] autorelease];
|
||||||
|
return QUOTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sftext[sfleng - 2] == '\\')
|
||||||
|
yymore();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BEGIN INITIAL;
|
||||||
|
sflval.obj = [[[NSString alloc] initWithCString: sftext length: sfleng - 1] autorelease];
|
||||||
|
return QUOTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{quote} {BEGIN QUOTE;}
|
||||||
|
|
||||||
|
{startComment} {BEGIN COMMENT;}
|
||||||
|
|
||||||
|
{label} {
|
||||||
|
sflval.obj = [NSString stringWithCString: sftext];
|
||||||
|
return LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
{semicolen} {return SEMICOLEN;}
|
||||||
|
|
||||||
|
{equals} {return EQUALS;}
|
||||||
|
|
||||||
|
{whitespace}+ ;
|
||||||
|
|
||||||
|
|
||||||
|
. { return ERROR; }
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include "stringsfile.tab.h"
|
||||||
|
|
||||||
|
#ifdef sfwrap
|
||||||
|
#undef sfwrap
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int sfwrap()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
quote \"
|
||||||
|
semicolen \;
|
||||||
|
equals \=
|
||||||
|
label [a-zA-Z][a-zA-Z0-9_]*
|
||||||
|
quoted [^"]*\"
|
||||||
|
whitespace [ \t\n]
|
||||||
|
startComment \/\*
|
||||||
|
endComment \*\/
|
||||||
|
|
||||||
|
|
||||||
|
%x QUOTE COMMENT
|
||||||
|
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
<COMMENT>{endComment} { BEGIN INITIAL; }
|
||||||
|
|
||||||
|
<COMMENT>. ;
|
||||||
|
|
||||||
|
<QUOTE>{quoted} {
|
||||||
|
if (sfleng == 1)
|
||||||
|
{
|
||||||
|
BEGIN INITIAL;
|
||||||
|
sflval.obj = [[[NSString alloc] init] autorelease];
|
||||||
|
return QUOTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sftext[sfleng - 2] == '\\')
|
||||||
|
yymore();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BEGIN INITIAL;
|
||||||
|
sflval.obj = [[[NSString alloc] initWithCString: sftext length: sfleng - 1] autorelease];
|
||||||
|
return QUOTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{quote} {BEGIN QUOTE;}
|
||||||
|
|
||||||
|
{startComment} {BEGIN COMMENT;}
|
||||||
|
|
||||||
|
{label} {
|
||||||
|
sflval.obj = [NSString stringWithCString: sftext];
|
||||||
|
return LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
{semicolen} {return SEMICOLEN;}
|
||||||
|
|
||||||
|
{equals} {return EQUALS;}
|
||||||
|
|
||||||
|
{whitespace}+ ;
|
||||||
|
|
||||||
|
|
||||||
|
. { return ERROR; }
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
130
Source/stringsfile.y
Normal file
130
Source/stringsfile.y
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSDictionary.h>
|
||||||
|
static NSMutableDictionary *properties;
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%token <obj> QUOTED LABEL
|
||||||
|
%token SEMICOLEN EQUALS ERROR
|
||||||
|
|
||||||
|
%union {
|
||||||
|
id obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
%type <obj> value
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
file: asignments
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
| error
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
| ERROR
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
asignments: asignment
|
||||||
|
| asignments asignment
|
||||||
|
;
|
||||||
|
|
||||||
|
asignment: value EQUALS value SEMICOLEN
|
||||||
|
{
|
||||||
|
[(NSMutableDictionary *)properties setObject: $3 forKey: (NSString *) $1];
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
value: LABEL
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
| QUOTED
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
};
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int sferror(char *s)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfSetDict(NSMutableDictionary *aDict)
|
||||||
|
{
|
||||||
|
properties = aDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSDictionary.h>
|
||||||
|
static NSMutableDictionary *properties;
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%token <obj> QUOTED LABEL
|
||||||
|
%token SEMICOLEN EQUALS ERROR
|
||||||
|
|
||||||
|
%union {
|
||||||
|
id obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
%type <obj> value
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
file: asignments
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
| error
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
| ERROR
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
asignments: asignment
|
||||||
|
| asignments asignment
|
||||||
|
;
|
||||||
|
|
||||||
|
asignment: value EQUALS value SEMICOLEN
|
||||||
|
{
|
||||||
|
[(NSMutableDictionary *)properties setObject: $3 forKey: (NSString *) $1];
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
value: LABEL
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
| QUOTED
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
};
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int sferror(char *s)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfSetDict(NSMutableDictionary *aDict)
|
||||||
|
{
|
||||||
|
properties = aDict;
|
||||||
|
}
|
Loading…
Reference in a new issue