Is there any way to have an Alex macro defined in one source file and used in other source files? In my case, I have definitions for $LowerCaseLetter and $UpperCaseLetter (these are all letters except e and O, since they have special roles in my code). How can I refer to these macros from other .x files?
Use Alex macros from another file
191 Views Asked by Paul Manta At
1
There are 1 best solutions below
Related Questions in HASKELL
- Cabal sandbox is using a global dependency. Could not resolve
- Haskell lens: let binding of Traversal'
- How can I parse fixed-length, non-delimited integers with attoparsec?
- Pipeline-like operation using TChan
- compile-time vs. run-time cost of Hamlet templates
- Date-time package in haskell - error in the current one, can't find an analog
- How does one debug infinite recursion in Haskell?
- Force GHC using local files
- List with random numbers in Haskell
- Changes in other elements based on listbox selections in threepenny-gui
- Multithreading and gtk2hs
- Operator section for applicative with <$> and <*>
- Unable to create a custom header to use it in "withManager"
- How do I reuse an intermediate value in chain of Haskell Either binds?
- Haskell, Tree problems
Related Questions in MACROS
- Writing a `define-let` macro, with hygiene
- Find all functions generated by macros
- How to token paste a number?
- Parentheses and macro overloading in C++
- Is there any way to skip macro replacement(During preprocessing) when macro is used as a variable name?
- Why is it not advised to define macros in header files?
- What does the non-terminating-p argument of set-macro-character do?
- Calling a table of function using repeat blocks or macros in GNU assembly
- x-macro conditional error - number comparison
- SAS Concatenate Multiple Variables to Create Data-Driven Macro Statements
- clojure quoting inside let
- Julia: How do I create a macro that returns its argument?
- How do I unit test clojure.core.async go macros?
- Defining Macros that are equal to functions that return objects in C++
- syntax error : missing ')' before 'constant'
Related Questions in ALEX
- Parsing complex files with Parsec
- How to use an Alex monadic lexer with Happy?
- Managing position information with Alex and Happy
- Use Alex macros from another file
- Haskell Alex: basic-bytestring lexer leaks memory
- Can LALR parser generators optionally consume unparsable input?
- Haskell parser created with Alex and Happy doesn't work because of main function, someone can tell me why?
- Is there an haskell EDSL for writing lexers?
- Cabal tries to build unknown package when building with alex, happy in nix-shell
- Why is this lexer not parsing this input?
- Alex monad wrapper difference between ; and skip
- Suppress certain Haskell Alex/Happy compilation messages
- Is there a way to put Haskell code before the token rules in an Alex source file?
- How to pass command-line options to Alex in Cabal
- GetWeeklySchedule directive not being sent by Amazon
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Disproving something exists is always harder than finding something that does exist, but I think the info below does show that Alex can only get macro definitions from the .x file it is reading (other than predefinied stuff like
$white), and not via includes from other files....You can get the sourcecode for Alex by doing the following:
In src/Main.hs, predefined macros are first set in variables called
initSetEnv(charset macros$white,$printable, and "."), andinitREEnv(regexp macros, there are none). This gets passed into runP, in src/ParseMonad.hs, which is used to hold the current parsing state, including all defined macros. The initial state is set using the values passed in, but macros can be added using a function callednewSMac(ornewRMacfor regular expression macros).Since this seems to be the only way that macros can be set, it is then only a matter of some grep bookkeeping to verify the only ways that macros can be added is through an actual macro definition in the source .x file. Unsurprisingly, Alex recursively uses its own .x/.y files for .x source file parsing (src/parser.y, src/Scan.x). It is a couple of levels of indirection away, but you can verify that the only way
newSMaccan be called is through the src/Scan.x macroOther than some obvious predefined stuff, I don't believe reuse in lexers is all that typical anyway, because at the token level things are usually pretty simple (often simple tokens like
SPACE,WORD,NUMBER, and a few operators, symbols and parens are all that are needed). The complexity comes at the parsing stage, although for technical reasons, parser-includes aren't that common either (see scannerless parsing for a newer technology that does allow reuse through nesting, like javascript embedded in html.... The tools for scannerless parsing are still pretty primitive though).