03-16-2006
lex for Chinese character
Hi,
I need to read one chinese char using lex. I tried using "." ( period ) for pattern matching but in vain.
Could anyone suggest me how do i proceeed.
Sample pgm: to read a chinese char in single quotes.
%{
#include <locale.h>
%}
%%
\'.\' printf("SUCCESS\n");
. printf("Failed\n");
}
%%
main()
{
setlocale(LC_ALL,"");
yylex();
}
This always prints me "Failed" message. I cannot use '.+' for matching for my application.
I can view the chinese char with locale settings on my machine. I am using linux machine . Locale set is : zh_CN.utf8.
Thank You
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
this is my lex file ------------ test.l
%%
printf("%c",yytext+'a'-'A');.ECHO;
how do i compile it
$ lex test.l cc lex.yy.c -o test -ll <------|
|
if this is correct do i add this line--------| @the command line or does it... (0 Replies)
Discussion started by: sinner
0 Replies
2. Shell Programming and Scripting
taskes one or more .l files and compiles them
#!/usr/bin/csh
#while loop to carry on asking user to enter the files
while $number!=0
echo "enter file name"
#check to see if file ends with .l
#if file ends with .l compile lexx.yy.c file for each file
this is how i think it needs... (1 Reply)
Discussion started by: homerj546
1 Replies
3. Programming
Hi all,
I'm working with flex (version 2.5.4a) on GNU/linux. I used it to develop 4 scanner C files for matching different patterns within an input file. But the problem now on my hand is that I need to conditionally combine these. That is in main (placed in a separate C file other than the 4... (5 Replies)
Discussion started by: Rakesh Ranjan
5 Replies
4. Programming
Hi all
I am using lex for my application scanning and I need to skip some lines for which I don't know the exact pattern.
So, could anybody tell me the regular expression to display lines NOT beginning with the specified pattern.
I know how to display lines beginning with the... (1 Reply)
Discussion started by: axes
1 Replies
5. Solaris
Hi everyone,
I would like to know how to compile and run lex programs on solaris 10.
the conventional way is
$ lex <name.l>
$ cc lex.yy.c -ll
$ ./a.out
but while trying to execute the 2nd command :i get a reference saying that the command is old or that main is not supported...
Hence... (1 Reply)
Discussion started by: wrapster
1 Replies
6. Programming
Hi ,
I need to develop a parser which should match something like
1. text a=5 " a=20";
2. text a=..."
a=20";
3 text a=..."
a=20
b=34
c=12
";
I have used this regular expression in my Lex file to generate the tokens:
\".\s*.*\s.\" (8 Replies)
Discussion started by: vishwa787
8 Replies
7. Programming
Hi ,
We have developed a grammer for our domain language using lex n yacc.
I want to know is there any pre defined lex-yacc function which gets call before executing any rule (or rules).
Oue requirement is, before processing any rule ,we want to perform some specific actions ?
is there... (0 Replies)
Discussion started by: supritjain
0 Replies
8. Programming
When i write the source code in netbeans environment,if the source code,there are chinese characters,chinese characters will be displayed as box,how to solve this problem?please (2 Replies)
Discussion started by: fang_xiaoan
2 Replies
9. UNIX for Dummies Questions & Answers
Hi everyone!
This is my very first post, sorry if I'm not posting in the right category.
I'm trying to match a newline "/n" using lex/yacc.
For example,
print(9,'\n',8)
should print
9
8
now do I write a regular expression to match exactly " '\n' "
Thanks! (1 Reply)
Discussion started by: code21
1 Replies
10. Shell Programming and Scripting
Alright, so I'm writing a file for the lexical analyzer (lex). It will be used to check C code (collecting the identifiers and storing those names along with the line numbers the identifier was found on). I'm not used to 'C' so I'm having some difficulty.
I am using a function (insertId()) to... (4 Replies)
Discussion started by: D2K
4 Replies
LEARN ABOUT OSX
setlocale
SETLOCALE(3) BSD Library Functions Manual SETLOCALE(3)
NAME
setlocale -- natural language formatting for C
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <locale.h>
char *
setlocale(int category, const char *locale);
DESCRIPTION
The setlocale() function sets the C library's notion of natural language formatting style for particular sets of routines. Each such style
is called a 'locale' and is invoked using an appropriate name passed as a C string.
The setlocale() function recognizes several categories of routines. These are the categories and the sets of routines they select:
LC_ALL Set the entire locale generically.
LC_COLLATE Set a locale for string collation routines. This controls alphabetic ordering in strcoll() and strxfrm().
LC_CTYPE Set a locale for the ctype(3) and multibyte(3) functions. This controls recognition of upper and lower case, alphabetic or non-
alphabetic characters, and so on.
LC_MESSAGES Set a locale for message catalogs, see catopen(3) function.
LC_MONETARY Set a locale for formatting monetary values; this affects the localeconv() function.
LC_NUMERIC Set a locale for formatting numbers. This controls the formatting of decimal points in input and output of floating point num-
bers in functions such as printf() and scanf(), as well as values returned by localeconv().
LC_TIME Set a locale for formatting dates and times using the strftime() function.
Only three locales are defined by default: the empty string "" (which denotes the native environment) and the "C" and "POSIX" locales (which
denote the C-language environment). A locale argument of NULL causes setlocale() to return the current locale. By default, C programs start
in the "C" locale. The only function in the library that sets the locale is setlocale(); the locale is never changed as a side effect of
some other routine.
RETURN VALUES
Upon successful completion, setlocale() returns the string associated with the specified category for the requested locale. The setlocale()
function returns NULL and fails to change the locale if the given combination of category and locale makes no sense.
FILES
$PATH_LOCALE/locale/category
/usr/share/locale/locale/category locale file for the locale locale and the category category.
ERRORS
No errors are defined.
SEE ALSO
colldef(1), mklocale(1), catopen(3), ctype(3), localeconv(3), multibyte(3), strcoll(3), strxfrm(3), euc(5), utf8(5), environ(7)
STANDARDS
The setlocale() function conforms to ISO/IEC 9899:1999 (``ISO C99'').
HISTORY
The setlocale() function first appeared in 4.4BSD.
BSD
November 21, 2003 BSD